Skip to content

Instantly share code, notes, and snippets.

@joewalnes
joewalnes / Makefile
Created November 22, 2011 17:51
NPM without NPM
# To find NPM dependencies, use http://search.npmjs.org/
NPM_DEPS += http://registry.npmjs.org/connect/-/connect-1.5.2.tgz
NPM_DEPS += http://registry.npmjs.org/mime/-/mime-1.2.2.tgz
NPM_DEPS += http://registry.npmjs.org/qs/-/qs-0.2.0.tgz
NPM_DEPS += http://registry.npmjs.org/websocket-server/-/websocket-server-1.4.04.tgz
node_modules: Makefile
@rm -rf $@
@mkdir -p $@
@set -e; for DEP in $(NPM_DEPS); do \
@joewalnes
joewalnes / jar-launcher.md
Last active December 10, 2023 11:58
Make a single file Java jar launcher

This is a little trick to turn an executable Java jar.

It works on all unixy like systems including Linux, MacOS, Cygwin, and Windows Linux subsystem.

Step 1 Start with an all-in-one jar (with entry point and all deps within)

$ ls 
hello.jar
@joewalnes
joewalnes / simple-http-server.kt
Created November 20, 2017 18:58
Minimal embedded HTTP server in Kotlin using Java built in HttpServer
import com.sun.net.httpserver.HttpServer
import java.io.PrintWriter
import java.net.InetSocketAddress
/**
* Minimal embedded HTTP server in Kotlin using Java built in HttpServer
*/
fun main(args: Array<String>) {
HttpServer.create(InetSocketAddress(8080), 0).apply {
@joewalnes
joewalnes / redis.py
Created August 29, 2012 21:35
Microlibrary: Python Redis client
from telnetlib import Telnet
class RedisLiteClient:
"""
Super lightweight no-frills blocking Redis client that doesn't require any additional dependencies.
This is a microlibrary, designed for easy copy'n'paste into a project, where you don't want to
rely on pip/easy_install/etc.
Usage:
@joewalnes
joewalnes / home-yet.py
Created December 14, 2012 03:12
Am I home yet?
#!/usr/bin/env python
"""A tiny script that polls your location on Google Latitude, and updates
the color of a Blink1 LED. http://shop.thingm.com/blink1/
Red = At work
Blue = At home
Green = On my way
Should work on Windows, OS-X and Linux. Requires Python 2.7 or later.
@joewalnes
joewalnes / 1. web.xml
Created December 21, 2012 12:47 — forked from anonymous/MyCustomDecoratorSelector.java
Custom SiteMesh 3 configuration - selecting a decorator based on HttpSession.
<web-app>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.blah.MyCustomSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
</web-app>
https://www.sparkfun.com/products/8688
http://bildr.org/2011/06/temt6000_arduino/
http://playground.arduino.cc/Interfacing/LinuxTTY
http://websocketd.com/
http://smoothiecharts.org/
-- sensor
@joewalnes
joewalnes / .block
Last active January 1, 2017 19:49 — forked from mbostock/.block
Streamgraph
license: gpl-3.0
@joewalnes
joewalnes / go-getter
Last active March 9, 2016 12:58
go-getter: Alternative to "go get" that fixes packages to a version for consistent and repeatable builds.
#!/bin/bash
# Alternative to "go get" that grabs Go packages based on a fixed version.
# Use this to ensure consistent and repeatable builds.
#
# While there are other tools out there that do this, this is really just
# a very small shell script so painless to work into your existing workflow.
#
# Usage:
#
@joewalnes
joewalnes / gist:6996934
Created October 15, 2013 19:04
parser notes
"{{foo bar.baz.bam}}"
OPEN ID(foo) ID(bar) SEP ID(baz) SEP ID(bam) CLOSE
root
TemplateNode(statements)
TemplateNode([statement])
TemplateNode([expression])
TemplateNode([ExpressionNode(expression_contents)])
TemplateNode([ExpressionNode(path param* hash?)])
TemplateNode([ExpressionNode(IdNode.build(path_segments) param*)])
TemplateNode([ExpressionNode(IdNode.build(id) param*)])