Skip to content

Instantly share code, notes, and snippets.

@jaydonnell
jaydonnell / golimit.go
Last active December 26, 2021 06:38
Limit http requests to 5 per second in golang
package main
import (
"context"
"fmt"
"log"
"net/http"
"sync"
"time"
package main
import (
"context"
"fmt"
"strings"
"github.com/andersfylling/disgord"
)
@jaydonnell
jaydonnell / jsonld.json
Created May 24, 2016 04:23
jsonld example
{
"@id" : "https://en.wikipedia.org/wiki/Frozen_(2013_film)",
"@type" : [ "http://schema.org/Movie" ],
"http://schema.org/releasedEvent" : [ {
"@value" : "2013-11-27"
}],
"http://schema.org/copyrightYear" : [ {
"@type" : "http://www.w3.org/2001/XMLSchema#integer",
"@value" : "2013"
}],
(defn mergeListPairs [xs]
(loop [xss xs]
(cond
(= (count xss) 1) (first xss)
:else (let [[xs1 xs2 & xssRest] xss]
(recur (conj xssRest (myMerge xs1 xs2)))))))
@jaydonnell
jaydonnell / test.go
Last active December 17, 2015 01:19
package main
import "fmt"
type Person struct {
Name string
}
func (p *Person) Intro() string {
return p.Name
@jaydonnell
jaydonnell / .emacs.el
Last active December 12, 2015 09:19
.emacs
(if window-system
(tool-bar-mode -1))
(load-theme 'deeper-blue t)
(set-face-attribute 'default nil :height 140)
(require 'package)
(package-initialize)
(add-to-list 'package-archives
'("marmalade" . "http://marmalade-repo.org/packages/"))
@jaydonnell
jaydonnell / gist:4735159
Last active December 12, 2015 07:18
ruby code
# let's count words
a = ['the quick brown fox jumped over the log', 'the slow brown fox ran fast', 'the blue fast cat jumped']
a.reduce({}) { |m, o|
o.split(' ').each{ |w|
m.key?(w) ? m[w] = m[w]+ 1 : m[w] = 1
}
m
}.sort { |a,b| b[1] <=> a[1] }
@jaydonnell
jaydonnell / gist:1690128
Created January 27, 2012 18:18
namespacing in coffeescript
root = exports ? this
root.PerformanceStats = {}
root.PerformanceStats.piePlot = (el, data) ->
tmp_data = [
{ label: "Series1", data: 10},
{ label: "Series2", data: 30},
{ label: "Series3", data: 90},
{ label: "Series4", data: 70},
{ label: "Series5", data: 80},
{ label: "Series6", data: 110}
function character_schema() {
$schema['character'] = array (
'description' => 'The main store for our entity',
'fields' => array(
'pid' => array(
'description' => 'Primary key for our table of characters',
'type' => 'serial',
'unsigned' => TRUE,
'not null' => TRUE,
),
@jaydonnell
jaydonnell / data.txt
Created October 21, 2011 18:29
jruby mahout collaborative filter
∴ head post_preferences.csv
4,1
7,2
4,4
1,4
4,3
8,1
8,3
4,5
4,6