Skip to content

Instantly share code, notes, and snippets.

@ankitdbst
ankitdbst / BinaryTree.cpp
Created May 31, 2012 19:08
Binary Tree class using cpp templates
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string.h>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
#include <map>
#include <algorithm>
@ankitdbst
ankitdbst / BinaryAdder.cpp
Created June 26, 2012 16:00
Adds two nums without '+' operation. (Works for positives only)
/*
* Addition using bitwise operations
*/
int binary_adder(int a, int b)
{
int sum = 0, pos = 0;
bool bit = 0, carry = 0;
while(a || b) {
// At each position i bitwise sum is the xor
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
@ankitdbst
ankitdbst / kmp.cpp
Created July 19, 2012 08:56
Knuth Morris Pratt String matching algorithm
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef vector<int> vi;
#define pb push_back
#define forn(a, b) for (int a = 0; a < b; ++a)
#define fore(a, b, c) for (int a = b; a < c; ++a)
@ankitdbst
ankitdbst / SortLanguageStrings.java
Created August 12, 2012 04:58
Sort the language strings in Moodle repository_plugin.php in lang/
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class SortLanguageStrings {
private static final String REGEX = "\\$string\\[\\'(.*)\\'\\].*";
public static void main( String args[] ) {
// Compile pattern
@ankitdbst
ankitdbst / galerkin.cpp
Created October 4, 2012 09:22
Finite Element Approximation :: Galerkin Method
/**
* Galerkin Method
* Solving for y''+ ay' + by + f(x) = 0
* a, b are constants
* y(u1) = v1, y(u2) = v2 BVP
*/
#include <iostream>
#include <cmath>
using namespace std;

Awesome PHP

A list of amazingly awesome PHP libraries, resources and shiny things.

Composer

/*
** Skip Lists data structures. Equivalent to Balanced Binary Trees
** Insert: O(LogN)
** Remove: O(LogN)
** Search: O(LogN) on average (worst case: O(N))
*/
#include <vector>
#include <ctime>
#include <cstdlib>
@ankitdbst
ankitdbst / todo-world_.idea_.name
Created December 7, 2014 12:23
React.JS | Hello World (Todo)
todo-world
@ankitdbst
ankitdbst / remove_idea_from_git
Created December 7, 2014 17:13
Remove .idea from Git
$ echo '.idea' >> .gitignore
$ git rm -r --cached .idea
$ git add .gitignore
$ git commit -m '(some message stating you added .idea to ignored entries)'
$ git push