Skip to content

Instantly share code, notes, and snippets.

View fhemberger's full-sized avatar

Frederic Hemberger fhemberger

View GitHub Profile
@fhemberger
fhemberger / backup-uberspace.exclude
Created October 17, 2013 08:52
How to easily backup your Uberspace (http://uberspace.de) account with rsync
.gem
.npm
cgi-bin
fcgi-bin
html
lib
man
share
tmp
**/node_modules
@fhemberger
fhemberger / init.lua
Created November 21, 2021 20:12
Hammerspoon: Switch layout when USB keyboard is plugged in
local usbLogger = hs.logger.new('usb', 'debug')
function configureKeyboard(data)
-- Uncomment the "usbLogger" line below, plug in the USB keyboard and update the USB vendor and product ID
local isKeyboardAffected = data.vendorID == 9610 and data.productID == 89
-- usbLogger.df("eventType %s, pname %s, vname %s, vId %s, pId %s, keyboardAffected %s", data.eventType, data.productName, data.vendorName, data.vendorID, data.productID, isKeyboardAffected)
if isKeyboardAffected and data.eventType == "added" then
hs.keycodes.setLayout("U.S.")
end
if isKeyboardAffected and data.eventType == "removed" then
@fhemberger
fhemberger / README.md
Last active February 10, 2021 21:37
Node.js: Create checksums for npm's 'postinstall' actions

Node.js: Create checksums for npm's 'postinstall' actions

After watching Patrick Debois' talk from DeliveryConf »How Secure Is Your Build / Server?«, I tried to get at least a rough idea if postinstall steps where running at all and if they do the same things after a package update.

So I wrote a little proof of concept that will:

  • Create a Dockerfile, using package.json and package-lock.json from a Node.js project in the current directory
  • Install all its dependencies inside the Docker container first, without running any postinstall steps, then do the same with running the scripts.
  • Reading the diff of those steps using Docker's image layers
  • And calculate a checksum of those changes.
@fhemberger
fhemberger / index.html
Last active January 22, 2018 06:05
Beispielcode für "Client-Server-Kommunikation mit Socket.io" (Webkrauts-Adventskalender 2012)
<!DOCTYPE html>
<html>
<head>
<title>Socket.io Test</title>
<!-- Dieses Script wird von Socket.io automatisch zu Verfügung gestellt -->
<script src="/socket.io/socket.io.js"></script>
<script>
// Mit dem Socket.io-Server verbinden
@fhemberger
fhemberger / README.md
Last active December 27, 2015 10:59
Get rid of content farms and W3Schools in search results.

I'm using the git pr command from the git-extras toolset to check out a local copy of a PR.

To rebase the PR again, I wrote a little script, which needs to be run in the PR's branch:

#!/usr/bin/env bash

branch=$(git symbolic-ref HEAD --short)

git rebase master
@fhemberger
fhemberger / gist:3974360
Created October 29, 2012 15:57
Pubsub with jQuery $.Callbacks
var topics = {};
$.Topic = function( id ) {
if ( !topics[ id ] ) {
var callbacks = jQuery.Callbacks();
topics[ id ] = {
publish: callbacks.fire,
subscribe: callbacks.add,
unsubscribe: callbacks.remove
};
@fhemberger
fhemberger / gist:2665360
Created May 12, 2012 09:07
Loose comparison with == in JavaScript
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial, sans-serif; }
th, td {
text-align: center;
padding: 10px;
}
th { background-color: #f0f0f0; }
@fhemberger
fhemberger / gist:1682734
Created January 26, 2012 13:24
Das Problemlöser-Manifest (German translation of the Solvers' Manifesto)

Das Problemlöser-Manifest

von Nuno Simaria | 13. Februar 2011

Wir, die Programmierer, die gelernt haben Schrift, Form und Farben zu kombinieren, damit ihr euren Kunden ein professionell aussehendes Interface anbieten könnt. Wir, die Designer, die Videoschnitt und Tonmischung gelernt haben, damit ihr einen Werbespot für eure Firma habt. Wir, die AV-Techniker, die gelernt haben eine Website zu bauen, damit euer Trailer im Internet erscheint, ohne dass ihr dafür einen Cent bezahlen müsst.

Wir sind hier.

Wir sind keine Programmierer. Sie müssen keine Banner entwickeln auf Basis einer Zeichnung eures Neffen. Wir sind keine Designer. Sie müssen nicht wissen, wie die Post-Produktion eines Films funktioniert. Wir sind keine AV-Techniker. Sie müssen sich keine Gedanken darüber machen, euer Formular mit 30 Eingabefeldern mittels JavaScript zu validieren, damit ihr euren Film online verkaufen könnt.

Von uns gibt es viele.