Skip to content

Instantly share code, notes, and snippets.

View nathggns's full-sized avatar

Nate Higgins nathggns

View GitHub Profile
@nathggns
nathggns / bridge.js
Created July 18, 2017 19:39
Applescript (JXA) code to get a list of notifications
#!/usr/bin/env osascript -l JavaScript
const NC_HIDDEN_POSITION = [99999, 99999];
class NotificationCenterBridge {
constructor() {
this.systemEvents = Application('System Events');
this.uiServer = this.systemEvents.applicationProcesses.byName('SystemUIServer');
this.notificationCentre = this.systemEvents.processes.byName('Notification Center');
this.notificationTable = this.notificationCentre.windows.byName('NotificationTableWindow');
@nathggns
nathggns / freebsd-java.md
Created January 29, 2015 20:25
Installing java on FreeBSD

Before installing this JRE, you have to install the linux binary compatibility on FreeBSD, you can follow this documentation. Jave requires some information about the proc. You have to mount linprocfs, type:

kldload linprocfs
mount -t linprocfs linprocfs /compat/linux/proc

and add this line to /etc/fstab:

linprocfs   /compat/linux/proc   linprocfs   rw   0  0
@nathggns
nathggns / base64url.php
Created September 21, 2013 18:34
base64url functionality for php
<?php
function base64url_encode($data) {
return rtrim(strtr(base64_encode($data), '+/', '-_'), '=');
}
function base64url_decode($data) {
return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT));
}
@nathggns
nathggns / keybase.md
Created December 9, 2019 16:09
keybase proof

Keybase proof

I hereby claim:

  • I am nathggns on github.
  • I am nathggns (https://keybase.io/nathggns) on keybase.
  • I have a public key ASBV3YWIoDIwLrDm90x-rjghaPiWU0bk6khGxpp-uFKAHAo

To claim this, I am signing this object:

@nathggns
nathggns / README.md
Created April 4, 2019 15:57
Break into Twitter's A/B test of their new website

Twitter has started testing a new desktop website based on their mobile website that should be a faster experience.

If you're not lucky enough to be included in this A/B test, you can "break" into it by setting the rweb_optin cookie to on.

You can do that by pasting the following URL into your browser's address bar while you're logged-in on https://twitter.com.

javascript:document.cookie%3D'rweb_optin%3Don%3B%20expires%3D01%2F12%2F2019%3B%20path%3D%2F%3B'%3Bwindow.location.reload()%3B
@nathggns
nathggns / mock.ts
Last active September 22, 2018 13:52
type JestFNs<T> = { [P in keyof T]: jest.MockInstance<any> };
type Mocked<T> = JestFNs<T> & { reset(): void };
export type Mock<T> = T & { mock: Mocked<T> };
export default function mock<T extends any>(
inst: Partial<T> = {} as any
): Mock<T> {
const target = {} as any;
const proxy = new Proxy(target, {
get(target: any, key: string) {
@nathggns
nathggns / hangman.py
Last active March 13, 2018 00:42
Python hangman game
# All this code is in one file for simplicity. It wouldn't normally be.
#
# This code makes advanced use of classes and regular expressions.
# Good luck with it.
# Let me know if there's anything you can't understand.
#
# Oh it also used list comprehensions. Enjoy those.
import re
@nathggns
nathggns / curry.es6.js
Created June 7, 2015 02:46
Recursive curry functions in ES6
function curry(fn, ...args) {
if (args.length === fn.length) {
return fn(...args);
}
return curry.bind(this, fn, ...args);
}
function add(a, b) {
return a + b;
@nathggns
nathggns / stroke.scss
Created June 24, 2012 17:40
Text Stroke SCSS Mixin (SASS)
@mixin stroke($width, $color) {
$shadow: 0 0 0 transparent;
$i: 0;
@while ($i < $width) {
$i: $i + 1;
$j: 0;
@while ($j < 2) {
$j: $j + 1;
@nathggns
nathggns / union.pl
Created August 22, 2017 21:52
Prolog to create union of two lists without unifying non-ground terms
myUMember(X, [Y|T]) :- X == Y; myUMember(X, T).
myU([X|Y],Z,W) :-
myUMember(X,Z),
!,
myU(Y,Z,W).
myU([X|Y],Z,[X|W]) :- myU(Y,Z,W).
myU([],Z,Z).