This file contains hidden or 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
# Five lines of code that will make your underscore + CoffeeScript use cleaner. | |
# Creates an underscore function for each function in to_reverse with R (short for Reversed) appended to the name. | |
# The R version moves the function argument (first argument in normal underscore) to the end, | |
# so you can write: | |
$(window).scroll _.throttleR 500, -> | |
console.log "This print's at most every 500ms" | |
# Instead of: | |
$(window).scroll _.throttle -> | |
console.log "This prints at most every 500ms too" |
This file contains hidden or 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 skein | |
from random import choice | |
target = '5b4da95f5fa08280fc9879df44f418c8f9f12ba424b7757de02bbdfbae0d4c4fdf9317c80cc5fe04c6429073466cf29706b8c25999ddd2f6540d4475cc977b87f4757be023f19b8f4035d7722886b78869826de916a79cf9c94cc79cd4347d24b567aa3e2390a573a373a48a5e676640c79cc70197e1c5e7f902fb53ca1858b6' | |
def bitcount(v): | |
if v > 0: | |
return (v & 1) + bitcount(v>>1) | |
else: | |
return 0 |
This file contains hidden or 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
cheater = | |
start_game: -> | |
@count = 0 | |
global.Math = {random: => @count++} | |
guess_index: (cur_num) -> | |
return cur_num | |
name: "Cheater" |
This file contains hidden or 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
S3 traceroute: | |
traceroute to s3-1-w.amazonaws.com (54.231.0.145), 64 hops max, 52 byte packets | |
1 104.36.1.1 (104.36.1.1) 3.439 ms 2.982 ms 3.082 ms | |
2 172.16.66.17 (172.16.66.17) 4.792 ms 4.924 ms 3.081 ms | |
3 172.16.70.41 (172.16.70.41) 1.868 ms 6.502 ms 8.978 ms | |
4 xe-0-3-0-17.r06.nycmny01.us.bb.gin.ntt.net (129.250.192.129) 2.753 ms 2.169 ms 2.273 ms | |
5 ae-9.amazon.nycmny01.us.bb.gin.ntt.net (129.250.201.130) 2.094 ms | |
ae-11.amazon.nycmny01.us.bb.gin.ntt.net (129.250.201.138) 2.475 ms | |
ae-10.amazon.nycmny01.us.bb.gin.ntt.net (129.250.201.134) 2.133 ms | |
6 54.240.229.78 (54.240.229.78) 8.173 ms |
This file contains hidden or 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
#![feature(collections)] | |
#![feature(box_patterns)] | |
#[derive(Clone, Debug)] | |
enum Regex { | |
Term(RegexTerm), | |
Or(RegexTerm, Box<Regex>), | |
} | |
impl Regex { |
This file contains hidden or 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
#![feature(collections)] | |
#![feature(box_patterns)] | |
#[cfg(feature = "simple")] | |
pub fn matches(regex : &str, target : &str) -> bool { | |
match (regex.slice_shift_char(), target.slice_shift_char()) { | |
// Both strings are emtpy, so we've got a match. | |
(None, None) => true, | |
// We're looking at _*, match the kleene star. |
This file contains hidden or 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
21 @ 0x26be6 0x12f4d 0x135bc 0x69d24 0x26db0 | |
# 0x69d24 jello/models.resizeAndWrite+0x6145 | |
~/go/src/jello/models/photo.go:149 |
This file contains hidden or 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
func createAlternateSizes(photoPath string, img image.Image, block bool) error { | |
// Put a white background on all the resized images. | |
whiteImg := imageWithWhiteBg(img) | |
numberOfResizes := 3 | |
c := make(chan error, numberOfResizes) | |
go resizeAndWrite(whiteImg, 640, photoPath + "_f", c) | |
go resizeAndWrite(whiteImg, 290, photoPath + "_s", c) | |
go resizeAndWrite(whiteImg, 200, photoPath + "_d", c) | |
This file contains hidden or 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
func createAlternateSizes(photoPath string, img image.Image, block bool) error { | |
// Put a white background on all the resized images. | |
whiteImg := imageWithWhiteBg(img) | |
c := make(chan error, 0) | |
go resizeAndWrite(whiteImg, 640, photoPath + "_f", c) | |
go resizeAndWrite(whiteImg, 290, photoPath + "_s", c) | |
go resizeAndWrite(whiteImg, 200, photoPath + "_d", c) | |
if block { |
This file contains hidden or 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
func resizeAndWrite(img image.Image, width int, path string, c chan error) { | |
newImg := resize.Resize(uint(width), 0, img, resize.Bicubic) | |
err := writeJpegToS3(s, newImg, path) | |
// Write back to the channel with the status of the S3 write operation. | |
c <- err | |
} |
NewerOlder