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 / 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">
symbol date price
MSFT Jan 1 2000 39.81
MSFT Feb 1 2000 36.35
MSFT Mar 1 2000 43.22
MSFT Apr 1 2000 28.37
MSFT May 1 2000 25.45
MSFT Jun 1 2000 32.54
MSFT Jul 1 2000 28.4
MSFT Aug 1 2000 28.4
MSFT Sep 1 2000 24.53
index a b c d e f g h
0 1.0000 0.0624 -0.0624 -1.0000 0.0215 0.0215 -1.0000 -1.0000
1 -0.9579 -0.9861 -0.6310 -0.8100 -0.9094 -0.6415 -0.9466 -0.9265
2 -0.9933 -0.5758 0.3697 -0.5160 0.8868 -0.2780 -0.9969 0.1435
3 -0.8254 -0.8311 0.4734 0.6095 0.3770 0.6794 -0.7360 -0.9298
4 -0.9896 0.5811 0.2703 -0.5235 0.9200 -0.6865 -0.7522 -0.9121
5 0.8905 0.9535 0.9544 0.8007 0.6632 0.6331 0.7218 0.7382
6 0.5355 -0.9440 -0.6908 0.6977 0.1048 0.4740 0.5587 -0.7965
7 -0.5221 -0.6041 0.9833 0.9924 -0.8704 -0.9585 -1.0000 -0.9999
8 0.3689 -0.4448 0.4905 0.4718 -0.9603 -0.0743 -0.3943 1.0000
@jarmitage
jarmitage / Stream.hs
Last active December 26, 2017 23:38
Turning a TidalCycles pattern into JSON
-- Added to https://github.com/tidalcycles/Tidal/blob/1d05c6119aba8c7547bbf1512ce1f901e38e1d6c/Sound/Tidal/Stream.hs
import qualified Data.Aeson as A
-- ...
instance A.ToJSON Value where
toJSON (VS s) = A.toJSON s
toJSON (VF d) = A.toJSON d
toJSON (VI i) = A.toJSON i
@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'