Skip to content

Instantly share code, notes, and snippets.

View sumanmukherjee03's full-sized avatar

Suman Mukherjee sumanmukherjee03

View GitHub Profile

Keybase proof

I hereby claim:

To claim this, I am signing this object:

@sumanmukherjee03
sumanmukherjee03 / cipher_encryption_decryption.go
Last active May 5, 2021 11:27
AES GCM example in python and go
package main
import (
"crypto/aes"
"crypto/cipher"
"fmt"
"reflect"
"strconv"
"time"
)
@sumanmukherjee03
sumanmukherjee03 / tree_traversal.rb
Created May 24, 2013 19:29
Implementation of preorder, inorder and postorder in a binary tree
require 'rspec'
require 'forwardable'
RSpec.configure do |config|
config.mock_with :rspec
config.color_enabled = true
end
class Node
def initialize(value)
@sumanmukherjee03
sumanmukherjee03 / barewords_example.rb
Created May 24, 2013 18:39
Another example of how to use barewords in ruby.
require 'rspec'
require 'forwardable'
RSpec.configure do |config|
config.mock_with :rspec
config.color_enabled = true
end
module Version
NUMBER = 1
@sumanmukherjee03
sumanmukherjee03 / array_ext.rb
Last active December 17, 2015 17:19
Extend the array class with merge_sort and binary_search
require 'rspec'
RSpec.configure do |config|
config.mock_with :rspec
config.color_enabled = true
end
module ArrayExt
def merge_sort
if self.length <= 1
@sumanmukherjee03
sumanmukherjee03 / barewords.rb
Created May 21, 2013 19:51
Implementation of Greeting Message application and barewords
require 'rspec'
require 'forwardable'
RSpec.configure do |config|
config.mock_with :rspec
config.color_enabled = true
end
def program_name
"Greeting Messages"
@sumanmukherjee03
sumanmukherjee03 / hash_ext.rb
Created May 21, 2013 19:50
Hash decoration with custom method for finding value for any nested key
require 'rspec'
RSpec.configure do |config|
config.mock_with :rspec
config.color_enabled = true
end
module MyHashTools
def get_val_for(sym)
@sumanmukherjee03
sumanmukherjee03 / implicit_return_encapsulation_issues.rb
Created March 9, 2013 23:59
Does implicit return in ruby violate encapsulation?
class Outer
class Inner
def initialize(attrs)
@obj = attrs
end
def do_something
# do somehting with the @obj
@obj
end
var Person = function(name) {
this.name = name;
};
Person.prototype.getName = function() {
return this.name;
};
var thomas = new Person('Thomas');
var amy = new Person('Amy');
@sumanmukherjee03
sumanmukherjee03 / gist:5117968
Created March 8, 2013 16:59
cache function
Function.prototype.cache = (function() {return {};})();
Function.prototype.setCache = (function() {
var self = this;
return function(key) {
if(!this.cache[key])
this.cache[key] = this.call(self, key);
};
})();