Skip to content

Instantly share code, notes, and snippets.

@jarmitage
jarmitage / gist:331f69692e90bd39b4a2
Created May 17, 2015 11:34
Socket.io functions
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
// sending to all clients in 'game' room(channel) except sender
for (int r = 0; r < graphRows; r++)
{
for (int c = 0; c < graphCols; c++)
{
int current = (graphCols - 1 - c) * graphRows + r;
}
}
@jarmitage
jarmitage / gist:a5b33dbdd9d7605757f9
Last active August 29, 2015 14:25
R: two y axis plot
plot (V1, V2,
type = "p",
col = "red",
cex = .2,
xlab = "Force (N)",
ylab = "Raw",
ylim = c(0,4096))
grid (col = "lightgray", lty = "dotted", lwd = par("lwd"), equilogs = TRUE)
par (new = TRUE)
plot (V1, V3,
#!/bin/bash
# Split and convert the PDF with ImageMagick convert
convert -density 300 input.pdf -type Grayscale -compress lzw -background white +matte -depth 32 page_%05d.tif
# OCR the pages with Tesseract
for i in page_*.tif; do echo $i; tesseract $i $(basename $i .tif) pdf; done
@jarmitage
jarmitage / himawari-8.py
Last active March 5, 2018 09:21
Himawari-8 Wallpaper Bot: Fresh images of the whole Earth from space, every 10 minutes
import urllib
import datetime as dt
import pytz
from PIL import Image
import numpy as np
import subprocess
import socket
import os
dir = '/FULL/PATH/TO/SCRIPT/DIR'
@jarmitage
jarmitage / dynamic-video-load-test.html
Last active March 24, 2016 17:34
Loading <video> into <a-entity> dynamically
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>'Dominoes' prototype</title>
<meta name="description" content="Hello, World! • A-Frame">
<script src="https://aframe.io/releases/0.1.2/aframe.js"></script>
</head>
<body>
<a-scene stats="true" id="scene">
@jarmitage
jarmitage / scrivx-to-org.py
Created July 13, 2016 14:20
Convert Scrivener .scrivx file to Emacs org-mode file
import xml.etree.ElementTree as ET
import os
from os.path import join
import io
# 1. Extract Docs and .scrivx from Scrivener using 'Open Package Contents'
# 2. Convert Docs from .rtf to .txt using GNU unrtf and put .txt files in folder called txt
# 3. Run script
dir = 'path/to/scriv'
@jarmitage
jarmitage / startup.scd
Created April 12, 2017 22:58
SuperDirt Startup for Multichannel Audio Output

( // http://doc.sccode.org/Classes/ServerOptions.html

s.options.numBuffers = 1024 * 16; // increase this if you need to load more samples s.options.memSize = 8192 * 16; // increase this if you get "alloc failed" messages s.options.maxNodes = 1024 * 32; // increase this if you are getting drop outs and the message "too many nodes"

// Default // s.options.numOutputBusChannels = 2; // set this to your hardware output channel size, if necessary // s.options.numInputBusChannels = 2; // set this to your hardware output channel size, if necessary