Skip to content

Instantly share code, notes, and snippets.

View s-ashwinkumar's full-sized avatar

Ashwin Kumar Subramanian s-ashwinkumar

View GitHub Profile
s-ashwinkumar /
Created September 13, 2017 07:06
Sample to show how to use getopt
# 'arg-x' and 'x' behave like flags
# 'arg-y' and 'y' have required arguments.
# 'arg-z' and 'z' have optional arguments
# Initial value for the flag parameter (default false)
# create the option string
s-ashwinkumar /
Created August 21, 2017 16:52 — forked from KartikTalwar/
Rsync over SSH - (40MB/s over 1GB NICs)

The fastest remote directory rsync over ssh archival I can muster (40MB/s over 1gb NICs)

This creates an archive that does the following:

rsync (Everyone seems to like -z, but it is much slower for me)

  • a: archive mode - rescursive, preserves owner, preserves permissions, preserves modification times, preserves group, copies symlinks as symlinks, preserves device files.
  • H: preserves hard-links
  • A: preserves ACLs
s-ashwinkumar / basicAlias.rb
Last active August 21, 2017 06:15
A sample for alias method in ruby
View basicAlias.rb
class MyClass
def old_method
'old_method OR new_method'
alias :new_method :old_method
# NOTE-1 : 'alias' is a keyword and not a method, that is why
# there is no comma (I almost everytime type a comma there !)
# NOTE-2 : If you want to use the method kind of syntax you can use
# the 'method' Module#alias_method which does the same thing
# but is actually a method.
s-ashwinkumar / methodMissingDeprecation.rb
Last active August 15, 2017 05:49
Method deprecation using method_missing
View methodMissingDeprecation.rb
class Myclass
@@old_methods = { oldMethod1: :new_method1, oldMethod2: :new_method2 }
def new_method1
def new_method2
s-ashwinkumar / 0_reuse_code.js
Created August 4, 2017 08:42
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
s-ashwinkumar / asynchCode.js
Last active August 4, 2017 08:29
Async equivalent of the synchronous code
View asynchCode.js
.then(finalResult => console.log("I DID IT - "+finalResult))
s-ashwinkumar / synchronousCode.js
Created August 4, 2017 08:21
Sample synchronous code
View synchronousCode.js
try {
var result1 = syncMeth1();
var result2 = syncMeth2(result1);
var finalResult = syncMeth3(result2);
console.log("I DID IT - "+finalResult);
s-ashwinkumar / chainedPromise.js
Last active August 4, 2017 08:31
Add a promise to the old one and chain it
View chainedPromise.js
const recordSong = function(new_post) {
// This is a shorthand for functions with just resolved state.
return Promise.resolve("I have recorded a song and "+new_post);
// Kudos to you if you caught the shorthand in 'console.log'
s-ashwinkumar / consumeFirstPromise.js
Created August 4, 2017 08:16
Consume the first promise
View consumeFirstPromise.js
.then(new_post => console.log(new_post))
.catch(error_message => console.log(error_message));
s-ashwinkumar / firstPromise.js
Last active August 4, 2017 08:34
Sample first promise
View firstPromise.js
let iReturnEarly = true;
const willAddNewPost = new Promise(
(resolve, reject) => {
if(iReturnEarly) {
resolve("This is new post");
}else {
reject("Damn I missed it.");