Skip to content

Instantly share code, notes, and snippets.

View ahurriyetoglu's full-sized avatar

Ali Hürriyetoğlu ahurriyetoglu

View GitHub Profile
@ahurriyetoglu
ahurriyetoglu / upload-file-or-folder-to-Dropbox.ipynb
Last active April 21, 2023 20:04
You can use Dropbox SDK with its Python client to upload files or folders directly to your Dropbox account. This code handles files independent of their size.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
"Ecrin"
"Eymen"
"Ceylin"
"Ebrar"
"Tuana"
"Esila"
"Esra"
"Enes"
"Talha"
"Ömer"
@ahurriyetoglu
ahurriyetoglu / rank_metrics.py
Created December 10, 2015 06:04 — forked from bwhite/rank_metrics.py
Ranking Metrics
"""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
# Docs: http://open-platform.theguardian.com/documentation/
import requests as r
import json
g_api_key = "Your API key" # limit is 12 calls per second.
keyterm = "Your Keyterm"
#from-date=1920-
g_articles_strt = r.get("http://content.guardianapis.com/search?q="+keyterm+"/politics&show-blocks=all&from-date=2015-01-01&api-key="+g_api_key)
import requests as r
import json
import datetime
# Docs: http://developer.nytimes.com/docs
# Try at: http://developer.nytimes.com/io-docs
srch_api_key = "Your key <check docs>"
keyphrase = 'anything_you_want'
srch_api_result = r.get("http://api.nytimes.com/svc/search/v2/articlesearch.json?q="+keyphrase+"&api-key="+srch_api_key)
#!flask/bin/python
from flask import Flask, jsonify, abort, request, make_response, url_for
from flask.ext.httpauth import HTTPBasicAuth
app = Flask(__name__, static_url_path = "")
auth = HTTPBasicAuth()
@auth.get_password
def get_password(username):
if username == 'miguel':
def plot_correlogram(df,figsize=(20,20)):
''' Creat an n x n matrix of scatter plots for every
combination of numeric columns in a dataframe'''
cols = list(df.columns[df.dtypes=='float64'])
n = len(cols)
fig, ax = plt.subplots(n,n,figsize=figsize)
for i,y in enumerate(cols):
for j,x in enumerate(cols):
if i != n-1:
import numpy as np
from math import pi, log
import pylab
from scipy import fft, ifft
from scipy.optimize import curve_fit
i = 10000
x = np.linspace(0, 3.5 * pi, i)
y = (0.3*np.sin(x) + np.sin(1.3 * x) + 0.9 * np.sin(4.2 * x) + 0.06 *
np.random.randn(i))
@ahurriyetoglu
ahurriyetoglu / pyTwiNL.py
Last active August 29, 2015 14:07
This python code provides easy access to twiqs.nl API. Information about twiqs.nl can be found at http://ifarm.nl/erikt/twinl/
# code to connect to twiqs.nl API
# Current IP address of twiqs.nl is: http://145.100.57.182
import requests
urlto_twiqsNL = "http://145.100.57.222/cgi-bin/twitter"
s = requests.Session()
r = s.post(urlto_twiqsNL, data={"NAME":user_name, "PASSWD":passwd})
print('Cookie Created')
#!/usr/bin/env python
import numpy as np
def medfilt (x, k):
"""Apply a length-k median filter to a 1D array x.
Boundaries are extended by repeating endpoints.
"""
assert k % 2 == 1, "Median filter length must be odd."