Skip to content

Instantly share code, notes, and snippets.

View xunker's full-sized avatar

Matthew Nielsen xunker

View GitHub Profile
function getElementXPath(elt)
{
var path = "";
for (; elt && elt.nodeType == 1; elt = elt.parentNode)
{
idx = getElementIdx(elt);
xname = elt.tagName;
if (idx > 1) xname += "[" + idx + "]";
path = "/" + xname + path;
}
@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'
@joelambert
joelambert / README
Created June 1, 2011 11:03
Drop in replacements for setTimeout()/setInterval() that makes use of requestAnimationFrame() where possible for better performance
Drop in replace functions for setTimeout() & setInterval() that
make use of requestAnimationFrame() for performance where available
http://www.joelambert.co.uk
Copyright 2011, Joe Lambert.
Free to use under the MIT license.
http://www.opensource.org/licenses/mit-license.php
@jamiew
jamiew / google_twunter_lol
Created July 28, 2011 20:34
All the dirty words from Google's "what do you love" project: http://www.wdyl.com/
easterEgg.BadWorder.list={
"4r5e":1,
"5h1t":1,
"5hit":1,
a55:1,
anal:1,
anus:1,
ar5e:1,
arrse:1,
arse:1,
@ngauthier
ngauthier / readme.md
Created December 24, 2011 04:30
Convert 3DS video for YouTube 3D

Assuming the file is named "source.avi":

ffmpeg -i source.avi  -map 0:2 -map 0:1 -vcodec rawvideo -s 480x480 right.avi
ffmpeg -i source.avi  -map 0:0 -map 0:1 -vcodec rawvideo -s 480x480 -vf pad=960:480:0:0:violet -y left.avi
ffmpeg -i left.avi -vf "movie=right.avi [ovl]; [in][ovl] overlay=480:0 [out]" -an -y -b 4096k done.avi

Then upload "done.avi" to youtube. View the video, click "Edit Info" => "3D Video" => "This video is already in 3D" => "Save Changes"

@timoxley
timoxley / view-helper.coffee
Created August 1, 2012 17:02
backbone handlebars helper, allows child views to be initialised from templates ala Ember
Handlebars.registerHelper 'view', (viewPath, options) ->
# use Backbone.View if not supplied a backbone view subclass
unless viewPath
viewPath = 'Backbone.View'
return 'No View'
View = viewPath.split('.').reduce (previous, current) ->
return previous[current]
, window
@anderslemke
anderslemke / OpenRSpecFile.py
Created August 31, 2012 14:38
Additions to RSpec Sublime plugin
import sublime
import sublime_plugin
import re, inspect, os
import shared
class OpenRspecFileCommand(sublime_plugin.WindowCommand):
def run(self):
if not self.window.active_view():
return
@bmatherly
bmatherly / APC PDU Monitor Instructions
Last active June 18, 2024 21:16
Script to control an APC MasterSwitch PDU to reset an outlet when the network stops working
sudo cp netmonitor.sh /usr/bin/netmonitor.sh
sudo chmod 755 /usr/bin/netmonitor.sh
sudo crontab -e
Add to crontab:
*/2 * * * * /usr/bin/netmonitor.sh 2>&1 | /usr/bin/logger -t netmonitor
@joekiller
joekiller / gtk-firefox.sh
Last active October 21, 2021 04:15 — forked from phstc/gtk-firefox.sh
INSTALL FIREFOX ON AMAZON LINUX X86_64 COMPILING GTK+
#!/bin/bash
# GTK+ and Firefox for Amazon Linux
# Written by Joseph Lawson 2012-06-03
# http://joekiller.com
# http://joekiller.com/2012/06/03/install-firefox-on-amazon-linux-x86_64-compiling-gtk/
# chmod 755 ./gtk-firefox.sh
# sudo ./gtk-firefox.sh
@myronmarston
myronmarston / explanation.md
Last active October 22, 2020 18:16
Explanation for why `its` will be removed from rspec-3

its isn't core to RSpec. One the of the focuses of RSpec is on the documentation aspects of tests. Unfortunately, its often leads to documentation output that is essentially lies. Consider this spec:

User = Struct.new(:name, :email)

describe User do
  subject { User.new("bob") }
  its(:name) { should == "bob" }
end