Skip to content

Instantly share code, notes, and snippets.

@ttezel
ttezel / quickSort.js
Created July 16, 2012 19:10
Simple QuickSort in JS
function quickSort (arr) {
if (!arr.length)
return arr
var pivot = arr.splice(0, 1)
var less = []
var greater = []
arr.forEach(function (el) {
if (el <= pivot)
@ttezel
ttezel / gist:3160712
Created July 22, 2012 19:00
Some things I think will happen by 2020

#Some things I think will happen by 2020:

  1. The Voice interface will be mastered. We will be talking to computers and they will understand the meaning/context of our words, and help us live our lives. Siri is where it starts.

  2. Fully articulable, brain-controlled artificial limbs will be in existence. Amputees will have limbs replaced with an artificial limb, and continue to live fully enabled. Price would still be high at this time. There is already great progress in this area.

  3. Driverless cars will start to gain popularity. People who purchase an autonomous vehicle (e.g. Google's driverless car) will be sitting in their cars, working/entertaining themselves with mobile devices while they are driven around. Google is close to launching their autonomous car for sale. They are way ahead of the competition. Google will be heavy in the automotive game. They are lobbying to legalize Autonomous Vehicles in the US.

  4. We will have devices with morphable, touchable interface

@ttezel
ttezel / gist:4138642
Last active July 27, 2024 14:46
Natural Language Processing Notes

#A Collection of NLP notes

##N-grams

###Calculating unigram probabilities:

P( wi ) = count ( wi ) ) / count ( total number of words )

In english..

@ttezel
ttezel / gist:4142172
Last active July 31, 2016 08:53
quickly add jquery to a page
var script = document.createElement('script');
script.src = 'https://code.jquery.com/jquery.min.js';
script.type = 'text/javascript';
document.getElementsByTagName('head')[0].appendChild(script);
@ttezel
ttezel / max_subarray
Created December 7, 2012 21:44
Max Subarray
/**
* Given an array of real numbers,
* returns the max contiguous subsequence for which
* the sum of the elements is maximized
*
* @param {Array} arr input array
* @return {Array} slice with maximum sum
*/
function maxSubarray (arr) {
//start & end indices for our max slice
@ttezel
ttezel / ECE 406 Algorithms notes.md
Last active December 10, 2015 21:39
ECE 406 Algorithms notes

#Class #2 Wed. Jan 9, 2013

End of last class

f = O(g) if there exist constants c and N s.t.

(notation: ∀ === for all)

f(n) ≤ g(n) ∀ n ≥ N

@ttezel
ttezel / modexp.m
Last active May 10, 2022 20:29
Modular Exponentiation in Matlab (x ^ y mod n)
%{
Problem 7 (i): modexp function
Returns x ^ y mod n for x, y, and n > 1.
%}
function result = modexp (x, y, n)
%anything raised to 0th power = 1 so return 1
if (y == 0)
result = 1;
return;
end
@ttezel
ttezel / gcd-euclid.m
Last active December 11, 2015 17:38
gcd algorithm (extended-euclid)
%{
Problem 7 (ii) - extended-euclid function
Given two integers a and b, it finds the largest integer that
divides both of them - known as their greatest common divisor (gcd).
Input: integers a and b where a >= b >= 0
Output : gcd(a, b)
%}
function result = euclid (a, b)
@ttezel
ttezel / extended_euclid.m
Created January 25, 2013 17:50
Extended Euclid Algo for finding the GCD of two integers. Works using Euclid's law: if `d` is the GCD of `a` and `b`, then there exists an `x` and `y` such that ```ax + by = d```
%{
Problem 7 (ii) - Extended Euclid
Input: positive integers a,b with a >= b >= 0
Output: integer array [ x,y,d ] such that
d = gcd(a,b) and ax + by = d
%}
function result = extended_Euclid (a, b)
if (b == 0)
@ttezel
ttezel / gist:6143316
Last active April 9, 2016 18:39
Elasticsearch fuzzy search scores the same for exact match and non-exact match
curl -XPOST 'http://localhost:9200/fuzzytest/' -d '
{
settings: {
index: {
analysis: {
analyzer: {
default: {
type: "custom",
tokenizer: "uax_url_email",
filter: [ "lowercase" ]