Skip to content

Instantly share code, notes, and snippets.

View ishankhare07's full-sized avatar
👨‍💻

Ishan Khare ishankhare07

👨‍💻
View GitHub Profile
@ishankhare07
ishankhare07 / Class_variables_and_init.ipynb
Last active January 28, 2016 13:30
Class variables and __init__ function details
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ishankhare07
ishankhare07 / subsets.py
Last active January 5, 2016 10:14
return a list of subsets
def subsets(not_selected, selected=[]):
if not not_selected:
return [selected]
else:
current_element = not_selected[0]
return (
subsets(not_selected[1:], selected) + \
subsets(not_selected[1:], selected + [current_element])
)
@ishankhare07
ishankhare07 / merge.py
Created November 22, 2015 13:51
merge sort in python
from random import shuffle
def merge(left, right, r_list=[]):
if not left and not right:
return r_list
elif not left:
r = right[0]
r_list.append(r)
return merge(left, right[1:], r_list)
elif not right:
@ishankhare07
ishankhare07 / ll
Last active September 30, 2015 13:45
linked numbers
@ishankhare07
ishankhare07 / alternate-merge.c
Created September 25, 2015 19:41
arrange a mix of numbers in an array in alternating +ve & -ve while retaining the order
#include "stdio.h"
#include "stdlib.h"
#define size(x) ({ \
sizeof(x) / sizeof(int); \
})
int main(void) {
int input[] = {4, -10, 2, -2, -7, 3, -3, 5, -4, -5, 1, -9, 0, -6, -1, -8};
int *i, *neg, *pos;
int *separators[2]; // pointer to a 2x(not yet know size) array
@ishankhare07
ishankhare07 / avl.py
Last active September 9, 2015 12:11
avl tree implementation
class Node:
def __init__(self, num):
self.data = num
self.left = None
self.right = None
root = None
def add_to_tree(element, root):
if root == None:
@ishankhare07
ishankhare07 / tmux.md
Last active September 7, 2015 10:40 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@ishankhare07
ishankhare07 / linesort
Last active August 30, 2015 16:50
pointer based quick sort
@ishankhare07
ishankhare07 / playground.rs
Created August 28, 2015 07:08 — forked from anonymous/playground.rs
Shared via Rust Playground
//function pointer
fn foo(x: i32) -> i32 {
return x+1;
}
fn main() {
let mut x: fn(i32) -> i32 = foo;
// or x = foo;
println!("{}", x(10));