Skip to content

Instantly share code, notes, and snippets.

View ctavan's full-sized avatar

Christoph Tavan ctavan

View GitHub Profile
@ctavan
ctavan / Reduce to 150 dpi average quality - STANDARD COMPRESSION.qfilter
Created November 15, 2022 13:26
Reduce to 150 dpi average quality - STANDARD COMPRESSION.qfilter
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Domains</key>
<dict>
<key>Applications</key>
<true/>
<key>Printing</key>
<true/>
@ctavan
ctavan / browser-build.diff
Last active December 2, 2021 22:07
uuid browser build without IE support
diff -ur dist-node-10/esm-browser/md5.js dist/esm-browser/md5.js
--- dist-node-10/esm-browser/md5.js 2021-12-02 13:15:02.000000000 +0100
+++ dist/esm-browser/md5.js 2021-12-02 22:48:16.000000000 +0100
@@ -20,11 +20,11 @@
*/
function md5(bytes) {
if (typeof bytes === 'string') {
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
@ctavan
ctavan / github.md
Last active February 18, 2021 02:22
Git & Github

Git & Github

  • Consider using these useful git shortcuts.
  • Repositories:
    • All developers clone the repos from the github organization, never create forks into your private accounts.
  • Branches:
    • Understand git rebase.
    • Development is done in branches.
    • Name branches starting with the JIRA issue followed by an all-lowercase dash-separated descriptive name, e.g: ID-7-shoping-cart-prototype
  • Always rebase onto origin/master before merging into master, we want to get a clean master history which looks like this: branches
@ctavan
ctavan / parse_broken_csv.py
Created October 12, 2012 11:46
Decode CSV file with broken encodings.
#!/usr/bin/env python
"""
This script parses a tab-separated CSV-file where fields may contain strings
with broken encodings. Each line of the CSV-file is parsed into a dictionary.
"""
import csv
import json
import sys

Keybase proof

I hereby claim:

  • I am ctavan on github.
  • I am ctavan (https://keybase.io/ctavan) on keybase.
  • I have a public key ASABxq9Uz6fewrw8b90TiKtxRootHXGuqHkvFd2QTNao2go

To claim this, I am signing this object:

commit ********b2a5c668b54348d0f3f891ddc58ef9f8
Author: Christoph Tavan <christoph@contentpass.de>
Date: Mon Mar 11 16:53:10 2019 +0100
Fix sorting of error codes
Apparently with node 11 there's a subtle change in how array sorting
compare function return values are interpreted. According to the spec
the return value of 0 will not change the sorting. A negative return
value will sort the element below and must be used in this case.
@ctavan
ctavan / mutatable.jsx
Created January 17, 2017 12:13
mutatable react HOC
import hoistNonReactStatic from 'hoist-non-react-statics';
import React from 'react';
function getDisplayName(WrappedComponent) {
return WrappedComponent.displayName || WrappedComponent.name || 'Component';
}
// See: https://facebook.github.io/react/docs/higher-order-components.html
export default function mutatable({ mutationName = 'mutate' } = {}) {
return (SourceComponent) => {
@ctavan
ctavan / array-sort-node-10-11.js
Created March 11, 2019 21:24
Array Sort Behavior Node 10 and 11
const unsorted1 = [1, 0, 0, 1];
console.log(process.version, [...unsorted1], '->', unsorted1.sort(( value ) => value));
const unsorted2 = [1, -1, -1, 1];
console.log(process.version, [...unsorted2], '->', unsorted2.sort(( value ) => value));
@ctavan
ctavan / gist:4482825
Last active February 18, 2019 16:09
Init-script for optionally starting multiple redis instances on the same host running Ubunut/Debian. Highly inspired by the memcached init script that comes with the Ubuntu package. This is useful since redis is single-threaded.
#! /bin/bash
### BEGIN INIT INFO
# Provides: redis-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redis-server - Persistent key-value db