Skip to content

Instantly share code, notes, and snippets.

View sumitasok's full-sized avatar

Sumit. M. Asok sumitasok

View GitHub Profile
@sumitasok
sumitasok / nginx.conf
Created June 5, 2013 12:16
Nginx Mobile Ehqv2
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@sumitasok
sumitasok / nginx.conf
Created June 5, 2013 12:15
Nginx Mobile Ehqv2
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
This installer has already modified the configuration file for you! The
following configuration snippet was inserted:
http {
...
passenger_root /Users/sumitasok/.rvm/gems/ruby-1.9.3-p392@ehq/gems/passenger-4.0.5;
passenger_ruby /Users/sumitasok/.rvm/wrappers/ruby-1.9.3-p392@ehq/ruby;
...
}
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@sumitasok
sumitasok / nginx.conf
Last active December 18, 2015 00:39
Couple of things I learnt while configuring nginx
map - like method definition
root - root path off the app
index - index file of the project
$http_user_agent - User Agent: Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari/6533.18.5
$request - Request: "GET /hhh?desktop_view HTTP/1.1"
$args - ARGS: "desktop_view"
$remote_addr - 127.0.0.1
$remote_user
$time_local - 03/Jun/2013:19:45:20 +0530
@sumitasok
sumitasok / gist:5661950
Created May 28, 2013 10:53
ruby command line JSON to YAML convertor
ruby -ryaml -rjson -e 'puts YAML.dump(JSON.parse(STDIN.read))' < file.json > file.yaml
it { should validate_presence_of :abc }
# what it expects is error messages against the columns which are under question.
# if you have a custom error message, use
it { should validate_presence_of(:abc).with_message(/the message/) }
@sumitasok
sumitasok / action_controller.rb
Created September 22, 2012 06:59
Module included
class UserDefined
module ActionController # :nodoc: all
def self.included(base)
base.send :helper_method, :user_method
end
private
def user_method
@user_defined ||= UserDefined.new(
:var => 'value',
@sumitasok
sumitasok / form.html
Created May 16, 2012 11:48
Form fields getting Accessible
<form>
<fieldset>
<legend>Form header</legend>
<! this above fieldset legend should have the text explaining the forms purpose >
<label for="id_of_related_input_field">Text corresponding to input field</label>
<input id="id_of_related_input_field" type="..." />
<! have label close to input, have for(label) and id(input) same for identification by screen reader, prefer this way over nesting input under label >
@sumitasok
sumitasok / rspec_expecations_spec.rb
Created April 27, 2012 06:55
Rspec Expectations
# to get the Location from the response header.
response.header["Location"].should eq('/admin/clients/'+client.id+'/edit')