Skip to content

Instantly share code, notes, and snippets.

View s4parke's full-sized avatar

Steve J. s4parke

View GitHub Profile
@s4parke
s4parke / xml_parser.rb
Created February 6, 2013 13:59
Workaround for rails XML/YAML param parsing vulnerability. Drop this file in /config/initializers/xml_parser.rb
# config/initializers/xml_parser.rb
# There are multiple weaknesses in the parameter parsing code for Ruby on Rails which
# allows attackers to bypass authentication systems, inject arbitrary SQL, inject
# and execute arbitrary code, or perform a DoS attack on a Rails application.
#
#This vulnerability has been assigned the CVE identifier CVE-2013-0156.
# https://groups.google.com/forum/?fromgroups=#!topic/rubyonrails-security/61bkgvnSGTQ
#
@s4parke
s4parke / gist:5052277
Created February 27, 2013 22:10
Install sysbench and run some cpu and mysql benchmarks.
wget http://garr.dl.sourceforge.net/sourceforge/sysbench/sysbench-0.4.12.tar.gz
cd sysbench-0.4.12
libtoolize --force --copy
./autogen.sh
./configure
make
sudo make install
mysql -u root -e "create database sbtest;"
@s4parke
s4parke / iptables-webserver-sample
Last active December 14, 2015 20:19
Example iptables config for a web server with ssh running on port 2222
#!/bin/bash
# iptables configuration script
# Flush all current rules from iptables
iptables -F
# Allow SSH connections on tcp port 2222
iptables -A INPUT -p tcp --dport 2222 -j ACCEPT
@s4parke
s4parke / git-large-files.pl
Created February 18, 2015 16:30
Perl script for finding large files in git repo history
#!/usr/bin/perl
use 5.008;
use strict;
use Memoize;
# usage:
# git-large-files 500k
# git-large-files 0.5m
# git-large-files 5b
@s4parke
s4parke / git-­truncate.sh
Created February 18, 2015 16:33
Simple bash script for truncating git repo history
#!/bin/bash
# Usage:
# ./git-truncate.sh SHA1
# Removes all the history prior to commit "SHA1"
git checkout --orphan temp $1
git commit -m "Truncated history of git repo"
git rebase --onto temp $1 master
git branch -D temp
#! /usr/bin/ruby
# Git before-update hook
def check_uncommitted_changes
diff_paths = `git diff-index --name-only HEAD`.split("\n")
diff_stats = `git diff-index --stat HEAD`.split("\n").join("\n ")
error_msg = %(
[GIT POLICY: DIRTY WORKING COPY]
@s4parke
s4parke / gist:75f03169f2ff429dd539
Last active November 19, 2015 17:37 — forked from jazbek/gist:6355989
Add custom fields to a single event detail page
<?php
//
add_action('tribe_events_before_view','tribe_custom_fields_meta');
function tribe_custom_fields_meta(){
global $post;
// force this to run only on single event views
if( is_single() && tribe_is_event( $post->ID ) ){
if( tribe_is_recurring_event( tribe_is_recurring_event( $post->ID ) ) ) {
tribe_register_meta( 'tribe_custom_fields_vaa', array(
@s4parke
s4parke / custom_venue_info.php
Created December 1, 2015 16:35 — forked from codearachnid/custom_venue_info.php
Add custom venue meta items by using the tribe_register_meta for individual items or tribe_register_meta_group for the group registration. See TEC (core plugin)/public/advanced-functions/meta.php for examples of group and individual registration
<?php
// add custom venue meta items
add_action('tribe_events_before_view','custom_venue_info');
function custom_venue_info(){
global $post;
// force this to run only on single event views
if( is_single() && tribe_is_event( $post->ID ) ){
$room = get_post_meta( $post->ID, '_VenueRoom', true );
tribe_register_meta( 'tribe_venue_room', array(
@s4parke
s4parke / redis-autostart-osx.md
Created February 1, 2016 22:39 — forked from subfuzion/redis-autostart-osx.md
redis auto start OS X

Install with Homebrew

brew install redis

Set up launchctl to auto start redis

$ ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents

/usr/local/opt/redis/ is a symlink to /usr/local/Cellar/redis/x.y.z (e.g., 2.8.7)

@s4parke
s4parke / nginx.conf for node express with nginx reverse proxy
Last active February 12, 2016 04:56 — forked from turtlesoupy/nginx.conf
node.js upstream nginx config
upstream calc_example_org_upstream {
server 127.0.0.1:8005;
#server 127.0.0.1:8006;
#keepalive 64;
}
server {
listen 80;
server_name www.calc.example.org;