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
NSImage* zh_road = [NSImage imageNamed:@"zh_road.png"]; | |
NSLog(@"%@", [zh_road representations]); | |
NSBitmapImageRep *rep = [[zh_road representations] objectAtIndex:0]; | |
NSLog(@"bytes per row: %ld, bits per pixel: %ld", [rep bytesPerRow], [rep bitsPerPixel]); | |
unsigned long img_height = [rep pixelsHigh]; | |
unsigned long img_width = [rep pixelsWide]; | |
unsigned char * const bmpData = [rep bitmapData]; | |
unsigned int * const histogram_rgba = calloc(img_width, sizeof(int)); |
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/env perl | |
use 5.010; | |
say ' ' x (10-$_) . '*' x ($_*2+1) for 0..9; | |
say ' ' x 9 . '*' x 3 for 0..2; |
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
(defun wordnet (word) | |
"Check word definition from WordNet command line program" | |
(interactive | |
(list (read-string "Check for word: " | |
(apply 'buffer-substring | |
(let (bounds) | |
(if (use-region-p) | |
(setq bounds (cons (region-beginning) (region-end))) | |
(setq bounds (bounds-of-thing-at-point 'word))) | |
(list (car bounds) (cdr bounds))))))) |
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
(defn overshoot-by-ratio | |
"Takes a list of event, emit an event if the overshoot events is over the ratio. | |
The emitted event will contain a description of the overshoot threshold and the ratio; | |
the metric of the emitted event will be the median of overshoot events. Example: | |
(moving-time-window 300 ; 5 min | |
(overshoot-by-ratio 1500 0.2 ; if the ratio of metrics which more than 1500 | |
; is larger than 0.2, the below would be called | |
(throttle 1 500 | |
(email \"[email protected]\"))))" |
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
(stream | |
(moving-time-window 600 ; 600 sec = 10 min | |
(folds/mean | |
(graphite)) | |
(folds/median | |
(while (> metric 1000) | |
(email "[email protected]"))))) |
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
(stream | |
(while (> metric 2000) | |
(fn [event] (info "Event metric is larger than 2000! event:" event)))) |
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
(defn my-awesome-function [arg1 arg2 & children] | |
(fn [event] | |
; process event with arg1, arg2, and generate my-modified-event | |
(call-rescue my-modified-event children))) |
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
(defn overshoot-by-ratio | |
"Takes a list of event, emit an event if the overshoot events is over the ratio. | |
The emitted event will contain a description of the overshoot threshold and the ratio; | |
the metric of the emitted event will be the median of overshoot events. Example: | |
(moving-time-window 300 ; 5 min | |
(overshoot-by-ratio 1500 0.2 ; if the ratio of metrics which more than 1500 | |
; is larger than 0.2, the below would be called | |
(throttle 1 500 | |
(email \"[email protected]\"))))" |
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
(moving-time-window 600 | |
(overshoot-by-ratio 1000 0.5 | |
#(info %) | |
(email "[email protected]"))) |
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
[{:url "http://www.yahoo.com/" | |
:interval 1000 ;; optional | |
:validator #(re-find #"yahoo" %) ;; optional | |
:http-options {:timeout 2000 ;; :http-options itself is also optional | |
:user-agent "Mozilla"} | |
:graphite-ns "com.yahoo.www" ;; defualt to reverse domain name | |
:params-fn (map #(hash-map :id %) (iterate inc 0)) ;; programatically control query params | |
:riemann-tags ["Yahoo" "Homepage"] | |
} | |
{:url "http://www.google.com/?search=abc" |