Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am jimtla on github.
* I am jimtla (https://keybase.io/jimtla) on keybase.
* I have a public key whose fingerprint is 9997 4223 B138 49BF 6F43 C80F AA4A 7117 AC09 F449
To claim this, I am signing this object:
@jimtla
jimtla / main.go
Created August 21, 2014 22:51
Test Program for Golang's heap profiler
package main
import (
"log"
"net/http"
_ "net/http/pprof"
)
func wasteMemory() {
s := "ABCDEFGHIJKLMNOPQRSTUVWXYZ00123456789"
@jimtla
jimtla / resizeAndWrite.go
Last active August 29, 2015 14:05
Code Sample for Go Leaks blog post
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
}
@jimtla
jimtla / gist:32dab1bb0ea0424710f8
Last active August 29, 2015 14:05
Code Sample for Go Leaks blog post
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 {
@jimtla
jimtla / gist:6693f7614ecfcd5fa7e9
Created August 21, 2014 23:54
Code Sample for Go Leaks blog post
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)
@jimtla
jimtla / gist:6c5191760729d0ec2502
Created August 22, 2014 00:04
Code Sample for Go Leaks blog post
21 @ 0x26be6 0x12f4d 0x135bc 0x69d24 0x26db0
# 0x69d24 jello/models.resizeAndWrite+0x6145
~/go/src/jello/models/photo.go:149
#![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.
#![feature(collections)]
#![feature(box_patterns)]
#[derive(Clone, Debug)]
enum Regex {
Term(RegexTerm),
Or(RegexTerm, Box<Regex>),
}
impl Regex {
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
@jimtla
jimtla / cheater.coffee
Created March 12, 2013 15:31
A perfect solution to AlexeyMK/guessing-game, although I can't help but feel it violates the spirit of the game.
cheater =
start_game: ->
@count = 0
global.Math = {random: => @count++}
guess_index: (cur_num) ->
return cur_num
name: "Cheater"