Skip to content

Instantly share code, notes, and snippets.

View bolshoibooze's full-sized avatar

Arthur Mwai bolshoibooze

View GitHub Profile
@bolshoibooze
bolshoibooze / install scipy & pandas on a virtualenv
Last active March 12, 2016 14:48
Quick install of scipy and pandas on a virtualenv
Bits and pieces i collected while trying to install scipy,numpy and pandas on a VPS (digitalocean):
Scipy has some funny dependencies: http://www.netlib.org/lapack/ and http://www.netlib.org/blas/, so if you want to avoid
the hassle of building BLAS and LAPACK, install linear algebra libraries from repository (for Ubuntu/debian).
# credits:: <http://stackoverflow.com/questions/7496547/does-python-scipy-need-blas>
sudo apt-get install gfortran libopenblas-dev liblapack-dev
@bolshoibooze
bolshoibooze / README.md
Created February 25, 2016 14:58 — forked from gajus/README.md

The issue:

..mobile browsers will wait approximately 300ms from the time that you tap the button to fire the click event. The reason for this is that the browser is waiting to see if you are actually performing a double tap.

(from a new defunct https://developers.google.com/mobile/articles/fast_buttons article)

touch-action CSS property can be used to disable this behaviour.

touch-action: manipulation The user agent may consider touches that begin on the element only for the purposes of scrolling and continuous zooming. Any additional behaviors supported by auto are out of scope for this specification.

@bolshoibooze
bolshoibooze / useful_pandas_recipies.py
Last active November 26, 2016 13:46 — forked from why-not/gist:4582705
Pandas recipe. I find pandas indexing counter intuitive, perhaps my intuitions were shaped by many years in the imperative world. I am collecting some recipes to do things quickly in pandas & to jog my memory.
"""quick way to create a data frame to try things out"""
df = pd.DataFrame(np.random.randn(5, 4), columns=['a', 'b', 'c', 'd'])
df['A'] """ will bring out a col """ df.ix[0] """will bring out a row, #0 in this case"""
"""to get an array from a data frame or a series use values, note it is not a function here, so no parans ()"""
point = df_allpoints[df_allpoints['names'] == given_point] # extract one point row.
point = point['desc'].values[0] # get its descriptor in array form.
@bolshoibooze
bolshoibooze / rank_metrics.py
Created December 6, 2015 22:05 — 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
@bolshoibooze
bolshoibooze / Python concave hull ( alpha shape ) .md
Created October 15, 2015 13:12 — forked from hellpanderrr/Python concave hull ( alpha shape ) .md
Concave hull in python using scipy and networkx
from scipy.spatial import Delaunay
import networkx as nx
 
points = [ [0,0],[0,50],[50,50],[50,0],[0,400],[0,450],[50,400],[50,450],[700,300],[700,350],[750,300],[750,350],
          [900,600],[950,650],[950,600],[900,650]
]
def concave(points,alpha_x=150,alpha_y=250):
  points = [(i[0],i[1]) if type(i) <> tuple else i for i in points]
  de = Delaunay(points)
@bolshoibooze
bolshoibooze / note.md
Created October 14, 2015 10:48 — forked from fyears/note.md
how to install scipy numpy matplotlib ipython in virtualenv

if you are using linux, unix, os x:

pip install -U setuptools
pip install -U pip

pip install numpy
pip install scipy
pip install matplotlib
#pip install PySide
@bolshoibooze
bolshoibooze / useful_pandas_snippets.py
Created October 10, 2015 18:21 — forked from bsweger/useful_pandas_snippets.md
Useful Pandas Snippets
#List unique values in a DataFrame column
pd.unique(df.column_name.ravel())
#Convert Series datatype to numeric, getting rid of any non-numeric values
df['col'] = df['col'].astype(str).convert_objects(convert_numeric=True)
#Grab DataFrame rows where column has certain values
valuelist = ['value1', 'value2', 'value3']
df = df[df.column.isin(value_list)]
import urllib2
"""
#Usage:
in a python shell
>> import get_pepperstone_data
>> get_pepperstone_data.run()
# Notes:
1: Selection of pairs is highly opinionated
#One of those handy scripts, see:http://djangotricks.blogspot.co.ke/2013/12/how-to-export-data-as-excel.html
from .models import *
from django.http import *
"""
# Quick 'how-to' guide
# model in question
class Duplicate(models.Model):
@bolshoibooze
bolshoibooze / gist:17adacf7436783faba3c
Created July 13, 2015 06:06
Built-in XML android layouts(typically used in Adaptors)
//simple_list_item_1
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/listItemFirstLineStyle"
android:paddingTop="2dip"
android:paddingBottom="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
//simple_list_item_2