Skip to content

Instantly share code, notes, and snippets.

View bagwanpankaj's full-sized avatar

Pankaj Bagwan bagwanpankaj

View GitHub Profile
@bagwanpankaj
bagwanpankaj / unicorn.rb
Created July 4, 2011 02:24 — forked from defunkt/gist:206253
Uncorn config File
# unicorn_rails -c /data/github/current/config/unicorn.rb -E production -D
rails_env = ENV['RAILS_ENV'] || 'production'
# 16 workers and 1 master
worker_processes (rails_env == 'production' ? 16 : 4)
# Load rails+github.git into the master before forking workers
# for super-fast worker spawn times
preload_app true
@bagwanpankaj
bagwanpankaj / factories.rb
Created July 5, 2011 08:58 — forked from technicalpickles/factories.rb
Factory Girl definition for Paperclip
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end
@bagwanpankaj
bagwanpankaj / show.py
Created July 22, 2011 05:48 — forked from lfborjas/show.py
Tunnel a local port to a remote host (like showoff.io does)
#!/usr/bin/python
#usage python show.py <local_port>
'''
Taken from: https://gist.github.com/932137 (found in http://news.ycombinator.com/item?id=2467107 )
Let's say you have a webapp running in localhost (with `manage.py runserver` in django or `ruby script.rb` in sinatra or `rails server` or whatever) and you want others to be able to see it with a public url without deploying remotely.
ssh provides a neat facility for that: tunneling. You set up a "tunnel" from the remote host to yours and vice-versa and then you give the remote host's url and it will send all of its requests to your local daemon.
@bagwanpankaj
bagwanpankaj / show
Created July 22, 2011 05:49 — forked from superchink/show
This does something essentially equivalent to showoff.io if you have a publicly facing server...
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".webhostology.com"
REMOTE="$2$DOMAIN"
ssh -tR 8080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:8080 localhost"
}
@bagwanpankaj
bagwanpankaj / pgDebug.js
Created August 5, 2011 09:36 — forked from purplecabbage/pgDebug.js
Workout your iPhone PhoneGap UI in Desktop Safari
var safariDebug = ( navigator.platform.indexOf("iPhone") < 0 && navigator.platform.indexOf("iPod") < 0 && navigator.platform.indexOf("iPad") < 0 );
if(safariDebug)
{
PhoneGap.run_command = function()
{
if (!PhoneGap.available || !PhoneGap.queue.ready)
return;
#you can copy this into IRB or just run it as a file
require "net/http"
require "uri"
url = "http://localhost:3000/login"
yaml = %{ --- !ruby/object:Time {} }
xml = %{<?xml version="1.0" encoding="UTF-8"?><foo type="yaml">#{yaml}</foo>}.strip
uri = URI.parse(url)

Python 101

Introduction

Welcome to Python 101 at PyOhio 2013!

Python 2.x or Python 3.x?

@bagwanpankaj
bagwanpankaj / scripts.md
Last active August 29, 2015 14:14 — forked from myano/scripts.md
package main
import (
"log"
"net/mail"
"encoding/base64"
"net/smtp"
"fmt"
"strings"
@bagwanpankaj
bagwanpankaj / what-forces-layout.md
Created September 25, 2015 03:22 — forked from paulirish/what-forces-layout.md
What forces layout/reflow. The comprehensive list.

What forces layout / reflow

All of the below properties or methods, when requested/called in JavaScript, will trigger the browser to synchronously calculate the style and layout. This is also called reflow or layout thrashing, and is common performance bottleneck.

Element

Box metrics
  • elem.offsetLeft, elem.offsetTop, elem.offsetWidth, elem.offsetHeight, elem.offsetParent
  • elem.clientLeft, elem.clientTop, elem.clientWidth, elem.clientHeight
  • elem.getClientRects(), elem.getBoundingClientRect()