Skip to content

Instantly share code, notes, and snippets.

View millisami's full-sized avatar
🎯
Focusing on landing a Web3 Job

Sachin Sagar Rai millisami

🎯
Focusing on landing a Web3 Job
View GitHub Profile
@millisami
millisami / dir.rb
Created July 20, 2011 07:27
Directory is empty or not?
class Dir
def empty?
Dir.glob("#{ path }/*", File::FNM_DOTMATCH) do |e|
return false unless %w( . .. ).include?(File::basename(e))
end
return true
end
def self.empty? path
new(path).empty?
end
@millisami
millisami / gist:1156518
Created August 19, 2011 10:15
chef rvm install backtrace
[default] [Fri, 19 Aug 2011 08:53:20 +0000] INFO: Processing execute[rvm-cleanup] action nothing (rvm::default line 19)
: stdout
[default] [Fri, 19 Aug 2011 08:53:20 +0000] INFO: Processing bash[installing system-wide RVM stable] action run (rvm::default line 25)
: stdout
[default] [Fri, 19 Aug 2011 08:53:20 +0000] INFO: Processing bash[upgrading to RVM head] action run (rvm::default line 31)
: stdout
[default] [Fri, 19 Aug 2011 08:53:20 +0000] INFO: Processing bash[upgrading RVM stable] action run (rvm::default line 38)
: stdout
[default] [Fri, 19 Aug 2011 08:53:20 +0000] INFO: Processing cookbook_file[/usr/local/bin/rvm-gem.sh] action create (rvm::default line 50)
: stdout
@millisami
millisami / cygwin_setup.txt
Created August 22, 2011 05:24 — forked from zoras/cygwin_setup.txt
install all the packages in cygwin
# Install all the packages required for using ruby on rails in cygwin
# Cygwin is a Linux-like environment for MS Windows.
# Download the Cygwin setup.exe from http://www.cygwin.com/setup.exe
# Few packages name and description
# inetutils # telnet(1)
# ncurses # see Terminator FAQ
# openssh # SSH (client and server, though the server's not so great)
@millisami
millisami / gist:1167353
Created August 24, 2011 05:17
Ruby stacktrace
/Users/millisami/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 52 column 11 (Psych::SyntaxError)
from /Users/millisami/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
from /Users/millisami/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:119:in `parse'
from /Users/millisami/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/psych.rb:106:in `load'
from /Users/millisami/rubygems/cloud_factory_ruby/lib/cf/cli/line_yaml_validator.rb:6:in `validate'
from /Users/millisami/rubygems/cloud_factory_ruby/lib/cf/cli/line.rb:128:in `create'
from /Users/millisami/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/task.rb:22:in `run'
from /Users/millisami/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/invocation.rb:118:in `invoke_task'
from /Users/millisami/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor.rb:263:in `dispatch'
from /Users/millisami/.rvm/gems/ruby-1.9.2-p180@global/gems/thor-0.14.6/lib/thor/invocation
require 'rubygems'
require 'httparty'
require 'active_support'
# require 'httplog'
module Linode
class Nodebalancer
include HTTParty
base_uri 'https://api.linode.com'
@millisami
millisami / god_resque.rb
Created September 5, 2011 14:26 — forked from gravis/god_resque.rb
God monitoring files for resque
# Copyright (c) 2010 Tech-Angels
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following
# conditions:
@millisami
millisami / all.god
Created September 5, 2011 18:18 — forked from nragaz/all.god
God configs for starting Resque and Unicorn
PID_DIR = '/srv/myapp/shared/pids'
RAILS_ENV = ENV['RAILS_ENV'] = 'production'
RAILS_ROOT = ENV['RAILS_ROOT'] = '/srv/myapp/current'
BIN_PATH = "/home/rails/.rvm/gems/ree-1.8.7-2010.02/bin"
God.log_file = "#{RAILS_ROOT}/log/god.log"
God.log_level = :info
%w(unicorn resque).each do |config|
God.load "#{RAILS_ROOT}/config/god/#{config}.god"
@millisami
millisami / email_validator.rb
Created September 20, 2011 10:14 — forked from jcf/email_validator.rb
Rails 3 Email Validator
require 'mail'
class EmailValidator < ActiveModel::EachValidator
attr_reader :record, :attribute, :value, :email, :tree
def validate_each(record, attribute, value)
@record, @attribute, @value = record, attribute, value
@email = Mail::Address.new(value)
@tree = email.__send__(:tree)
$ sudo cat /etc/sudoers
[sudo] password for deploy:
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
@millisami
millisami / webkit2png.py
Created October 31, 2011 17:08
Webkit2Png
#!/usr/bin/env python
# webkit2png - makes screenshots of webpages
# http://www.paulhammond.org/webkit2png
__version__ = "0.5"
# Copyright (c) 2009 Paul Hammond
#
# Permission is hereby granted, free of charge, to any person obtaining a copy