Skip to content

Instantly share code, notes, and snippets.

View paydro's full-sized avatar
💨

Peter Bui paydro

💨
View GitHub Profile
@paydro
paydro / proxy.go
Created August 20, 2014 17:37 — forked from vmihailenco/proxy.go
package main
import (
"bytes"
"encoding/hex"
"flag"
"fmt"
"io"
"log"
"net"
#######################################################
# Add this to app/controllers/application_controller.rb
#######################################################
def render_json_response(type, hash)
unless [ :ok, :redirect, :error ].include?(type)
raise "Invalid json response type: #{type}"
end
# To keep the structure consistent, we'll build the json
# structure with the default properties.
require 'minitest/unit'
require 'minitest/spec'
require 'rubygems'
require 'ansi'
class MiniTest::Unit
include ANSI::Code
PADDING_SIZE = 4
@paydro
paydro / apache_rewrite.conf
Created November 27, 2010 14:39
redirect all requests to a particular file - useful for php
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule .* index.php [L]
@paydro
paydro / controller.rb
Created January 14, 2011 21:52
Sample js_message javascript call
# corresponding rails action that handles the js_message call. Note the format.jsm calls in the
# respond_to block
def create
@task = Task.new(params[:task])
respond_to do |format|
if @task.save
format.html { redirect_to(tasks_path, :notice => 'Task was successfully created.') }
format.jsm do
render_js_message(:ok, :html => "it saved!")
@paydro
paydro / gist:1140999
Created August 11, 2011 22:48
Allows #context calls in Rails 3 tests like rspec/minitest spec
# Create a context block like rspec.
#
# Inspired by:
# - MiniTest::Spec
# - Chris Wanstrath's https://gist.github.com/25455
#
# Examples:
#
# class UserTest < ActiveSupport::TestCase
# context "Auth" do
@paydro
paydro / fancybuttons.css
Created August 20, 2011 22:38
Fancy buttons via css
/* Fancy buttons */
.buttons a,
.buttons input,
input.button,
.button {
font-family: "Helvetica Neue", Verdana,Helvetica, sans-serif;
font-size: 12px;
padding: 5px 10px;
@paydro
paydro / commandline.sh
Created January 17, 2012 18:37
What is running on X port
lsof -i TCP:80
@paydro
paydro / bootstrap.sh
Created April 27, 2012 20:50
MapReduce Files
#!/usr/bin/env bash
#
# This script is run as the 'hadoop' user - which means any commands
# that create/update privileged areas must use sudo.
# Print out every command executed in this script.
set -x
# Exit this script if any of the commands below fail.
set -e
@paydro
paydro / image_ready.sh
Created May 29, 2012 20:05
Script to wait on something to happen
while :
do
building=`bulldozer images:list | grep postprocessor-2012-05-29 | grep available | wc -l`
if [ $building -eq 1 ]
then
say "post processor image finished building"
break
fi
sleep 5
done