Skip to content

Instantly share code, notes, and snippets.

@abhi1010
abhi1010 / kthLinkedList.cpp
Created June 8, 2014 07:46
Kth element in Linked List
Node* findKthToLastElement (Node* node, unsigned short k)
{
Node* secondRunner = node;
for(unsigned short i = 0; i < k; ++i)
{
if (secondRunner->next != NULL)
secondRunner = secondRunner->next;
else
return NULL;
}
@abhi1010
abhi1010 / PartitionLinkedList.cpp
Last active August 29, 2015 14:02
Partition LInked List such that all values less than x are on left and the rest on the right side.
Node* sendToOtherList(Node* otherSideList, Node* n)
{
n->next = NULL;
if (otherSideList)
{
otherSideList->next = n;
otherSideList = otherSideList->next;
}
else
{
@abhi1010
abhi1010 / 0_reuse_code.js
Last active August 29, 2015 14:21
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@abhi1010
abhi1010 / RW1 Script in bash.sh
Last active February 25, 2021 02:59
Testing Reconwise from scratch
## Change only the first three variables. Rest should be same.
DIR='/tmp/'
GIT_LOCATION='https://[email protected]/tildesg/reconwisev1.git'
VENV=$DIR/v_env_rw1
## You cannot change the following
RW='reconwisev1'
cd $DIR
### Delete the folders if they already exist
@abhi1010
abhi1010 / curl.sh
Created July 2, 2015 06:52
curl commands for rw2
alias cu='curl -Fclient=GH -F"Newedge SGX T+1.2015-03-05.zip=@/private/var/reconwise/emails/Newedge SGX T+1.2015-03-05/Newedge SGX T+1.2015-03-05.zip" localhost:8000/confo/upload/'
alias rpp='curl -F"Daily Statements 2015-02-25=@/private/var/reconwise/emails/Daily_Statements_2015-02-25.xls" localhost:8000/parser/parse/'
alias rpu='curl -F"Daily Statements 2015-03-16=@/tmp/test.csv" localhost:8000/parser/upload/'
alias rcp='curl -F"Daily Statements 2015-02-25=@/private/var/reconwise/emails/Daily_Statements_2015-02-25.xls" localhost:8000/confo/parse/'
alias rpu1='curl -F"Daily Statements 2015-03-16=@/tmp/test.csv" localhost:8000/confo/upload/'
alias rdi='curl -Fclient=1 -Fadapter=GH -F"delta_info.20150403.csv=@/private/var/reconwise/ftp/grasshopper-delta_info-20150403_060205.csv" -F"fields=hedge_ratio" -k https://tamtech.ddns.net/confo/relations/'
@abhi1010
abhi1010 / gist:554885a7235f4047dae6
Last active September 2, 2015 14:18 — forked from anonymous/gist:0465925390f3442a7691
Tokenize a String
string strToSplit = "splitting strings, in|multiple ways";
std::vector<std::string> words;
boost::split(words, strToSplit, boost::is_any_of("\t ,|"));
std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
words.clear();
std::istringstream iss(strToSplit);
std::copy(std::istream_iterator<std::string>(iss), std::istream_iterator<std::string>(), std::back_inserter(words));
std::copy (words.begin(), words.end(), std::ostream_iterator<string>(cout, "\n"));
@abhi1010
abhi1010 / typename.cpp
Last active September 2, 2015 14:19 — forked from anonymous/typename.cpp
typename usage
template <class T1>
struct OuterStruct
{
T1 mValue;
struct InnerStruct
{
T1 mValue;
};
};
@abhi1010
abhi1010 / setup_ifast_demo.sh
Last active September 24, 2015 05:21
reconwise ifast demo setup
git clone https://bitbucket.org/tildesg/reconwisev2.git
cd reconwisev2
git fetch && git checkout ifastdemo
git pull
cd ../
virtualenv -p python3.4 ve_rw2
source ve_rw2/bin/activate
pip install -r reconwisev2/requirements.txt
cd reconwisev2/rw/
mkdir media/log
@abhi1010
abhi1010 / git_stats.sh
Created September 16, 2015 15:05
git stats by timelines - number of lines added, removed
git log --oneline --shortstat | tee /tmp/2
git log --shortstat --pretty="%cE" | sed 's/\(.*\)@.*/\1/' | grep -v "^$" | awk 'BEGIN { line=""; } !/^ / { if (line=="" || !match(line, $0)) {line = $0 "," line }} /^ / { print line " # " $0; line=""}' | sort | sed -E 's/# //;s/ files? changed,//;s/([0-9]+) ([0-9]+ deletion)/\1 0 insertions\(+\), \2/;s/\(\+\)$/\(\+\), 0 deletions\(-\)/;s/insertions?\(\+\), //;s/ deletions?\(-\)//' | awk 'BEGIN {name=""; files=0; insertions=0; deletions=0;} {if ($1 != name && name != "") { print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net"; files=0; insertions=0; deletions=0; name=$1; } name=$1; files+=$2; insertions+=$3; deletions+=$4} END {print name ": " files " files changed, " insertions " insertions(+), " deletions " deletions(-), " insertions-deletions " net";}' > /tmp/1 &
git log --since="1 year ago" --pretty=tformat: --numstat | awk '{ if ( $2 != 0 && $1 != 0 ) print $0 }' | gawk '{ add += $1; s
@abhi1010
abhi1010 / generate_diagram.py
Created September 24, 2015 04:19 — forked from jul/generate_diagram.py
building entitty relation ship diagram from a db by using introspection
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from sqlsoup import SQLSoup as sql
from sys import argv
DIGRAPH = """digraph structs {
graph [
rankdir= "LR"
bgcolor=white
]