Skip to content

Instantly share code, notes, and snippets.

View iMagesh's full-sized avatar
🏠
Working from home

Magesh iMagesh

🏠
Working from home
View GitHub Profile
@iMagesh
iMagesh / nginx-config
Created November 6, 2014 06:30
Nginx config new one
upstream railsapp {
# fail_timeout=0 means we always retry an upstream even if it failed
# to return a good HTTP response (in case the Unicorn master nukes a single worker for timing out).
server 10.0.0.5:8182;
#server unix:/var/www/meralabour/tmp/sockets/unicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name app.atsquare.in;
require 'haml'
class ErbEngine < Haml::Engine
def push_script(text, preserve_script, in_tag = false, preserve_tag = false,
escape_html = false, nuke_inner_whitespace = false)
push_text "<%= #{text.strip} %>"
end
def push_silent(text, can_suppress = false)
push_text "<% #{text.strip} %>"
@iMagesh
iMagesh / user.rb
Last active August 29, 2015 13:57
User Model roles
require 'csv'
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable, :confirmable, :token_authenticatable,
:recoverable, :rememberable, :trackable, :authentication_keys => [:rollno]
#user nobody;
worker_processes 10;
error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
@iMagesh
iMagesh / whining-web-server.html
Created December 19, 2013 18:51
Funny 404 Page - Web server whines on hitting a 404
<html>
<body>
<form>
<textarea class="span12" rows="20" cols="100"></textarea>
</form>
<script language="Javascript"><!--
var tl=new Array(
"The requested document is no more.",
'No file found.',
@iMagesh
iMagesh / emacs.el
Created November 19, 2013 10:59
Laptop emacs setting
(setq inhibit-startup-message t) ;; Removes startup message
(setq-default indent-tabs-mode nil)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(auto-save-default t)
[user]
name = Magesh
email = magesh@atsquare.in
[color]
ui = true
[alias]
timeline = log --graph --all --format=format:'(%cr) %s%d' --date-order --abbrev-commit --date=relative
timelog = log --graph --pretty=format:'%Cgreen(%cr) -%C(yellow)%d%Creset %s %C(bold blue)<%an>%Creset' --abbrev-commit --
dlog = log --graph --date-order -C -M --pretty=format:'%ad [%an] %Cgreen%d%Creset %s' --all --date=short
@iMagesh
iMagesh / mygitconfig
Last active December 20, 2015 13:18
My git config file
[user]
name = Magesh
email = magesh@atsquare.in
[color]
ui = true
[alias]
timeline = log --graph --all --format=format:'(%cr) %s%d' --date-order --abbrev-commit --date=relative
task :migrate_wp => :environment do
wp = Mysql2::Client.new(:host => "localhost", :username => "root", :password => "root", :database => "mageshblog")
results = wp.query("select * from wp_zxdasg_posts;")
results.each do |r|
Post.create(
:user_id => r["author"],
:date => r["post_date"],
:content => r["post_content"],
:title => r["post_title"],