Skip to content

Instantly share code, notes, and snippets.

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidar
davidar / flow.py
Created November 29, 2017 07:50
implementation of http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.46.7829 for plain lambda calculus
#!/usr/bin/env python3
from util import *
from lam import *
from ty import *
def extract(t, *kind):
if type(t) is Lam:
res = extract(t.args[1], *kind)
if Lam in kind: res.add(t)
if Var in kind: res.add(t.args[0])
#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<string.h>
#include<ctype.h>
void handle_args(int argc, char*argv[], char *neg, FILE **fp);
int main(int argc, char*argv[])
{
var jsdom = require("jsdom").jsdom;
var Readability = require("./index").Readability;
var express = require("express");
var app = express();
function removeCommentNodesRecursively(node) {
for (var i = node.childNodes.length - 1; i >= 0; i--) {
var child = node.childNodes[i];
if (child.nodeType === child.COMMENT_NODE) {
var jsdom = require("jsdom").jsdom;
var Readability = require("./index").Readability;
function removeCommentNodesRecursively(node) {
for (var i = node.childNodes.length - 1; i >= 0; i--) {
var child = node.childNodes[i];
if (child.nodeType === child.COMMENT_NODE) {
node.removeChild(child);
} else if (child.nodeType === child.ELEMENT_NODE) {
removeCommentNodesRecursively(child);
#!/usr/bin/env python
import requests
d = requests.get('https://www.reddit.com/r/EarthPorn/top/.json', headers={'User-agent':'IOTD bot'}).json()
for c in d['data']['children']:
src = c['data']['preview']['images'][0]['source']
if src['width'] >= 4000:
print 'Location: ' + src['url'] + '\n'
break
@davidar
davidar / fix-app-icons.sh
Created August 13, 2016 06:03
Fix Chrome App icons in the KDE launcher
#!/bin/bash
# http://superuser.com/a/1068709/55113
for file in ~/.local/share/applications/*.desktop; do
CLASS="`grep '^StartupWMClass=' "$file" | cut -d= -f2`"
if [ -n "$CLASS" ] && ! grep -q xdotool "$file"; then
EXEC="`grep '^Exec=' "$file"`"
EXEC="$EXEC \\&\\& xdotool search --sync --classname $CLASS set_window --class $CLASS"
sed -i~ "s!^Exec=.*!$EXEC!" "$file"
fi
done
@davidar
davidar / gist:89fc971198412a634928
Created February 24, 2016 13:59 — forked from anonymous/gist:7200880
Processing motion blur
/* passable motion blur effect using frame blending
* basically move your 'draw()' into 'sample()', time runs from 0 to 1
* by dave
* http://beesandbombs.tumblr.com
*/
int samplesPerFrame = 32; // more is better but slower. 32 is enough probably
int numFrames = 48;
float shutterAngle = 2.0; // this should be between 0 and 1 realistically. exaggerated for effect here
int[][] result;
[
"abstract.coffee",
"animal.coffee",
"applause.coffee",
"aww.coffee",
"bang-bang.coffee",
"base58.coffee",
"base64.coffee",
"botsnack.coffee",
"coin.coffee",
#!/bin/sh
# https://nixos.org/wiki/How_to_install_nix_in_home_%28on_another_distribution%29#PRoot_Installation
OPT=$HOME/opt
ARCH=x86_64
VER_NIX=nix-1.10-$ARCH-linux
URL_NIX=http://hydra.nixos.org/build/25489771/download/1/$VER_NIX.tar.bz2
mkdir $OPT
mkdir $OPT/bin && cd $OPT/bin && wget http://static.proot.me/proot-$ARCH && chmod u+x proot-$ARCH