Skip to content

Instantly share code, notes, and snippets.

@jellea
jellea / gist:3438926
Created August 23, 2012 17:18
Webcam snapshot on every git commit
#!/bin/bash
#
# This script will make a webcam snapshot every commit. The jpg file will have
# the commit id as the filename.
#
# This script requires imagesnap. Install with: 'brew install imagesnap'
#
# Put this file in the '.git/hooks/' name it 'post-commit' and chmod it by:
# 'chmod +x .git/hooks/post-commit'
#
function ssidChangedCallback()
newSSID = hs.wifi.currentNetwork()
if newSSID ~= lastSSID then
hs.alert.show("Wifi Change - Zeroing Volume", 5)
hs.audiodevice.defaultOutputDevice():setVolume(0)
end
lastSSID = newSSID
end
@jellea
jellea / README.md
Last active June 2, 2020 14:29
Say, a colleague passes you a Figma link, you click it and surprisingly the browser opens, while you have the desktop app installed! You *sigh* and install this script script which adds a question if you want to open web or desktop.

Install

  1. Install Hammerspoon
  2. Install SpoonInstall (unzip and click to install)
  3. Move the contents of appOrWebDialog.lua (question dialog version) or alwaysApp.lua (default to app version) to ~/.hammerspoon/init.lua
  4. Reload Hammerspoon configuration if you already started it.
  5. Set Hammerspoon as default web browser in macOS preferences -> General

Add more apps

  1. Figure out the App Bundle Identifier. Right click "Show Package Contents" on Application and open Contents/Info.plist inside. Find the Bundle Identifier in the plist file.
// inslude the SPI library:
#include <SPI.h>
#include "Pixi.h" // dependency: https://github.com/wolfgangfriedrich/Pixi_demo
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <WiFiUdp.h>
#include <OSCMessage.h> // dependency: https://github.com/CNMAT/OSC
#include <OSCBundle.h>
#include <OSCData.h>
(fn mass->fuel [mass]
(-> (tonumber mass) (/ 3) (math.floor) (- 2)))
(let [file (io.open "1.data" "r")
file-contents (file:read "*a")
mods (string.gmatch file-contents "%d+")]
(var total-fuel 0)
(each [mass mods]
(let [fuel (mass->fuel mass)]
(set total-fuel (+ total-fuel fuel))
(fn mass->fuel [mass]
(-> (tonumber mass) (/ 3) (math.floor) (- 2)))
(let [file (io.open "1.data" "r")
file-contents (file:read "*a")
mods (string.gmatch file-contents "%d+")]
(var total-fuel 0)
(each [mass mods]
(let [fuel (mass->fuel mass)]
(set total-fuel (+ total-fuel fuel))
@jellea
jellea / advent2019-1.fnl
Created December 1, 2019 12:08
Advent Of Code Puzzle 1
(fn mass->fuel [mass]
(-> (tonumber mass) (/ 3) (math.floor) (- 2)))
(let [file (io.open "1.data" "r")
file-contents (file:read "*a")
mods (string.gmatch file-contents "%d+")]
(var total-fuel 0)
(each [mass mods]
(let [fuel (mass->fuel mass)]
(set total-fuel (+ total-fuel fuel))
@jellea
jellea / div.lua
Last active May 4, 2019 21:38
modulo matrix sequencing
-- div
-- modulo matrix sequencing
-- with variable divisions
-- by lijnenspel
--
-- grid needed
-- x = tracks, y = division
-- add samples via param menu
--
-- enc 2
@jellea
jellea / penti.ino
Created January 13, 2019 17:34
Penti chorded keyboard emulation for one half of the Let's Split 40% mech keyboard
#include <Keyboard.h>
#define ROW_NUM 5
#define COL_NUM 6
byte row_pins[5] = { 4, 6, 7, 8, 9 };
byte col_pins[6] = { 10, 16, 14, 15, 18, 19};
byte fingers[5][2] = {{4, 2},{3, 2}, {2, 2}, {1, 2}, {0, 4}}; // [col, row]
char finger_keys[5] = {'A', 'B', 'C', 'D', 'E'};
@jellea
jellea / gist:6510897
Last active August 28, 2018 05:53
Node.js Forever rcng script for FreeBSD
#!/bin/sh
# PROVIDE: forever
# REQUIRE: NETWORKING SERVERS DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# Taken from http://habrahabr.ru/post/137857/
. /etc/rc.subr