Skip to content

Instantly share code, notes, and snippets.

// Sensors begin here
var __device_sensors_service_entry = {
"name": null,
"version": null,
"proto": __device_sensors,
"descriptor": __device_sensors_descriptor,
"providers": [{
"descriptor": __sp_sensors_descriptor,
"instance": __sp_sensors_instance
}]
@ganzuul
ganzuul / superquerio
Last active December 14, 2015 18:38
Get a message from an UDP-listener, send it onwards with socket.io
var express = require('express');
var io = require('socket.io');
var server = require('http');
var dgram = require("dgram");
var app = express()
, server = require('http').createServer(app)
, io = io.listen(server)
, server2 = dgram.createSocket("udp4");
app.use(express.static(__dirname + '/public'));
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile 'com.tinkerpop.blueprints:blueprints-neo4j-graph:2.6.0',
'org.neo4j:neo4j-lucene-index:2.1.8',
/*
Rotary Encoder - Polling Example
The circuit:
* encoder pin A to Arduino pin 2
* encoder pin B to Arduino pin 3
* encoder ground pin to ground (GND)
*/
#include <Arduino.h>
#include <U8g2lib.h>
@ganzuul
ganzuul / a.h
Created July 20, 2017 20:51
WIP UI for setting a large number e.g. a frequency using only clockwise and CCW movements of a rotary encoder. ESP8266 with Arduino SDK.
struct TwoNibbles
{
byte v1:4;
byte v2:4;
};
union Nibble
{
TwoNibbles nibble;
byte Nibble[sizeof(TwoNibbles)];
@ganzuul
ganzuul / regis.sh
Last active September 1, 2018 22:24
ReGIS pm3d bash script
#!/bin/bash
#
# For reference:
# VT330/VT340 Programmer Reference Manual
# Volume 2: Graphics Programming
#
#
# This script plots vector graphics in the terminal emulator mlterm when mlterm is compiled with ./configure --with-tools
# The graph is generated by gnuplot compiled with ./configure --with-regis
#
@ganzuul
ganzuul / gottaReadEmAll.kt
Last active November 21, 2018 19:29
Takes two directory names as arguments, iterates through the files in those directories, adds their content to lists of lists and prints what it has found.
import java.io.File
var file: MutableList<List<String>> = ArrayList() //list of lists
var file2: MutableList<List<String>> = ArrayList() //list of lists
fun main(args: Array<String>) {
file = readDir(args[0])
file2 = readDir(args[1])
for (e in file) println(e)
@ganzuul
ganzuul / kotgombinator.kt
Last active November 25, 2018 21:59
Multiplies config files using a range of lines
// Usage: java kotgombinate.jar Dir1 Dir2 Dir3 startOfRange endOfRange
// Output: Dir1(A, B) * Dir2(C, D) = Dir3 (A_C, A_D, B_C, B_D)
// Range is line-numbers so files in Dir1 and Dir2 need to correspond 1-to-1
import java.io.File
import kotlin.system.exitProcess
data class Butt(var fileContents: MutableList<List<String>>, var fileName: MutableList<String>)
var dir1 = Butt(ArrayList(), ArrayList())
var dir2 = Butt(ArrayList(), ArrayList())
var dir3 = Butt(ArrayList(), ArrayList())
@ganzuul
ganzuul / linkshere.r
Last active November 10, 2019 19:53
en.wikipedia.org/wiki/Special:WhatLinksHere to R via REST API
#install.packages("httr") #install.packages("jsonlite") #install.packages("tidyverse")
#install.packages("stringr") #install.packages("furrr") #install.packages("igraph")
require(httr)
require(jsonlite)
require(tidyverse)
require(stringr)
#require(furrr) #require(igraph)
url_base <- "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=linkshere&lhlimit=500"
articles <- c("Maximal and minimal elements", "Maxima and minima")
@ganzuul
ganzuul / fetch.r
Last active November 3, 2019 12:52
edges case is broken
#install.packages("httr")
#install.packages("jsonlite")
#install.packages("tidyverse")
#install.packages("stringr")
require(httr)
require(jsonlite)
require(tidyverse)
require(stringr)
base <- "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=linkshere&lhlimit=500"