Skip to content

Instantly share code, notes, and snippets.

View rgsingh's full-sized avatar

Rai Singh rgsingh

View GitHub Profile
@rgsingh
rgsingh / gist:8774590
Created February 2, 2014 20:40
jQuery performance tip (avoid DOM ready function overuse)
http://encosia.com/dont-let-jquerys-document-ready-slow-you-down
@rgsingh
rgsingh / Simple pull request work flow
Last active August 28, 2017 17:08
Establish a simple workflow for managing pull pull requests
# Fork a repository (owned by someone else usually. In this case, fordprefect forked from rgsingh)
git clone https://github.com/fordprefect/feature-dev-demo.git
# Establish an upstream so that your fork can keep in sync with the original repo.
cd feature-dev-demo
git remote add upstream https://github.com/th-js-meetup/feature-dev-demo.git
# Pull down all of the deltas from the original repo via upstream
git fetch upstream
@rgsingh
rgsingh / Squash last n commits
Last active August 29, 2015 13:56
Squash last n commits
# Typically, a discussion between a repo owner and collaborator will result in a pull request being assigned back to
# the respective collaborator, a new commit created, and being assigned back to the repo owner for review. This interaction
# can result in many commits per pull request.
# If following the convention of a commit header message which prefixes with an issue number, squashing commits for the same
# issue is very easy.
# For example, if "git log" shows 3 commits with commit messages starting with "Issue #3" or "i3", it is easy to visually
# determine what "n" should be.
#git rebase -i HEAD-<n>
git rebase -i HEAD-3

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"

From stackoverflow

####Replace USER with username and REPO with the name of the repository/application. git init

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'

git add whatever

git commit -a

@rgsingh
rgsingh / PageI.java
Last active August 29, 2015 14:06 — forked from criminy/PageI.java
import java.util.Collection;
import java.util.List;
import java.util.ListIterator;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
/**
* Extension class between spring data commons and java.util.List that is
* required to get MyBatis to use it as a return value.
@rgsingh
rgsingh / vim_diff_shortcuts
Created July 13, 2015 18:33
Vim diff of two files
#Open two files that need to be diffed
:e file1
Ctrl-w n
:e file2
:windo diffthis
:windo diffoff
Ctrl w t Ctrl w H (horizontal)
Ctrl w t Ctrl w K (vertical)
@rgsingh
rgsingh / vim_tab_space_check
Last active August 29, 2015 14:25
Vim show non-visible characters and look for whitespace or tab
:syntax on
:set syntax=whitespace
... then search for a string
...tab characters will be highlighted in blue
...space characters will be highlighted in red
If comparing more than one file in split windows, switch to that file (Ctrl-W w)
and set the syntax equal to whitespace to enable the color coding effect (:set syntax=whitespace).
@rgsingh
rgsingh / fix_last_remote_commit
Created July 28, 2015 02:01
Remove a git commit and re-push corrections
// If a push to the remote origin was already done then do the following
1. git stash // in same directory as previous commit
2. git reset --hard HEAD~1 // reset to the commit before last
3. git stash apply
4. Build if necessary and test
5. Commit whatever is needed
6. git push origin HEAD --force
7. Done
8. Have cake
@rgsingh
rgsingh / LICENSE
Last active August 29, 2015 14:28 — forked from ourmaninamsterdam/LICENSE
Arrayzing - The JavaScript array cheatsheet
The MIT License (MIT)
Copyright (c) 2015 Justin Perry
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions: