Skip to content

Instantly share code, notes, and snippets.

View sumitasok's full-sized avatar

Sumit. M. Asok sumitasok

View GitHub Profile
lyrics_prob = { "Poetry" => 0.000004219324421463816, "History" => 1.406441473821272e-7, "Other_Arts_Humanities" => 7.03220736910636e-7, "Performing_Arts" => 4.2193244214638157e-7, "Philosophy" => 2.812882947642544e-7, "Small_Business" => 1.406441473821272e-7, "Games_and_Gear" => 1.406441473821272e-7, "Law_and_Ethics" => 1.406441473821272e-7, "Comics_and_Animation" => 5.625765895285088e-7, "Jokes_and_Riddles" => 2.812882947642544e-7, "Other_Society_and_Culture" => 1.406441473821272e-7, "Polls_and_Surveys" => 1.406441473821272e-7, "Internet" => 2.812882947642544e-7, "Security" => 1.406441473821272e-7, "Software" => 1.406441473821272e-7, "Camcorders" => 1.406441473821272e-7, "Cultures_and_Groups" => 1.406441473821272e-7, "Home_Theater" => 1.406441473821272e-7, "Other_Electronics" => 1.406441473821272e-7, "Home_Schooling" => 1.406441473821272e-7, "Homework_Help" => 2.812882947642544e-7, "Preschool" => 9.845090316748903e-7, "Quotations" => 0.000001406441473821272, "Special_Education" => 1.406441473821272e-7, "Word

Git work flow

Intro

A branch is a version of code that we are working on, different from main code.

Two people working on a same file, if they are creating their own branch and editing the same file in those two different branches, they will not find any conflict between their work, as two different copies of their file will be maintained by Git.

The process by which we sync between work done on both the files, is called merging.

@sumitasok
sumitasok / gtest.sublime-snippet
Last active August 29, 2015 14:05
Go test with testify assert sublime snippet
<snippet>
<content><![CDATA[
package ${1:pkgname}
import (
// "fmt"
"github.com/stretchr/testify/assert"
"testing"
)
@sumitasok
sumitasok / periodic-cal-update.applescript
Created August 25, 2014 09:34
An apple script to set reminder ahead for x days, in Mac calendar.
-- An apple script to set reminder ahead for x days, in Mac calendar.
tell application "iCal"
set theCalendar to make new calendar with properties {title: "Calendar title - Mac"}
end tell
set i to -1 -- manipulate i to offset start date of making events.
repeat 365 times --make event for 365 days
set i to i + 1
tell application "Calendar"
@sumitasok
sumitasok / interface-funcprog-oop.go
Last active August 29, 2015 14:05
A Display of interface and Functional Programming playing hand in hand with OOP - with Golang
package reqresp
type ReqResp interface {
HashableString() string
IgnoreList() map[string]string
}
type Response struct {
Type Type
Details DataTypes
@sumitasok
sumitasok / send_json_and_get_json.go
Created October 3, 2014 06:17
Send and Get Json in Go lang
str := fmt.Sprintf(`{"key": "%s", "message": {"html": "%s", "text": "%s", "subject": "%s", "from_email": "%s", "from_name": "%s", "to": [ { "email": "%s", "name": "%s", "type": "%s" }]}}`,
s.Key,
s.Message.Html,
s.Message.Text,
s.Message.Subject,
s.Message.FromEmail,
s.Message.FromName,
s.Message.To[i].Email,
s.Message.To[i].Name,
s.Message.To[i].RType)
package goUtils
import (
"encoding/json"
"io/ioutil"
"net/http"
)
func reqJsonToObject(resp *http.Response, v interface{}) error {
defer resp.Body.Close()
@sumitasok
sumitasok / ssh-key
Last active August 29, 2015 14:17
Dockerfile examples from internet
#DOCKER-VERSION 0.3.4
# http://stackoverflow.com/questions/18136389/using-ssh-keys-inside-docker-container
from ubuntu:12.04
RUN apt-get update
RUN apt-get install python-software-properties python g++ make git-core openssh-server -y
RUN add-apt-repository ppa:chris-lea/node.js
RUN echo "deb http://archive.ubuntu.com/ubuntu precise universe" >> /etc/apt/sources.list
RUN apt-get update
@sumitasok
sumitasok / conn.go
Last active August 29, 2015 14:18
Mongo Mgo Cheat Sheet
func mgoSession() *mgo.Session {
uri := "127.0.0.1"
if uri == "" {
fmt.Println("no connection string provided")
os.Exit(1)
}
sess, err := mgo.Dial(uri)
if err != nil {
fmt.Printf("Can't connect to mongo, go error %v\n", err)
@sumitasok
sumitasok / file_replace.sh
Last active August 29, 2015 14:19
Shell Script collection
# add a string in a field to line number (15)
perl -pi -e 'if($.==14){s/\n/\n\/\/ ABC\n/g}if(eof){$.=0}' Makefile.txt
# replace regex with environment variable
perl -pi -e 's/(([0-9]+.){3}([0-9]+))/'$dIPmysql'/g' t.sh