Thursday, March 3, 2016

Reset local git branch to match remote

Setting your branch to exactly match the remote branch can be done in two steps:

git fetch origin
git reset --hard origin/master


Deleting git tags

Delete tag locally

git tag -d tagName

Delete tag on remote

git push --delete origin tagName

Tuesday, February 16, 2016

jquery ajax timeout

When making an ajax request, it seems that jQuery only sets the timeout when the timeout property in the $.ajax call is defined.

You can see that from here https://github.com/jquery/jquery/blob/master/src/ajax.js#L684

Here is an excerpt from http://api.jquery.com/jquery.ajax/#timeout
Set a timeout (in milliseconds) for the request. This will override any global timeout set with $.ajaxSetup(). The timeout period starts at the point the $.ajax call is made; if several other requests are in progress and the browser has no connections available, it is possible for a request to time out before it can be sent. In jQuery 1.4.x and below, the XMLHttpRequest object will be in an invalid state if the request times out; accessing any object members may throw an exception. In Firefox 3.0+ only, script and JSONP requests cannot be cancelled by a timeout; the script will run even if it arrives after the timeout period.

Monday, February 15, 2016

get autocomplete for git on mac os

Weird thing, I installed git for mac and i did not get autocomplete for git.

To fix this I followed this instructions http://www.codethatmatters.com/2010/01/git-autocomplete-in-mac-os-x/


Error starting mysql on mac os after installing with homebrew

I just recently got a mac. I then learnt that I needed to install stuff with homebrew. But after installing mysql via homebrew, I could not get it to work.

Then i read in stackoverflow.com that deleting the error file fixes the startup problem I was having.

The file I deleted is this

usr/local/var/mysql/MacBook-Air.local.err

Wednesday, January 6, 2016

Confine metaClass changes to a specific test class or test method in grails

@ConfineMetaClassChanges([StatisticsService])
StatisticsServiceIntegrationTest extends IntegrationSpec {
    StatisticsService statisticsService
    void "count login to private area"() {
        setup:
            def user = new User(statistics: new UserStatistics())
            statisticsService.metaClass.getCurrentUser = { -> user }
        when:
            statisticsService.countLoginPA()
        then:
            user.statistics.logins == 1
    }    
}

http://spockframework.github.io/spock/javadoc/1.0/spock/util/mop/ConfineMetaClassChanges.html

Reset last local git commit

git reset HEAD~1