Skip to content

Instantly share code, notes, and snippets.

View dyerw's full-sized avatar
🦑
squiddin'

Liam Dyer dyerw

🦑
squiddin'
  • Chicago, IL
View GitHub Profile
@dyerw
dyerw / anagram_finder.clj
Last active August 29, 2015 13:59
finds all anagrams in a text file
(defn get-words-from-file [file-name]
(into [] (re-seq #"\b[a-zA-Z]+\b" (slurp file-name))))
(defn is-anagram? [word1 word2]
(let [word1-letters (seq word1)
word2-letters (seq word2)]
(= (sort word1-letters) (sort word2-letters))))
(defn get-ana-set [word other-words]
(loop [words other-words
@dyerw
dyerw / rest.go
Created October 20, 2014 17:12
Basic REST Api in Go w/ Gorilla
package main
import (
"net/http"
"encoding/json"
"github.com/gorilla/mux"
)
func HomeHandler(rw http.ResponseWriter, r *http.Request) {
rw.Header().Set("Content-Type", "application/json")
@dyerw
dyerw / gist:95b9af4d44671b150552
Created October 23, 2014 18:35
Non-working Go Facebook Form Spammer
package main
import (
"fmt"
"net/http"
"net/url"
"os"
"io/ioutil"
)
@dyerw
dyerw / reflecty.go
Created November 3, 2014 04:54
A bunch of reflective nonsense in go, but a good example
package main
import (
"fmt"
"reflect"
)
type Example struct {
A string
B string
@dyerw
dyerw / coroutines.py
Created January 6, 2015 17:09
A simple producer/consumer example using python coroutines
import random
def coroutine(func):
"""A decorator to automatically prime coroutines"""
def start(*args, **kwargs):
cr = func(*args, **kwargs)
next(cr)
return cr
return start
@dyerw
dyerw / rmbin.sh
Created February 9, 2015 20:49
Unix Command - Removes all binary files from dir, leaving plaintext files
file * | grep -v text | cut -d':' -f1 | xargs rm
@dyerw
dyerw / differ.rb
Last active August 29, 2015 14:16
Takes the difference of two png files
require 'chunky_png'
include ChunkyPNG::Color
images = [ChunkyPNG::Image.from_file('dog1.png'), # Put yr files here
ChunkyPNG::Image.from_file('dog2.png')]
output = ChunkyPNG::Image.new(images.first.width, images.last.height, rgb(255, 255, 255))
height = images.first.height > images.last.height ? images.last.height : images.first.height
width = images.first.width > images.last.width ? images.last.width : images.first.width
@dyerw
dyerw / assetcleaner.py
Last active February 28, 2024 05:09
AssetCleaner - Removes all unused assets from an XCode project
USAGE = \
"""
Searches an XCode project to determine which image
assets aren't being used then removes them.
WARNING: This will delete things permanently if your
project is not under source control.
"""
import os
@dyerw
dyerw / alias.sh
Last active August 29, 2015 14:18
Git - Aliases
git config --global alias.history "log --follow --stat"
@dyerw
dyerw / hearthpwnscrape.py
Created November 4, 2015 23:01
Scrapes hearthpwn.com for decklist data
import urllib2
from bs4 import BeautifulSoup
PAGES_TO_SCRAPE = 10
# Get HTML for all deck listing pages
htmls = []
for x in range(PAGES_TO_SCRAPE):
print "SCRAPING PAGE " + str(x + 1)