Skip to content

Instantly share code, notes, and snippets.

@endolith
endolith / Has weird right-to-left characters.txt
Last active June 1, 2024 10:58
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶
@mfoliveira
mfoliveira / Fibonacci.cpp
Created May 5, 2011 20:07
Yield in C/C++ using Macros
#include "yield.h"
class Fibonacci {
protected:
/* Yield's internal */
void *YIELD_POINTER;
/* Fibonacci terms */
@andrix
andrix / iunzip.py
Created July 4, 2011 13:33
python iterable unzip
import itertools
from operator import itemgetter
def iunzip(iterable):
"""Iunzip is the same as zip(*iter) but returns iterators, instead of
expand the iterator. Mostly used for large sequence"""
_tmp, iterable = itertools.tee(iterable, 2)
iters = itertools.tee(iterable, len(_tmp.next()))
return (itertools.imap(itemgetter(i), it) for i, it in enumerate(iters))
@xim
xim / cluster_example.py
Created October 11, 2011 20:19
Clustering K-Means by euclidian distance, yay!
import sys
import numpy
from nltk.cluster import KMeansClusterer, GAAClusterer, euclidean_distance
import nltk.corpus
from nltk import decorators
import nltk.stem
stemmer_func = nltk.stem.EnglishStemmer().stem
stopwords = set(nltk.corpus.stopwords.words('english'))
@tillahoffmann
tillahoffmann / performancemodule.c
Created January 17, 2012 14:53
A quick implementation of a trapezoidal convolution in C.
#include <Python.h>
//Normally #include "arrayobject.h" should be sufficient. I need to fix my includes.
#include "/Library/Frameworks/Python.framework/Versions/7.2/lib/python2.7/site-packages/numpy/core/include/numpy/arrayobject.h"
/*
* Convolution method.
*/
static PyObject* convolve(PyObject* self, PyObject* args)
{
PyArrayObject *vec1, *vec2, *conv; //The python object proxies
@hfossli
hfossli / gist:7562257
Last active June 27, 2018 04:56
A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#!/bin/bash
# Created by Håvard Fossli <hfossli@gmail.com> in 2013
# This is free and unencumbered software released into the public domain.
# For more information, please refer to <http://unlicense.org/>
#
# Description
# A bash script for fetching all branches and tags of a git project as snapshots into separate folders
#
# Keywords
@vjpr
vjpr / README.md
Last active June 27, 2022 10:01
RPC for Chrome Packaged App to allow communication between sandbox and privileged environment

ChromeRPC

I will eventually turn this into a bower module when I have time with tests and the whole shebang.

Usage

background.html

--use like eval(HRANDKEY, 2, key_for_set_with_keys, key_for_hash_with_keys)
local randkey = redis.call('srandmember', KEYS[1])
local val = redis.call('hget', KEYS[2], randkey)
return val
@manujrastogi
manujrastogi / cognito-developer-authenticated-client-example.py
Created August 8, 2016 12:15 — forked from dkarchmer/cognito-developer-authenticated-client-example.py
django-boto3-cognito: AWS' Cognito Developer Authenticated Identities Authflow using Django/Python/Boto3 (For building stand-alone clients)
__author__ = 'dkarchmer'
'''
This script emulates a stand-alone Python based client. It relies on Boto3 to access AWS, but
requires your Django server to have an API for your user to access Cognito based credentials
Because of Cognito, the client (this script) will only get temporary AWS credentials associated
to your user and only your user, and based on whatever you configure your AIM Policy to be.
Most Cognito examples demonstrate how to use Cognito for Mobile Apps, so this scripts demonstrate
how to create a stand-alone Python script but operating similarly to these apps.
@tokestermw
tokestermw / self_attention.py
Last active June 29, 2022 05:39
Implementation of self-attention in the paper "Attention Is All You Need" in TensorFlow.
"""Example TensorFlow code for Self-Attention mechanism.
Refs:
Attention Is All You Need
Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N. Gomez, Lukasz Kaiser, Illia Polosukhin
https://arxiv.org/abs/1706.03762
Transformer: A Novel Neural Network Architecture for Language Understanding
https://research.googleblog.com/2017/08/transformer-novel-neural-network.html