Skip to content

Instantly share code, notes, and snippets.

View akesling's full-sized avatar
🐣

Alex Kesling akesling

🐣
View GitHub Profile
" Highlight a word from inside vim. The color is chosen at random but
" persisted across sessions.
" By Kartik Agaram -- http://akkartik.name -- ondemandhighlight@akkartik.com
" Experimenting with an idea by Evan Brooks: https://medium.com/p/3a6db2743a1e
" Discussion: http://www.reddit.com/r/programming/comments/1w76um/coding_in_color
let highlight_file = &viewdir."/highlights"
if !filereadable(highlight_file)
call system("mkdir -p ".&viewdir)
" Highlight a word from inside vim. The color is chosen at random but
" persisted across sessions.
" By Kartik Agaram -- http://akkartik.name -- ondemandhighlight@akkartik.com
" Experimenting with an idea by Evan Brooks: https://medium.com/p/3a6db2743a1e
" Discussion: http://www.reddit.com/r/programming/comments/1w76um/coding_in_color
let highlight_file = &viewdir."/highlights"
if !filereadable(highlight_file)
call system("mkdir -p ".&viewdir)
" Highlight a word from inside vim. The color is chosen at random but
" persisted across sessions.
" By Kartik Agaram -- http://akkartik.name -- ondemandhighlight@akkartik.com
" Experimenting with an idea by Evan Brooks: https://medium.com/p/3a6db2743a1e
" Discussion: http://www.reddit.com/r/programming/comments/1w76um/coding_in_color
let highlight_file = &viewdir."/highlights"
if !filereadable(highlight_file)
call system("mkdir -p ".&viewdir)
/*
* Code for making one potentiometer control 3 LEDs, red, grn and blu, or one tri-color LED
* The program cross-fades from red to grn, grn to blu, and blu to red
* Debugging code assumes Arduino 0004, as it uses Serial.begin()-style functions
* Clay Shirky <clay.shirky@nyu.edu>
*/
// INPUT: Potentiometer should be connected to 5V and GND
int potPin = 3; // Potentiometer output connected to analog pin 3
int potVal = 0; // Variable to store the input from the potentiometer
@akesling
akesling / gist:1793692
Created February 10, 2012 22:49
strace output for Anomaly core dump
execve("./AnomalyWarzoneEarth", ["./AnomalyWarzoneEarth", "2"], [/* 58 vars */]) = 0
[ Process PID=7248 runs in 32 bit mode. ]
brk(0) = 0x9cf4000
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xfffffffff77dc000
readlink("/proc/self/exe", "/media/space/Anomaly/AnomalyWarzoneEarth", 4096) = 40
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("tls/i686/sse2/libX11.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/i686/libX11.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/sse2/libX11.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/libX11.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
var x = 0;
var y = 0;
var ds = 100;
var track = document.getElementById('track');
var viewport = document.getElementById('viewport').getContext('2d');
viewport.drawImage(track,x,y,ds,ds,0,0,500,500);
var pixels = viewport.getImageData();
> document.getElementById("viewport").getContext('2d').getImageData()
Unable to get image data from canvas because the canvas has been tainted by cross-origin data.
Error: SECURITY_ERR: DOM Exception 18
@akesling
akesling / flip_screen.sh
Last active December 11, 2015 00:18
Bash script for flipping Lenovo Thinkpad 230t screen in X (including input).
#!/usr/bin/env bash
if [[ -n "$1" ]] ; then
if [[ *"$1"* == "display screen monitor" ]] ; then
flip_display=true
flip_input=false
elif [[ *"$1"* == "input wacom tablet stylus" ]] ; then
flip_display=false
flip_input=true
else
# Copyright 2013 echoet@echoet.com
import requests
import urllib
import datetime
import time
import os
import json
RUN_ID = int(time.mktime(datetime.datetime.now().timetuple()))
MAX_POSTS_REQUESTED = 1000
@akesling
akesling / preprocess.go
Last active December 15, 2015 21:49 — forked from cdfox/preprocess.go
// For each line of the input file, remove nonalphanumeric characters,
// lowercase all letters, remove stopwords, and write the result to the output
// file. I used the answer here as a template for reading/writing files:
// http://stackoverflow.com/questions/1821811/how-to-read-write-from-to-file/9739903#9739903
package main
import (
"bufio"
"fmt"