Skip to content

Instantly share code, notes, and snippets.

View ishankhare07's full-sized avatar
πŸ‘¨β€πŸ’»

Ishan Khare ishankhare07

πŸ‘¨β€πŸ’»
View GitHub Profile
@ishankhare07
ishankhare07 / shuffle.rb
Created June 12, 2015 11:33
ruby permutations
def shuffle(number)
ret_arr = []
f = fact(number.to_s.size)
count = 0
while count < f/2 do
if count == 0
ret_arr.push(number)
ret_arr.push(number.to_s.reverse.to_i)
else
num_arr = number.to_s.split(//)
@ishankhare07
ishankhare07 / dumps.log
Last active August 29, 2015 14:24
dumps
{0=>7,
1=>1436615004374.0,
9=>26,
2=>
[{0=>9,
1=>1436615004217.0,
2=>
[{12=>"process_incoming_request",
13=>"Rbkit::Server#process_incoming_request",
6=>"/Users/ishan/Desktop/rbkit/lib/rbkit/server.rb",
@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));
@ishankhare07
ishankhare07 / linesort
Last active August 30, 2015 16:50
pointer based quick sort
@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 / 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 / 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 / ll
Last active September 30, 2015 13:45
linked numbers
@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: