Skip to content

Instantly share code, notes, and snippets.

View oztalha's full-sized avatar

Talha Oz oztalha

View GitHub Profile
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
Okay so here's the setup:
[-] The primary server API is exposed via Flask (Python) and all static files, including all html, css, js is served by nginx.
[-] Python is exposing an API at url http://domain.com/api/download/<file_id>, where file_id is a database id for the file that we're interested in downloading.
1. User wants to download a file, so we spawn a new window with the url '/api/download/<file_id>'
2. Nginx intercepts the request, sees that it starts with /api/, and then forwards the request to Flask, which is being served on port 5000.
3. Flask routes the request to its download method, retrieves the pertinent data from the file_id, and constructs additional header settings to make nginx happy and to force the browser to see the file stream as a download request instead of the browser just trying to open the file in a new window. Flask then returns the modified header stream to nginx
4. Nginx is finally ready to do some work. While parsing the headers for the incoming request, it encounters "X
@oztalha
oztalha / grant.sh
Created September 3, 2014 21:42
Grant SELECT access to a user for all tables in a PostgreSql DB
#!/bin/bash
echo '---------------------------------------------------------------'
echo 'Grant SELECT access to a user for all tables in a PostgreSql DB'
echo '[USAGE]: ./scriptname username dbname'
echo '---------------------------------------------------------------'
for table in `echo "SELECT schemaname || '.' || relname FROM pg_stat_all_tables;" | psql $2 | grep -v "pg_" | grep "^ " | grep -v "\?column\?"`;
do
echo "GRANT SELECT ON TABLE $table TO $1;"
echo "GRANT SELECT ON TABLE $table TO $1;" | psql $2
done
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oztalha
oztalha / nba-game-logs-scraper.py
Last active January 27, 2017 14:06
Python script to scrape NBA game logs (saves each season as a separate html file)
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import pandas as pd
import time
driver = webdriver.Chrome()
#driver.get('http://stats.nba.com/teams/gamelogs/#!?Season=ALLTIME&SeasonType=Regular%20Season')
for year in range(2016,1945,-1):
url = 'http://stats.nba.com/teams/gamelogs/#!?Season='+str(year)+'-'+format((year+1)%100,'02d')+'&SeasonType=Regular%20Season'
driver.get(url)
@oztalha
oztalha / PopSynth.ipynb
Last active February 15, 2017 16:15
PopSynth.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oztalha
oztalha / Population Synthesis.ipynb
Last active April 5, 2017 17:30
Population Synthesis Using Census Data
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oztalha
oztalha / Social Circles.ipynb
Last active April 26, 2017 18:59
code/Social Circles.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oztalha
oztalha / Visa Refusals.ipynb
Last active May 14, 2017 06:13
Tourist Visa Refusals by Country
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.