Skip to content

Instantly share code, notes, and snippets.

View alexeygrigorev's full-sized avatar
:octocat:
Githubbing

Alexey Grigorev alexeygrigorev

:octocat:
Githubbing
View GitHub Profile
@akihiro4chawon
akihiro4chawon / Main.groovy
Created July 4, 2011 08:44
Memoization with Groovy Custom AST Tranformation
package akihiro4chawon
class Main {
@Memoize
def fib(a) {
//a <= 1 ? a : fib(a - 2) + fib(a - 1)
if (a <= 1) return a
else return fib(a - 2) + fib(a - 1)
}
@mblondel
mblondel / kmeans.py
Last active April 21, 2024 13:41
Fuzzy K-means and K-medians
# Copyright Mathieu Blondel December 2011
# License: BSD 3 clause
import numpy as np
import pylab as pl
from sklearn.base import BaseEstimator
from sklearn.utils import check_random_state
from sklearn.cluster import MiniBatchKMeans
from sklearn.cluster import KMeans as KMeansGood
@hanleybrand
hanleybrand / java_String_hashcode.py
Last active November 20, 2022 18:09
python function that produces the same result as java's String.hashCode() found at http://garage.pimentech.net/libcommonPython_src_python_libcommon_javastringhashcode/
def java_string_hashcode(s):
h = 0
for c in s:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000
@damianavila
damianavila / remove_output.py
Created April 3, 2013 22:05
Remove output from IPython notebook from the command line (dev version 1.0)
"""
Usage: python remove_output.py notebook.ipynb [ > without_output.ipynb ]
Modified from remove_output by Minrk
"""
import sys
import io
import os
from IPython.nbformat.current import read, write
@darribas
darribas / panel_FE.ipynb
Last active January 10, 2021 18:41
Fixed-Effects panel OLS
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@lmarkus
lmarkus / README.MD
Last active May 21, 2024 02:50
Extracting / Exporting custom emoji from Slack

Extracting Emoji From Slack!

Slack doesn't provide an easy way to extract custom emoji from a team. (Especially teams with thousands of custom emoji) This Gist walks you through a relatively simple approach to get your emoji out.

If you're an admin of your own team, you can get the list of emoji directly using this API: https://api.slack.com/methods/emoji.list. Once you have it, skip to Step 3

HOWEVER! This gist is intended for people who don't have admin access, nor access tokens for using that list.

Follow along...

@chenjianjx
chenjianjx / start-celery-for-dev.py
Created March 10, 2016 10:45
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os
@ld86
ld86 / spirals.ipynb
Created June 30, 2016 12:12
How to generate spirals dataset.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sswt
sswt / eval_map
Created January 23, 2017 19:59
Outbrain map@12 evaluation
def eval_map(yhat, dtrain):
inds = (-yhat).argsort(kind='mergesort')
X = np.vstack([dtrain.data['display_id'], dtrain.get_label()]).T
X = X[inds[X[inds, 0].argsort(kind='mergesort')]]
y_ind = np.where(X[:, 1] == 1)[0]
y_pr = np.unique(X[:, 0], return_index=True)[1]
return 'map@12_ob', np.mean(1 / (y_ind - y_pr + 1)), True
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.