Skip to content

Instantly share code, notes, and snippets.

View dan-palmer's full-sized avatar
👨‍💻

Dan Palmer dan-palmer

👨‍💻
View GitHub Profile
@mislav
mislav / gist:938183
Created April 23, 2011 02:28
Faraday SSL example
connection = Faraday::Connection.new('http://example.com') do |builder|
builder.request :url_encoded # for POST/PUT params
builder.adapter :net_http
end
# same as above, short form:
connection = Faraday.new 'http://example.com'
# GET
connection.get '/posts'
@cereda
cereda / mydoc.tex
Created June 25, 2011 11:29
Base64 LaTeX example
\documentclass{article}
\usepackage{filecontents}
\usepackage{graphicx}
\newcommand{\generateimage}[2]{%
\immediate\write18{convert.cmd #1 > #2}}
\begin{document}
\begin{filecontents*}{myfigure.txt}
@ehynds
ehynds / inbox_view.js
Created October 6, 2011 20:52
backbone lazy loading nested collections w/ caching...
// inbox view
app.views.Inbox = Backbone.View.extend({
events: {
"click .view-message": "view"
},
view: function(event) {
var id = $(event.target).data("message-id");
var model = this.collection.get(id);
message.render(model);
@julien
julien / backbone.mock.js
Created January 12, 2012 14:17
BackboneMock
(function() {
var root = this;
var BackboneMock = (function() {
if(typeof Backbone === 'undefined') {
throw '"Backbone" is undefined, make sure you have loaded ' +
'backbone.js before using this mock utility';
}
// Override Backbone.sync
// because we want to mock the requests
# Ruby Thread Pool
# ================
# A thread pool is useful when you wish to do some work in a thread, but do
# not know how much work you will be doing in advance. Spawning one thread
# for each task is potentially expensive, as threads are not free.
#
# In this case, it might be more beneficial to start a predefined set of
# threads and then hand off work to them as it becomes available. This is
# the pure essence of what a thread pool is: an array of threads, all just
# waiting to do some work for you!
http://stackoverflow.com/questions/68569/text-watermark-on-website-how-to-do-it
<style type="text/css">
#watermark {
color: #d0d0d0;
font-size: 200pt;
-webkit-transform: rotate(-45deg);
-moz-transform: rotate(-45deg);
position: absolute;
width: 100%;
@adamawolf
adamawolf / Apple_mobile_device_types.txt
Last active June 28, 2024 08:58
List of Apple's mobile device codes types a.k.a. machine ids (e.g. `iPhone1,1`, `Watch1,1`, etc.) and their matching product names
i386 : iPhone Simulator
x86_64 : iPhone Simulator
arm64 : iPhone Simulator
iPhone1,1 : iPhone
iPhone1,2 : iPhone 3G
iPhone2,1 : iPhone 3GS
iPhone3,1 : iPhone 4
iPhone3,2 : iPhone 4 GSM Rev A
iPhone3,3 : iPhone 4 CDMA
iPhone4,1 : iPhone 4S
@tj
tj / some.sh
Created October 11, 2012 18:45
change terminal tab name on cd
function tabname {
printf "\e]1;$1\a"
}
if [ x`type -t cd` == "xfunction" ]; then
# previously wrapped cd
eval $(type cd | grep -v 'cd is a function' | sed 's/^cd/original_cd/' | sed 's/^}/;}/' )
else
# builtin
eval "original_cd() { builtin cd \$*; }"
@mburst
mburst / astar.rb
Created February 24, 2013 16:35
Ruby A* implementation
require 'priority_queue'
require 'set'
class Node
def initialize(x, y)
@x = x
@y = y
@obstacle = false
@g_score = Float::INFINITY
end
@hubgit
hubgit / app.js
Last active December 16, 2015 21:39
Postcode -> Location lookup using Ordnance Survey Linked Data APIs
$(function() {
var form = $("form");
var button = form.find("button[type=submit]");
var input = form.find("input[name=postcode]");
var output = form.find("output[name=location]");
var map = L.mapbox.map("map", "hubbox.map-u557d78b").setView([54, 0], 6);
var failed = function(data) {
button.html("Failed");