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 / 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]
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 / 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;
Lib.ajax.getJSON({
url: 'https://api.twitter.com/1/statuses/user_timeline.json?&screen_name=gabromanato&callback=?&count=1',
type: 'jsonp'
}, function(tweet) {
document.querySelector('#tweet').innerHTML = tweet[0].text;
});
var pageUrl = "http://something.com/gsm";
var interactionId = "email-form"; //id of the product
document.getElementsByClassName(interactionId).onsubmit = function AfterFunction(e){
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
@iMagesh
iMagesh / nginx.conf
Created July 17, 2015 12:07
nginx ssl config rails
upstream myapp{
# 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 127.0.0.1:3000;
}
server {
#listen 80 ssl;
listen 443 ssl;
var now = new Date();
var currMonth = now.getMonth();
var currYear = now.getFullYear();
var date = now.getDate();
var weekDay = new Array(7);
weekDay[0] = "Sun";
weekDay[1] = "Mon";
weekDay[2] = "Tue";
@iMagesh
iMagesh / textbooks.rake
Created August 13, 2009 11:03
this is my first ruby script..for rake tasks.. used to populate the database with the students textbook info
namespace :sp do
authors = %w/Magesh Bala Vikram Abraham Imran Satish Harish Varun Jayamohan Ramesh Raghuvamsan Yogesh Yuvaraja Ranjith Kavitha Safia Surya Priya Shalini Priyanka/
publishers = ["Tamil Nadu TextBook Corporation"]
al = authors.length
pl = publishers.length
task :textbooks => :environment do
TextBook.delete_all
@iMagesh
iMagesh / wp2tumblr
Created October 12, 2010 19:13 — forked from mwunsch/wp2tumblr
#!/usr/bin/env ruby
## WP2TUMBLR: WordPress 2 Tumblr Importing tool
##
## Usage: wp2tumblr [OPTION] WORDPRESS_XML_FILE
##
## Import the WORDPRESS_XML_FILE to a Tumblr blog.
## Provide `--group` option to publish to a group.
## This could take a long time...
##
## To install, download the script and chmod to 755.
require 'rubygems'
require 'net/http'
require 'nokogiri'
TUMBLR_USER = 'your@email.com'
TUMBLR_PASS = 'yourpassword'
url = URI.parse('http://www.tumblr.com/api/write')
# Read the WP export file