This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ssh localhost "sleep 99 < <(cat; kill -INT 0)" <&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://mrdanadams.com/2011/partials-ajax-form-submit-rails/#.UWcy9kDCHsg | |
// http://stackoverflow.com/questions/18770517/rails-4-how-to-use-document-ready-with-turbo-links | |
$(document).on ('ajax:success', 'form[data-update-target], a[data-update-target]', function (evt, data) { | |
var dom = $(data); | |
$('#messages').html(dom.siblings('#messages:first').contents()); | |
var target = $(this).data('update-target'); | |
$('#' + target).html(dom.siblings('#body:first').contents()); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
require 'fileutils' | |
def run(args) | |
args = args.gsub /$/, '' | |
`#{args}` | |
end | |
def listzip(file) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Iterator; | |
public class Each { | |
public static class Indexed<T> { | |
public T value; | |
public int index; | |
public Indexed (T value, int index) { | |
this.value = value; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def rescue_wait(timeout, increment = 2) | |
start = Time.now | |
begin | |
yield | |
return true | |
rescue Exception => e | |
puts e.message | |
sleep increment | |
retry unless Time.now-start > timeout | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
swaplast = !git tag _invert && git reset --hard HEAD~2 && git cherry-pick _invert _invert~1 && git tag -d _invert | |
invertindex = !git commit -m tmp1 && git add -A && git commit -m tmp2 && git swaplast && git reset HEAD~1 && git reset HEAD~1 --soft |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Object methodToOverride () { | |
Object temp = super.methodToOverride (); | |
/// do post-super stuff | |
return temp; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Object methodToOverride () { | |
try { | |
return super.methodToOverride (); | |
} finally { | |
// do post-super stuff | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ContentValues toContentValues (User user) { | |
ContentValues values = new ContentValues (); | |
switch (Column._id) { | |
case _id: // auto-incremented primary key, skip this one | |
case sync_state: values.put (Column.sync_state.name (), user.getSyncState ()); | |
case user_id: values.put (Column.user_id.name (), user.getUserId ()); | |
} | |
return values; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static enum Column { | |
_id ("INTEGER PRIMARY KEY"), | |
sync_state ("STRING NOT NULL DEFAULT 'none'"), | |
user_id ("LONG NOT NULL"), | |
... | |
; | |
} |
NewerOlder