Skip to content

Instantly share code, notes, and snippets.

Will Franzen wtfaremyinitials

Block or report user

Report or block wtfaremyinitials

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:0e1aa099a29f562cdc3ba30c36717995
#!/bin/sh
KERNEL="vmlinuz-4.4.0-112-generic"
INITRD="initrd.img-4.4.0-112-generic"
CMDLINE="earlyprintk=serial console=ttyS0 acpi=off root=/dev/vda1 ro"
MEM="-m 1G"
SMP="-c 2"
NET="-s 2:0,virtio-net"
IMG_HDD="-s 4,virtio-blk,hd.raw"
View time-travel.md

Time Travel Debugging

Time Travel refers to the ability to record a tab and later replay it ([WebReplay][wrr]). The technology is useful for local development, where you might want to:

  • pause and step forwards or backwards
  • pause and rewind to a prior state
  • rewind to the time a console message was logged
  • rewind to the time an element had a certain style or layout
  • rewind to the time a network asset loaded
@jdarpinian
jdarpinian / executable.c
Last active Oct 2, 2019
Add one line to your C/C++ source to make it executable.
View executable.c
///bin/true;COMPILER_OPTIONS="-g -Wall -Wextra --std=c99 -O1 -fsanitize=address,undefined";THIS_FILE="$(cd "$(dirname "$0")"; pwd -P)/$(basename "$0")";OUT_FILE="/tmp/build-cache/$THIS_FILE";mkdir -p "$(dirname "$OUT_FILE")";test "$THIS_FILE" -ot "$OUT_FILE" || $(which clang || which gcc) $COMPILER_OPTIONS -xc "$THIS_FILE" -o "$OUT_FILE" || exit;exec "$OUT_FILE" "$@"
#include <stdio.h>
int main() {
printf("Hello world!\n");
return 0;
}
View qrcli.swift
// % swift qrcli.swift TEST > qrcode.png
// or, % swift build -Xswiftc -framework -Xswiftc CoreImage
import CoreImage
import class AppKit.NSBitmapImageRep
func qrcode(_ text: String) -> CIImage {
let filter = CIFilter(name: "CIQRCodeGenerator")!
filter.setValue(text.data(using: .shiftJIS), forKey: "inputMessage")
filter.setValue("M", forKey: "inputCorrectionLevel")
@banjun
banjun / main.swift
Created Feb 14, 2017
add Touch Bar support for CLI without .app bundle nor Info.plist
View main.swift
class AppDelegate: NSResponder, NSTouchBarDelegate, NSApplicationDelegate {
@available(OSX 10.12.2, *)
lazy var touchbar: NSTouchBar = {
let tb = NSTouchBar()
tb.delegate = self
tb.defaultItemIdentifiers = [NSTouchBarItemIdentifier(rawValue: "test")]
return tb
}()
@Rich-Harris
Rich-Harris / footgun.md
Last active Oct 15, 2019
Top-level `await` is a footgun
View footgun.md

Edit — February 2019

This gist had a far larger impact than I imagined it would, and apparently people are still finding it, so a quick update:

  • TC39 is currently moving forward with a slightly different version of TLA, referred to as 'variant B', in which a module with TLA doesn't block sibling execution. This vastly reduces the danger of parallelizable work happening in serial and thereby delaying startup, which was the concern that motivated me to write this gist
  • In the wild, we're seeing (async main(){...}()) as a substitute for TLA. This completely eliminates the blocking problem (yay!) but it's less powerful, and harder to statically analyse (boo). In other words the lack of TLA is causing real problems
  • Therefore, a version of TLA that solves the original issue is a valuable addition to the language, and I'm in full support of the current proposal, which you can read here.

I'll leave the rest of this document unedited, for archaeological

@pwnsdx
pwnsdx / main.scpt
Last active Jun 17, 2019
Hardened Chrome Browser
View main.scpt
# Misc: --start-maximized --disable-save-password-bubble
# Reduce attack surface: --disable-presentation-api --disable-file-system --disable-contextual-search --disable-account-consistency --disable-translate --disable-background-mode --disable-plugins-discovery --disable-webgl --disable-webgl-image-chromium --disable-speech-api --disable-smart-virtual-keyboard --disable-print-preview --disable-password-generation --disable-overlay-scrollbar --disable-offer-upload-credit-cards --disable-ntp-popular-sites --disable-cloud-import --disable-component-cloud-policy --disable-credit-card-scan --disable-bundled-ppapi-flash --disable-java --disable-plugins --disable-ipv6 --disable-people-search --disable-default-apps
# Incognito, sandboxing & security stuff: --incognito --disable-sync --disable-sync-backup --disable-sync-rollback --disable-sync-app-list --disable-sync-types --enable-sandbox --enable-sandbox-logging --isolate-extensions --isolate-sites-for-testing=* --process-per-tab --process-per-site --safe-plugins
#
@novemberborn
novemberborn / setup.md
Created Jan 7, 2016
OS X Redirect ports 80 and 443 to 8080 and 8443 respectively
View setup.md

Changes with .dev domains in mind.

Create /etc/pf.anchors/dev, containing:

rdr pass inet proto tcp from any to any port 80 -> 127.0.0.1 port 8080
rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 8443

@gbaman
gbaman / HowToOTG.md
Last active Oct 12, 2019
Simple guide for setting up OTG modes on the Raspberry Pi Zero
View HowToOTG.md

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

View gulpfile.js
var gulp = require('gulp');
var exec = require('child_process').exec;
gulp.task('default', function (cb) {
exec('sketchtool export slices assets/icons.sketch --output=assets/icons/', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb(err);
});
});
You can’t perform that action at this time.