Skip to content

Instantly share code, notes, and snippets.

@dallasmarlow
dallasmarlow / gist:8d228807ccacd40b4fd9
Created April 20, 2015 20:53
mysql service wrapper
package main
import (
"bytes"
"errors"
"fmt"
"os/exec"
"strings"
"time"
)
package main
import (
"fmt"
"strings"
"sync"
)
type RowMapper interface {
Map(src chan []string) chan []string
package main
import (
"fmt"
"strings"
"sync"
)
type RowMapper interface {
Map(src chan []string) chan []string
from kombu import Connection
import datetime
import os
with Connection('pyamqp://dallas:marlow@localhost:5672/%s' % os.environ.get('vhost', '/')) as conn:
queue = conn.SimpleQueue('test')
message = 'hello vine - %s' % datetime.datetime.today()
queue.put(message)
print('sent msg: %s' % message)
queue.close()
@dallasmarlow
dallasmarlow / gist:51d0dfed20eed3dc0053
Created December 4, 2014 00:27
today's duplicate imgs
#!/usr/bin/env ruby
today = Time.now.yday
duplicate_files = []
File.read('/opt/images.tsv').lines.reduce([]) do |files, entry|
size, filename = entry.chomp.split
if filename and not filename.empty?
files << [File.basename(filename), filename].join(':')
end
package main
import (
"fmt"
"math"
"sort"
"sync"
"time"
)
@dallasmarlow
dallasmarlow / texttable.go
Last active August 29, 2015 14:08
text tables
package texttable
import (
"bytes"
"errors"
"fmt"
"strconv"
"strings"
"text/tabwriter"
)
if *loopId == 0 || *loopId > *loopMax-1 {
log.Fatalf("invalid loop device number: %d", *loopId)
}
loopDevNum := int((*loopId & 0xff) | ((7 & 0xfff) << 8))
loopDevPath := "/dev/loop" + strconv.Itoa(int(*loopId))
// ensure requested loop device is unique and read file
// permissions from existing loop device
devices, err := ioutil.ReadDir("/dev")
@dallasmarlow
dallasmarlow / gist:b5401069bb6a4c2c7787
Created October 17, 2014 01:34
create gif from images
bash -c "ls * | xargs -I{} -P4 convert {} +repage {}.gif"
gifsicle --loop --resize-fit-width 400 --delay 35 --dither --colors 256 --disposal previous -O2 *.gif > corner.gif
http://thisthread.blogspot.com/2013/06/spoj-prime-generator.html
https://gist.github.com/codysoyland/7164035
http://play.golang.org/p/9U22NfrXeq
http://www.haskell.org/haskellwiki/Prime_numbers
http://en.wikipedia.org/wiki/Generating_primes
http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
http://www.primesdemystified.com/
http://www.psp-project.de/llrnetstats.php
http://www.psp-project.de/stats.html
http://www.henleyclan.co.uk/sobsieve/alltime/scores_t.htm