Skip to content

Instantly share code, notes, and snippets.

"""
A python script to notify on hackernews changes using pySnarl (win32)
author: joebo
I found myself checking HN throughout the day while working and would
spend a few minutes each time skimming to see if there was anything new.
This automated the task for me and I thought it might be useful to share.
It's meant to be quick and dirty but works.
get pysnarl from http://code.google.com/p/pysnarl/
(class +Person +Entity)
(rel nm (+Need +Sn +Idx +String)) # Name
(rel pa (+Joint) kids (+Man)) # Father
(rel ma (+Joint) kids (+Woman)) # Mother
(rel mate (+Joint) mate (+Person)) # Partner
(rel job (+Ref +String)) # Occupation
(rel dat (+Ref +Date)) # born
(rel fin (+Ref +Date)) # died
(rel txt (+String)) # Info
fbpad-256,
use=linux, U8#0,
colors#256,
pairs#32767,
setab=\E[%?%p1%{8}%<%t4%p1%d%e%p1%{16}%<%t10%p1%{8}%-%d%e48;5;%p1%d%;m,
setaf=\E[%?%p1%{8}%<%t3%p1%d%e%p1%{16}%<%t9%p1%{8}%-%d%e38;5;%p1%d%;m,
@joebo
joebo / gist:6813083
Last active December 24, 2015 14:29
(de makeRacer (Race Line)
(let
(Parts (mapcar 'pack (split (chop Line) " "))
Place (format (car Parts))
Racer (car (nth Parts 3))
IsRacerID (= (chop "RUS") (head 3 (chop Racer)))
Fname (car (nth Parts 4))
LName (car (nth Parts 5))
Name (uppc (pack Fname " " LName) ))
(if (and Place IsRacerID)
@joebo
joebo / gist:6857220
Last active December 24, 2015 20:19
require 'data/jdb'
NB. Borrowed from Dan Bron's solution
'GROUPS POINTS' =. <"_1 |: ".;._2 noun define
0 ; 0
5 ; 3 2 1 NB. 5 <= #riders <= 10
11 ; 7 5 4 3 2 1 NB. 11 <= #riders <= 20
21 ; 8 6 5 4 3 2 1 NB. 21 <= #riders <= 49
50 ; 10 8 7 6 5 4 3 2 1 NB. 50 or more #riders
)
NB. Parpool.ijs
NB. ===================================
NB. Attempt to make a J parpool
NB. ----------------------------
NB. Todo's:
NB. - Spin up tasks
NB. - Use net/clientserver's jsss/jssc for workers resp master
NB. - Figure out how to automatically find data from sentence and send to each worker if needed
NB. - keep old data? or discard after return?
NB. - exploit rank (IRS) write parfor / blockprocessing
NB. Signal Processing in J
NB. ========================
NB. Mainly written as exercise, so no guarantees
NB. cocurrent <'jimproc'
NB. Assumptions : 1-cell = 1 sample of dimensionsionality $ samp
NB. set of samples in 2-cell
NB. Monad mean y
NB. Mean of data samples in y
mean =: +/ % #
{"nbformat": 4, "nbformat_minor": 0, "metadata": {"language_info": {"pygments_lexer": "ipython3", "name": "python", "mimetype": "text/x-python", "version": "3.3.5", "nbconvert_exporter": "python", "codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py"}, "kernelspec": {"language": "python", "name": "python3", "display_name": "Python 3"}}, "cells": [{"execution_count": 1, "source": "from IPython import parallel", "outputs": [], "metadata": {"collapsed": false, "trusted": true}, "cell_type": "code"}, {"execution_count": 2, "source": "rc = parallel.Client()\ndv = rc[:]", "outputs": [], "metadata": {"collapsed": false, "trusted": true}, "cell_type": "code"}, {"execution_count": 24, "source": "with rc[:].sync_imports():\n import time\n import functools\n from ctypes import WinDLL\n from ctypes import pointer\n from ctypes import c_int\n import operator", "outputs": [{"output_type": "stream", "text": "importing time on engine(s)\nimporting functools on engine(s)\nimporting Wi
@joebo
joebo / scoring
Last active August 29, 2015 14:22
tbl=:3 4 $ 0; 2; 'A'; 'B'; 3; 1; 'B'; 'C'; 1; 1; 'C'; 'A'
init=:((~. @: , @: (2&}."1)) ; (0 #~ #)) tbl
NB. given a table of team scores, score a game and return new team score
score =: 4 : 0
'allteams scores'=. > y
diff =. - / (> @: (2&{.)) > x
teams=. 2&}. > x
allteamIdx=. allteams i. teams
arr=:(i.!10) A. i. 10
tonum=: ". @: (,/"1 @: ":"0)
a=: tonum (5{."1 arr)
b=: tonum (5}."1 arr)
mindiff=: (<./) (#~ >&0) a-b
idx=:(a-b) i. 247
Note "output"
idx { a