Skip to content

Instantly share code, notes, and snippets.

View ejamesc's full-sized avatar

Cedric Chin ejamesc

View GitHub Profile
@ejamesc
ejamesc / gist:0c11b6b44541e5d28fba
Last active August 29, 2015 14:02
Solution for Golang Tour No 58
package main
import (
"fmt"
"math"
)
// type declaration
type ErrNegativeSqrt float64
@ejamesc
ejamesc / gist:95158b6401f718706d0f
Last active August 29, 2015 14:02
Exercise: HTTP Handlers - Gotour
package main
import (
"fmt"
"net/http"
)
type String string
type Struct struct {
Greeting string
Ext.define('App.someclass.SomeClass', {
someFunction: function(data) {
this.offers = someArrayOfOffers();
var blahCallback = (function (offers, context) {
return function(points){
for (var i = 0; i < points.length; i++) {
Ext.bind(context.onMarkerTap, context, offers[i], points[i])
}
}
@ejamesc
ejamesc / gist:1c333aa2250b61c84228
Created February 8, 2015 08:23
Keybase verification
### Keybase proof
I hereby claim:
* I am ejamesc on github.
* I am ejames_c (https://keybase.io/ejames_c) on keybase.
* I have a public key whose fingerprint is BCED BFC9 A789 5722 5AB9 3ACC E2D5 B0BA 695C 481D
To claim this, I am signing this object:
package main
import (
"fmt"
"github.com/codegangsta/negroni"
"github.com/gorilla/mux"
"log"
"net/http"
)
@ejamesc
ejamesc / tumblr_corpus.py
Created February 8, 2015 17:24
Download Tumblr API Results
import xlwt
import requests
API_KEY = "DFIqb6odlalG3lzJbmcSlaaCwM9EkFyaAPzgSeKD9oQTQtWMVm"
URL = "http://api.tumblr.com/v2/tagged"
def main(search_tag, filename, pages):
book = xlwt.Workbook()
sh = book.add_sheet(search_tag)
def replace(s, casey)
a = s
case casey
when 1
a.sub("AB", "AA")
when 2
a.sub("BA", "AA")
when 3
a.sub("CB", "CC")
when 4
type Blog struct {
Logger *log.Logger
}
func NewBlog() (*Blog, error) {
var b *Blog
logger := log.New(os.Stdout, "[goblawg] ", 0)
b.Logger = logger
// this explodes with a panic: runtime error: invalid memory address or nil pointer dereference
@ejamesc
ejamesc / currency.py
Last active August 29, 2015 14:21
Currency symbol extractor script
import csv
# data taken from http://www.currency-iso.org/en/home/tables/table-a1.html
# and consolidated.csv from http://datahub.io/dataset/iso-4217-currency-codes/resource/69ec48a5-4195-4439-92cf-d15096b9b20a
current_currencies = set()
with open('active_currencies.txt', 'rb') as file:
for row in file:
r = row.rstrip()
current_currencies.add(r)
@ejamesc
ejamesc / currency.txt
Created May 27, 2015 10:23
List of currency names | Symbols
Afghani|AFN
Algerian Dinar|DZD
Argentine Peso|ARS
Armenian Dram|AMD
Aruban Florin|AWG
Australian Dollar|AUD
Azerbaijanian Manat|AZN
Bahamian Dollar|BSD
Bahraini Dinar|BHD
Baht|THB