Skip to content

Instantly share code, notes, and snippets.

@erogol
erogol / twitter_scrapper.py
Created December 25, 2013 22:34
scrap twitter wall given the search page address or simulating a browser via mechanize
'''
Written by:
Eren Golge - erengolge@gmail.com
'''
import json
import pdb
import urllib2
import mechanize
import cookielib
@erogol
erogol / dist2.m
Last active January 1, 2016 16:29
Efficient pairwise euclidean distance for MATLAB given two matrices dist
function D = dist2(X, C)
tempx = full(sum(X.^2, 2));
tempc = full(sum(C.^2, 2).');
D = -2*(X * C.');
D = bsxfun(@plus, D, tempx);
D = bsxfun(@plus, D, tempc);
end
@erogol
erogol / fundamental_algos.py
Last active January 2, 2016 22:49
Some fundamental algorithms. Currently ; Insertion Sort, Merge Sort, Binary Search, Heap_Sort, Quick_sort
'''
Eren Golge - erengolge@gmail.com
written for experience and experiment
'''
import pdb
import math
import random
import time
'''
@erogol
erogol / linked_list.cpp
Last active April 10, 2022 10:17
linked list implementation to experiment with it in C++
/*
Linked_list implementation for cracking the code
questions
*/
#include <iostream>
#include <stdlib.h> /* srand, rand */
#include <map>
using namespace std;
template <typename dataType>
@erogol
erogol / linked_list.h
Created January 21, 2014 12:57
linked_list.cpp 'h header file
/*
Linked_list implementation for cracking the code
questions
*/
template <typename dataType>
class List{
private:
@erogol
erogol / sub_vector_exp.cpp
Created January 26, 2014 10:58
extract a sub-vector from given c++ vector, example code
#include <vector>
#include <iostream>
using namespace std;
int main(){
// This initialization is available at C++11 support compiler
// For lower version C++ support check the reference document
vector<int> arr (9);
arr = {1,2,3,4,5,6,7,8,9};
@erogol
erogol / sort_aganram_base.cpp
Last active January 4, 2016 16:29
Write a method to sort an array of strings so that all the anagrams are next to each other.
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
void printArr(string arr[], int size){
for(int i = 0; i < size; i++){
cout << arr[i] << endl;
}
from multiprocessing import Pool
# parallelize function
def product(a,b):
print a*b
# auxiliary funciton to make it work
def product_helper(args):
return product(*args)
@erogol
erogol / face_detection.py
Created February 8, 2014 12:58
detect faces and show them on separate windows. You give the image path as an argument to that python script and see the magic.
from __future__ import division
import cv2
import cv2.cv as cv
import sys
import pdb
def detect(img, cascade):
rects = cascade.detectMultiScale(img, scaleFactor=1.1, minNeighbors=3, minSize=(10, 10), flags = cv.CV_HAAR_SCALE_IMAGE)
if len(rects) == 0:
return []
import numpy as np
import theano
import theano.tensor as T
from theano import function,sandbox
from theano import ProfileMode
import warnings
warnings.filterwarnings("ignore")
# Dummy Data
theano.config.floatX = 'float32' # Theano needs this type of data for GPU use