Skip to content

Instantly share code, notes, and snippets.

View lukaskollmer's full-sized avatar
👻
procrastinating

Lukas Kollmer lukaskollmer

👻
procrastinating
View GitHub Profile
@lukaskollmer
lukaskollmer / noscript-tracking.go
Created May 7, 2019 20:13 — forked from wybiral/noscript-tracking.go
Tracking cursor position in real-time with remote monitoring (without JavaScript)
// Tracking cursor position in real-time without JavaScript
// Demo: https://twitter.com/davywtf/status/1124146339259002881
package main
import (
"fmt"
"net/http"
"strings"
)
@lukaskollmer
lukaskollmer / ref-buffer-type.js
Created January 2, 2019 15:24 — forked from TooTallNate/ref-buffer-type.js
Fixed length "Buffer" type, for use in `ref-struct` type definitions.
var ref = require('ref');
module.exports = BufferType;
/**
* Fixed length "Buffer" type, for use in Struct type definitions.
*
* Optionally setting the `encoding` param will force to call
* `toString(encoding)` on the buffer returning a String instead.
*/
@lukaskollmer
lukaskollmer / gist:87e41c0621c0eebc6c7ca4ddca8e5225
Created November 25, 2017 17:37 — forked from johanbrook/gist:761909
Convert an ICNS file to PNG with alpha transparency
sips -s format png /Applications/Safari.app/Contents/Resources/compass.icns --out /Users/Johan/Desktop/safari.png
@lukaskollmer
lukaskollmer / more-mute-regex.md
Last active November 7, 2017 22:09 — forked from jimmynotjim/more-mute-regex.md
Tweetbot can use regular expressions to mute tweets in your timeline and mentions.

Hashtag abuse

Three or more hashtags.

#[^#]+#[^#]+#

Long hashtags (15+ characters): #hashtagpunchline

As of iOS 11/macOS High Sierra, and only including ones in Foundation and CoreFoundation
Strings:
_NSCFString - a CFStringRef or CFMutableStringRef. This is the most common type of string object currently.
- May have 8 bit (ASCII) or 16 bit (UTF-16) backing store
_NSCFConstantString - a compile time constant CFStringRef, like you'd get with @"foo"
- May also be generated by dynamic string creation if matches a string in a pre-baked table of common strings called the StringROM
NSBigMutableString - an NSString backed by a CFStorage (https://github.com/opensource-apple/CF/blob/master/CFStorage.h) for faster handling of very large strings
NSCheapMutableString - a very limited NSMutableString that allows for zero-copy initialization. Used in NSFileManager for temporarily wrapping stack buffers.

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@lukaskollmer
lukaskollmer / StatusBarButton.swift
Created August 5, 2017 07:38 — forked from sindresorhus/StatusBarButton.swift
Creates a NSStatusBarButton with proxy methods for the NSStatusItem methods, so you don't have to deal with that class anymore. Most of the NSStatusItem properties are deprecated, so it's much nicer to deal with the NSStatusBarButton directly.
final class AssociatedObject<T: Any> {
subscript(index: Any) -> T? {
get {
return objc_getAssociatedObject(index, Unmanaged.passUnretained(self).toOpaque()) as! T?
} set {
objc_setAssociatedObject(index, Unmanaged.passUnretained(self).toOpaque(), newValue, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
#!/usr/bin/env bash
# Install Xcode Command Line Tools.
xcode-select --install
# Install Homebrew.
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install brew basics (auto-updating).
brew install terminal-notifier
@lukaskollmer
lukaskollmer / better-nodejs-require-paths.md
Created July 26, 2017 15:28 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@lukaskollmer
lukaskollmer / main.m
Created June 28, 2017 11:59 — forked from steventroughtonsmith/main.m
Load Mach-O executable at runtime and execute its entry point
void callEntryPointOfImage(char *path, int argc, char **argv)
{
void *handle;
int (*binary_main)(int binary_argc, char **binary_argv);
char *error;
int err = 0;
printf("Loading %s…\n", path);
handle = dlopen (path, RTLD_LAZY);