Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

{
"java": {
"jdk_version": "7",
"oracle": {"accept_oracle_download_terms": "true"},
"accept_license_agreement": "true",
"install_flavor": "oracle"
},
"elasticsearch": {
"nginx": {
"users": [{"username": "salesloft", "password": "<haha you wish>"}],
@sionide21
sionide21 / python.py
Created July 11, 2014 14:42
Complex default parameters: Ruby vs Python
def foo(a=[]):
a.append(1)
return a
foo() # => [1]
foo() # => [1, 1]
foo() # => [1, 1, 1]
@sionide21
sionide21 / alias.rb
Created August 12, 2014 19:40
The dangers of `alias` in ruby
class Parent
def foo
"Parent#foo"
end
alias :bar :foo
end
class Child < Parent
def foo
"Child#foo"
@sionide21
sionide21 / 0_enumerator.rb
Last active August 29, 2015 14:10
Lazy enumerators aren't magic
class Benerator
def initialize(&block)
@block = block
end
def next
as_array.shift
end
def as_array
@sionide21
sionide21 / outlook_proxy.rb
Created December 15, 2014 20:55
A proxy to the office365 IMAP server to figure out what a client tis up to.
require 'openssl'
require 'socket'
Thread.abort_on_exception = true
server = TCPServer.new(1993)
n = 0
loop do
client = server.accept
n += 1
@sionide21
sionide21 / railsconf_schedule.rb
Last active August 29, 2015 14:19
Make the Schedule Items at http://railsconf.com/schedule clickable to add to your Google Calendar
$("<script/>", {type: "text/javascript", src: "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"}).appendTo(document.body);
$(".session-content a").on("click", function() { event.stopPropagation(); });
$(".session-content").on("click", function() {
var session = $(this),
title = session.find(".session-title"),
details = title.find("a")[0].href,
speaker = session.find(".speaker-name"),
room = $("th").eq(session.parent().index()),
text = function(el) { return el.text().trim(); },
@sionide21
sionide21 / Rsync Backup
Created January 7, 2010 14:55
My home directory backup command
rsync -av --delete --exclude-from="$HOME/exclude.rsync" "$HOME" <server>:<backup dir>/
:w !sudo tee %
old()
{
command=$1
shift
$(which -a $command | head -n 2 | tail -n 1) $@
}
head -n 2 | tail -n 1