Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
  • Login to instagram developers site and add http://localhost as a redirect API in your API client's settings
  • Navigate to https://www.instagram.com/oauth/authorize/?client_id=<CLIENT_ID>&redirect_uri=http://localhost&response_type=token
  • Get token from URL after redirect occurs back to http://localhost
ffmpeg -i in.mov -s 600x400 -pix_fmt rgb24 -r 10 -f gif - > out.gif
@ttezel
ttezel / download_popular_insta_photos.js
Last active October 17, 2016 09:02
Download instagram photos with >= N likes (run from an instagram user's profile page)
@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 / 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" ]
@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)