Skip to content

Instantly share code, notes, and snippets.

View zoras's full-sized avatar
🏠
Working remotely 🌏 Available for Hire

Saroj Maharjan zoras

🏠
Working remotely 🌏 Available for Hire
View GitHub Profile

ssh <computer_name or ip> echo $PATH /usr/bin:/bin:/usr/sbin:/sbin

This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

Edit the /etc/sshd_config file by activating the PermitUserEnvironment yes option and then creating a ~/.ssh/environment file with the following:-

PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin

➜ (ruby-1.8.7-head) Employee rails s
/Users/zoras/.rvm/rubies/ruby-1.8.7-head/lib/ruby/1.8/logger.rb:174: private method `chomp' called for nil:NilClass (NoMethodError)
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.0/lib/active_support/core_ext/logger.rb:19:in `require'
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/activesupport-3.0.0/lib/active_support/core_ext/logger.rb:19
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/railties-3.0.0/lib/rails.rb:7:in `require'
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/railties-3.0.0/lib/rails.rb:7
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/railties-3.0.0/lib/rails/all.rb:1:in `require'
from /Users/zoras/.rvm/gems/ruby-1.8.7-head/gems/railties-3.0.0/lib/rails/all.rb:1
from /Users/zoras/Dev/Training/Employee/config/application.rb:3:in `require'
from /Users/zoras/Dev/Training/Employee/config/application.rb:3
@zoras
zoras / cygwin_setup.txt
Created July 28, 2011 17:22
install all the packages in cygwin
# install all the packages required for using ruby on rails in cygwin
# http://software.jessies.org/salma-hayek/cygwin-setup.html
# Cygwin is a Linux-like environment for MS Windows. You can read more about it on the Cygwin home page, but this page assumes you know what it is and have already decided that you want it. If you're a Unix user and you're stuck with a Win32 box, you probably do. It's quite a remarkable hack.
Download the Cygwin setup.exe from http://www.cygwin.com/setup.exe
# Packages
inetutils # telnet(1)
ncurses # see Terminator FAQ
openssh # SSH (client and server, though the server's not so great)
@zoras
zoras / rmagick.sh
Created August 2, 2011 17:14
Install RMagick on Ubuntu 11.04
sudo apt-get install libdjvulibre-dev libjpeg-dev libtiff-dev libwmf-dev libmagickcore-dev libmagickwand-dev libmagick++-dev rvm
sudo gem install rmagick
ok!
Fetching: rmagick-2.13.1.gem (100%) Building native extensions. This could take a while ... Successfully installed rmagick-2.13.1 1 gem installed
require 'RMagick' #=> true
@zoras
zoras / connection_fix.rb
Created September 7, 2011 08:02 — forked from defunkt/connection_fix.rb
MySQL server has gone away fix
# If your workers are inactive for a long period of time, they'll lose
# their MySQL connection.
#
# This hack ensures we re-connect whenever a connection is
# lost. Because, really. why not?
#
# Stick this in RAILS_ROOT/config/initializers/connection_fix.rb (or somewhere similar)
#
# From:
# http://coderrr.wordpress.com/2009/01/08/activerecord-threading-issues-and-resolutions/
@zoras
zoras / spec_helper.rb
Created September 13, 2011 11:12 — forked from ryanb/spec_helper.rb
Focus on specific specs in RSpec
# add this to your spec helper
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
# and then use the :focus tag in your specs
it "does something awesome", :focus do
@zoras
zoras / code.rb
Created September 17, 2011 15:58 — forked from caius/code.rb
require "uri"
(URI::REGEXP.constants - ["PATTERN"]).each do |rc|
puts "#{rc}: #{URI::REGEXP.const_get(rc)}"
end
URI::REGEXP::PATTERN.constants.each do |pc|
puts "#{pc}: #{URI::REGEXP::PATTERN.const_get(pc)}"
end
@zoras
zoras / email_validator.rb
Created September 20, 2011 16:15 — 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)
@zoras
zoras / AccessPrivate.rb
Created September 21, 2011 05:12
Accessing private method in ruby
Difference between C++ and Ruby private/protected
One person summed up the distinctions by saying that in C++, “private” means “private to this class”, while in Ruby it means “private to this instance”. What this means, in C++ from code in class A, you can access any private method for any other object of type A. In Ruby, you can not: you can only access private methods for your instance of object, and not for any other object instance (of class A).
Ruby folks keep saying "private means you cannot specify the receiver". What they are saying, if method is private, in your code you can say:
class AccessPrivate
def a
end
private :a # a is private method
@zoras
zoras / LICENSE.txt
Created September 28, 2011 12:05 — forked from p01/LICENSE.txt
Sudoku Solver in 140bytes
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Mathieu 'p01' Henri <http://www.p01.org/releases/>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE