Skip to content

Instantly share code, notes, and snippets.

View urigoren's full-sized avatar

Uri Goren urigoren

View GitHub Profile
import numpy as np
from scipy import sparse
import collections
"""
#SPARK Co-Occurence Matrix
#Format: (vertex, vertex) : count
import json, operator, itertools
def cooccur_matrix(srcHdfs, product2vertex):
ret = sc.textFile(srcHdfs)\
<?php
define('SLACK_WEBHOOK', 'https://hooks.slack.com/services/xxx/yyy/zzz');
define('TELEGRAM_BOT_TOKEN', '...');
define('TELEGRAM_CHAT_ID', '12345');
function slack($txt) {
$msg = array('text' => $txt);
$c = curl_init(SLACK_WEBHOOK);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
curl_setopt($c, CURLOPT_SSL_VERIFYPEER, false);
from itertools import combinations
from functools import reduce
from pprint import pprint as pr
def all_arrangements(k):
m=k*(k+1)/2
m_bits_on=set([tuple(reduce(lambda x,y:x[:y]+[1]+x[y+1:],c,[0]*(2*m+1))) for c in combinations(range(2*m+1),m)])
return set([tuple(sorted(filter(lambda i:i>0,reduce(lambda x,y: x+[y] if y==0 else x[:-1]+[x[-1]+1,],p,[0])))) for p in m_bits_on])
def move(t,n=1):