Skip to content

Instantly share code, notes, and snippets.

@philfreo
philfreo / gist:7257723
Created October 31, 2013 21:44
Facebook Perl source code from 2005. When browsing around thefacebook.com in 2005 the server spit out some server-side source code rather than running it. I believe this was for their old graph feature that let you visualize the graph between all your friends. The filename is `mygraph.svgz` and contains some gems such as a commented out "zuck" d…
#!/usr/bin/perl
use Mysql;
use strict;
use vars qw($school_name);
use vars qw($pass);
require "./cgi-lib.pl";
@jbenet
jbenet / simple-git-branching-model.md
Last active April 9, 2024 03:31
a simple git branching model

a simple git branching model (written in 2013)

This is a very simple git workflow. It (and variants) is in use by many people. I settled on it after using it very effectively at Athena. GitHub does something similar; Zach Holman mentioned it in this talk.

Update: Woah, thanks for all the attention. Didn't expect this simple rant to get popular.

@mattvh
mattvh / favicon.rb
Last active September 4, 2020 12:13
Discovering and saving favicons with Ruby
# by Matt Harzewski
# Read more: http://www.webmaster-source.com/2013/09/25/finding-a-websites-favicon-with-ruby/
require "httparty"
require "nokogiri"
require "base64"
class Favicon
@zealot128
zealot128 / crawler.rb
Last active August 15, 2018 12:22
Web Crawler Helper class based upon Poltergeist (PhantomJS).Using Capybara as framework for building webcrawlers is surprisingly convenient
class ExampleCrawler < PoltergeistCrawler
def crawl
visit "https://news.ycombinator.com/"
click_on "More"
page.evaluate_script("window.location = '/'")
end
end
ExampleCrawler.new.crawl
FROM centos
RUN curl -L http://www.opscode.com/chef/install.sh | bash
ADD ./chef-repo /root/chef-repo
RUN cd /root/chef-repo; chef-solo -c solo.rb -j ./nodes/localhost.json
@krisleech
krisleech / 00_value_object.rb
Last active December 16, 2015 17:19
Array of value objects for ActiveRecord with/out serialize
class Leg
include ActiveModel::Validations
include ActiveModel::Naming
include ActiveModel::Conversion
include Virtus
attribute :start_day, Integer
attribute :end_day, Integer
end
@DavidAllison
DavidAllison / s3-file.rb
Created April 1, 2013 22:19
An update to @peplin's work on https://gist.github.com/peplin/470321 that makes this gist compatible with the more modern AWS-SDK gem and new APIs, and updates for Chef 11.x (still works with 10.x too).
#
# Author:: Christopher Peplin (<peplin@bueda.com>)
# Copyright:: Copyright (c) 2010 Bueda, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@UtahDave
UtahDave / iptables
Created March 21, 2013 22:38
An example of using the Salt peer interface to query web server IP addresses and add them to an iptables config.
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
@piavlo
piavlo / adduser
Last active January 9, 2017 17:37
logstash init script for centos 5/6 requires daemonize binary and unpacked monolitic jar under /opt/logstash
adduser --home-dir /var/lib/logstash --no-create-home --shell /sbin/nologin logstash
mkdir -p /var/lib/logstash /var/log/logstash
chown -R logstash:logstash /var/lib/logstash /var/log/logstash
@Unpakt
Unpakt / rails 3.2.11 params patch
Created January 9, 2013 18:54
Put "repair_empty_param_associations" in your before filters in the application_controller.rb
def repair_empty_param_associations
params.keys.each do |key|
repair_nested_params(params, key, params[key])
end
end
private
def repair_nested_params(current_params, key, value)
if key =~ /^(.*)_attributes$/ && value.nil?