$(document).one('feature-a', '#some-id', function() {
$(document).on('some-event', '#some-ids', handler);
});
//Turn on feature a
$('#a, #b').trigger('feature-a');
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
ruby -run -e httpd . -p 3000 |
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 x (agent 0)) | |
@x ; 0 | |
(send x inc) | |
@x ; 1 | |
(send x + 10) | |
@x ; 11 |
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
(clojure.core.logic/unifier '[(+ ?x 1) (inc ?x)] '[(+ a 1) ?refactored]) | |
;[(+ a 1) (inc a)] |
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://gitready.com/intermediate/2009/02/06/helpful-command-aliases.html | |
git config --global alias.rb rebase | |
git config --global alias.st status | |
git config --global alias.ci commit | |
git config --global alias.br branch | |
git config --global alias.co checkout | |
git config --global alias.df df | |
git config --global alias.lg log -p | |
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 float distFrom(float lat1, float lng1, float lat2, float lng2) { | |
double earthRadius = 3958.75; | |
double dLat = Math.toRadians(lat2-lat1); | |
double dLng = Math.toRadians(lng2-lng1); | |
double a = Math.sin(dLat/2) * Math.sin(dLat/2) + | |
Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * | |
Math.sin(dLng/2) * Math.sin(dLng/2); | |
double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); | |
double dist = earthRadius * c; |
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
;; from http://www.learningclojure.com/2010/09/astonishing-macro-of-narayan-singhal.html | |
(defmacro def-let | |
"like let, but binds the expressions globally." | |
[bindings & more] | |
(let [let-expr (macroexpand `(let ~bindings)) | |
names-values (partition 2 (second let-expr)) | |
defs (map #(cons 'def %) names-values)] | |
(concat (list 'do) defs more))) | |
;; from http://blog.gaz-jones.com/2012/02/04/debug_let.html |
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 long-list (into (repeat 10000 0) [9 9 9 9 9])) | |
(dotimes [_ 10] | |
(time | |
(dotimes [_ 1000] | |
(sort long-list) | |
))) |
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
ab -n 5000 -c 50 http://localhost:8080/ |
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
[MBProgressHUD showHUDAddedTo:[self.view.window.subviews objectAtIndex:0] animated:YES]; | |
dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{ | |
// Do something... | |
dispatch_async(dispatch_get_main_queue(), ^{ | |
[MBProgressHUD hideHUDForView:[self.view.window.subviews objectAtIndex:0] animated:YES]; | |
}); | |
}); | |
[MBProgressHUD HUDForView: [UIApplication sharedApplication].keyWindow] |
OlderNewer