Skip to content

Instantly share code, notes, and snippets.

View fhemberger's full-sized avatar

Frederic Hemberger fhemberger

View GitHub Profile
@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.

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 / talks.md
Last active August 29, 2015 14:05
FrOSCon 2014 Cologne.js JavaScript track
@fhemberger
fhemberger / README.md
Last active December 27, 2015 10:59
Get rid of content farms and W3Schools in search results.
@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 / 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 / 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; }