Skip to content

Instantly share code, notes, and snippets.

@ssp
ssp / turn off spindumps
Created March 7, 2010 15:35
Turn off spindump in MacOS X. This can improve the performance of the whole system in some situations.
launchctl unload -w /System/Library/LaunchDaemons/com.apple.spindump.plist
@ssp
ssp / README.md
Last active May 22, 2023 21:40
senec-to-influx

Senec to Influx

Extract values from Senec JSON with string-hex-floats and push them to InfluxDB

Run example

SENEC_URL=http://senec.local/lala.cgi INFLUX_URL=https://influx.yourserver.net/ INFLUX_ORG=your_org INFLUX_TOKEN=your_token ./senec-to-influx.py
@ssp
ssp / git-extract-file.markdown
Created January 23, 2012 13:21
Extract a single file from a git repository

How to extract a single file with its history from a git repository

These steps show two less common interactions with git to extract a single file which is inside a subfolder from a git repository. These steps essentially reduce the repository to just the desired files and should performed on a copy of the original repository (1.).

First the repository is reduced to just the subfolder containing the files in question using git filter-branch --subdirectory-filter (2.) which is a useful step by itself if just a subfolder needs to be extracted. This step moves the desired files to the top level of the repository.

Finally all remaining files are listed using git ls, the files to keep are removed from that using grep -v and the resulting list is passed to git rm which is invoked by git filter-branch --index-filter (3.). A bit convoluted but it does the trick.

1. copy the repository to extract the file from and go to the desired branch

@ssp
ssp / nibtoxib.sh
Created December 11, 2009 11:57
nibtoxib
#! /bin/sh
find . -name "*.nib" -type d | awk '{sub(/.nib/,"");print}' | xargs -I % ibtool --write %.xib --upgrade %.nib
@ssp
ssp / flv-to-mp4.sh
Last active July 7, 2022 17:54
Command to repackage a MP4 video from a FLV container to a MP4 container.
#!/usr/bin/env sh
# Stored at: https://gist.github.com/4452136
# Assumes the given path points to a FLV file with MP4 video.
# Use ffmpeg to repackage the file.
ffmpeg -i "$1" -acodec copy -vcodec copy "$1".mp4
# old version:
# Not used anymore as VLC seems to have a bug that creates broken
@ssp
ssp / xmlpaths.xsl
Last active June 29, 2022 02:15
XSL to determine all tag paths in an XML file.
<?xml version="1.0"?>
<!--
Stylesheet to list all tag-name paths in an XML file, including attributes.
2013 Sven-S. Porst <porst@sub.uni-goettingen.de>
-->
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text" />
@ssp
ssp / output.js
Created September 21, 2021 23:47
Brute force solution to a quiz-formula given by symbols
{ a: 7, b: 2, c: 5, d: 4, e: 1, f: 3, g: 8, h: 6 }
@ssp
ssp / key.xsl
Created September 19, 2013 12:39
An attempt to understand xsl:key and the key() function and why it is not possible to insert the keys into the document itself.
<?xml version="1.0" encoding="UTF-8"?>
<!--
Attempt to use xsl:key on data not stored in the document itself.
We _can_ load external XML into a variable using document() and use
the key() function on that.
We _cannot_ include the XML into our stylesheet and use the key()
function on that.
@ssp
ssp / Handbrake conversion
Created June 10, 2010 21:59
Convert DV to mp4 and ogv using Handbrake CLI
HandBrakeCLI --input input.dv --output output.mp4 --format mp4 --encoder x264 --x264opts ref=2:bframes=2:subq=6:mixed-refs=0:weightb=0:8x8dct=0:trellis=0 --optimize --quality 0.5 --audio 1 --aencoder ca_aac --ab 128 --arate 32 --aname English
HandBrakeCLI-0.9.3 --input input.dv --output result.ogv --format ogm --encoder theora --optimize --quality 0.6 --audio 1 --aencoder vorbis --ab 128 --arate 32 --aname English
# Commands to convert DV (or any) video to MP4 and OGM using the CLI version of HandBrake.
# The MP4 result it simple-minded enough to be played by QuickTime.
# The audio bitrate is picked to match the 32kHz audio of some DV video.
# You need the 0.9.3 version for the ogg files, as that feature was removed in 0.9.4.
@ssp
ssp / xibtonib.sh
Created December 11, 2009 11:58
xibtonib
#! /bin/sh
find . -name "*.xib" -type f | awk '{sub(/.xib/,"");print}' | xargs -I % ibtool --compile %.nib %.xib