Skip to content

Instantly share code, notes, and snippets.

View shreyas-satish's full-sized avatar

Shreyas Satish shreyas-satish

View GitHub Profile
@tekacs
tekacs / show
Created April 20, 2011 17:55
This does something essentially equivalent to showoff.io if you have a publicly facing server...
# Usage: show <local-port> <subdomain>
function show() {
DOMAIN=".tekacs.com"
REMOTE="$2$DOMAIN"
ssh -tR 1080:127.0.0.1:$1 vps "sudo ssh -Nl \$USER -L $REMOTE:80:127.0.0.1:1080 localhost"
}
@shreyas-satish
shreyas-satish / gist:1363413
Created November 14, 2011 06:59
Rails 3 routing : Map namespace to subdomain
constraints :subdomain => "admin" do
scope :module => "admin", :as => "admin" do
resources :players
end
end
@shreyas-satish
shreyas-satish / gist:1397857
Created November 27, 2011 17:32
setting up my ubuntu linux
sudo apt-get install build-essential openssl libssl-dev curl libcurl3 libcurl3-dev git-core
@shreyas-satish
shreyas-satish / gist:1424124
Last active January 19, 2016 13:48
Installing Postgresql on linux with apt
sudo apt-get install python-software-properties
Next, let’s add the repository containing PostgreSQL 9.0:
sudo add-apt-repository ppa:pitti/postgresql
sudo apt-get update
Now, we need to install the database, the contrib tools, and several supporting libraries:
sudo apt-get install postgresql-9.0 postgresql-contrib-9.0
sudo apt-get install postgresql-server-dev-9.0 libpq-dev libpq5
module Extractor extend self
def extract_email(str)
email = Mail::Address.new(str)
email.domain && email.address
end
def parse(str)
str.split(",").map do |seg|
extract_email(seg)
end.compact
@shreyas-satish
shreyas-satish / edu.txt
Created February 15, 2012 10:29
Education resources for web development
Git Guide - http://rogerdudler.github.com/git-guide/ , http://gitref.org/
html, css, JavaScript - codecademy, The good parts, Mozilla Developer Network (MDN)
Ruby - rubymonk, tryruby
Rails - Michael Hartl - ruby.railstutorial.org, railscasts
Docs - dochub.io

Proposal for Improving Mass Assignment

For a while, I have felt that the following is the correct way to improve the mass assignment problem without increasing the burden on new users. Now that the problem with the Rails default has been brought up again, it's a good time to revisit it.

Sign Allowed Fields

When creating a form with form_for, include a signed token including all of the fields that were created at form creation time. Only these fields are allowed.

To allow new known fields to be added via JS, we could add:

@shreyas-satish
shreyas-satish / application.html.erb
Created March 7, 2012 13:16
Better Organization of Assets in the Rails Asset Pipeline
<!DOCTYPE html>
<html>
<head>
<title>Citizenmatters</title>
<%= stylesheet_link_tag :application, params[:controller] %>
<%= javascript_include_tag :application, params[:controller] %>
<%= csrf_meta_tags %>
<%= yield :head %>
</head>
<body data-controller = "<%= controller_name %>" data-action = "<%= action_name %>">
@davatron5000
davatron5000 / gist:2254924
Created March 30, 2012 20:57
Static Site Generators

Backstory: I decided to crowdsource static site generator recommendations, so the following are actual real world suggested-to-me results. I then took those and sorted them by language/server and, just for a decent relative metric, their Github Watcher count. If you want a heap of other projects (including other languages like Haskell and Python) Nanoc has the mother of all site generator lists. If you recommend another one, by all means add a comment.

Ruby

@shreyas-satish
shreyas-satish / node-and-npm-in-30-seconds.sh
Created June 8, 2012 17:53 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh