Skip to content

Instantly share code, notes, and snippets.

Magesh iMagesh

Block or report user

Report or block iMagesh

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View using-multiple-github-accounts-with-ssh-keys.md

Problem

I have two Github accounts: oanhnn (personal) and superman (for work). I want to use both accounts on same computer (without typing password everytime, when doing git push or pull).

Solution

Use ssh keys and define host aliases in ssh config file (each alias for an account).

How to?

  1. Generate ssh key pairs for accounts and add them to GitHub accounts.
@iMagesh
iMagesh / move_to_rds.rb
Created Feb 5, 2019 — forked from guenter/move_to_rds.rb
A quick and dirty script to move a database into Amazon RDS (or any other database). Can transfer part of the data beforehand.
View move_to_rds.rb
require 'fileutils'
start_time = Time.now
SOURCE_DB = {
:name => 'db_name',
:user => 'db_user',
:password => 'db_pass',
:host => 'localhost'
View server installation
For new user
adduser user_name
add sudo permission to the user
adduser user_name sudo
For generate key(local)
ssh-keygen -b 4096
copy key to server (ubuntu)
View kill all delayed job workers
kill $(ps aux | grep '[d]elayed_job' | awk '{print $2}')
Credit:
http://stackoverflow.com/questions/3510673/find-and-kill-a-process-in-one-line-using-bash-and-regex
@iMagesh
iMagesh / precompile.md
Created Feb 15, 2016 — forked from mrbongiolo/precompile.md
HOW TO: Rails 4.2 add 'vendor/asset' to precompile list
View precompile.md

To enable the precompilation of all non.js/.css assets within vendor/assets just add this to config/initializers/assets.rb:

Rails.application.config.assets.precompile << Proc.new { |path, fn| fn =~ /vendor\/assets/ && !%w(.js .css).include?(File.extname(path)) }

Be aware that this will precompile ALL non .js/.css assets that you have there, some plugins or libraries might have .txt or other files around, and those would end up into your precompiled list also.

If you need to precompile images only, you could use this:

Rails.application.config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
@iMagesh
iMagesh / nginx.conf
Created Jul 17, 2015
nginx ssl config rails
View nginx.conf
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;
View testcl.js
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 {
View example.js
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;
});
@iMagesh
iMagesh / nginx-config
Created Nov 6, 2014
Nginx config new one
View nginx-config
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;
View gist:9ae481a75425234f1f0b
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} %>"
You can’t perform that action at this time.