Skip to content

Instantly share code, notes, and snippets.

View sagar-ranglani's full-sized avatar

Sagar Ranglani sagar-ranglani

View GitHub Profile
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 https://www.npmjs.org/install.sh | sh
<% if @port != 80 -%>
Listen <%= @port %>
<% end -%>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot <%= @document_root %>
<Directory />
Options FollowSymLinks
<html>
<body>
<h1>Welcome to <%= node["motd"]["company"] %></h1>
<h2>We love <%= @site_name %></h2>
<%= node["ipaddress"] %>:<%= @port %>
</body>
</html>
@sagar-ranglani
sagar-ranglani / gist:7688431
Created November 28, 2013 07:31
remove all gems all versions
for i in `gem list --no-versions`; do gem uninstall -aIx $i; done
require 'nokogiri'
require 'open-uri'
namespace :bookmarks do
desc '-- Import bookmarks in Netscape Bookmark format'
task :import => :environment do
doc = Nokogiri::HTML(open(File.join(Rails.root, "lib/dump/bookmarks_5_8_12.html")))
# Ensure we're dealing with the correct format
require 'uri'
#Ruby Method for URI validation
def valid?(url)
uri = URI.parse(url)
rescue URI::InvalidURIError
false
end
#Ruby Method for URI validation with HTTP and HTTPS
@sagar-ranglani
sagar-ranglani / test.thor
Created June 20, 2013 03:17
Example usage of Thor (A command line building gem) In a Thor class, public methods become commands.
# Sample for Thor
# https://github.com/erikhuda/thor/wiki/Getting-Started
# Important command
# - thor list => This lists down all the .thor files with the tasks
# - thor help test:example
# Usage: "thor test:example".
# Usage: "thor test:example_with_arg FILE".
#!/usr/bin/env ruby
# This is a basic deploy script for Heroku apps.
# It provides a structure you can use to expand on
# and add your own prereqs and deploy tasks.
#
# It basically ensures that:
# 1. There are no uncommited files
# 2. You can ssh to github
# 3. You can connect to heroku