Skip to content

Instantly share code, notes, and snippets.

Nate Higgins nathggns

Block or report user

Report or block nathggns

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
@nathggns
nathggns / README.md
Created Apr 4, 2019
Break into Twitter's A/B test of their new website
View README.md

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
View mock.ts
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 / union.pl
Created Aug 22, 2017
Prolog to create union of two lists without unifying non-ground terms
View union.pl
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).
@nathggns
nathggns / bridge.js
Created Jul 18, 2017
Applescript (JXA) code to get a list of notifications
View bridge.js
#!/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 / results2017.json
Last active Jun 14, 2017
Results of the 2017 UK General Election scraped from BBC.
View results2017.json
{
"Aberavon": [
{
"name": "(LAB)",
"votes": 22662,
"share": 68.1
},
{
"name": "(CON)",
"votes": 5901,
@nathggns
nathggns / README.md
Last active Dec 16, 2016
Two implementations of quick sort in C
View README.md

Included in this gist are two C implementations of Quicksort. One designed to work with pointers, and one with arrays.

These were created for educational purposes and should not be used in production. Any suggestions on improvements would be vastly appreciated.

@nathggns
nathggns / enum.babel.js
Created Aug 4, 2015
Mini enum-like solution. Probably not all that useful;
View enum.babel.js
import { invert, assign, object } from 'lodash';
class Enum {
// Should probably look into using a Symbol for this instead??
static privateKey = '_private';
constructor(map) {
const inverted = invert(map);
const keys = Object.keys(map);
@nathggns
nathggns / README.md
Last active Aug 29, 2015
Calculate which Conservative seats Labour would have won with the votes from the Green Party. #GE2015
View README.md

Calculate which Conservative seats Labour would have won with the votes from the Green Party.

  • Requires babel with the setting of stage 0.
  • Requires q-io && lodash
  • Requires my results.json compilation of the 2015 General Election (#GE2015)

You can plug in a different json file in the same format as mine, or change the variables on lines 4-6 to work out the results for different combinations and elections.

Example:

View es7.js
import {inject} from 'aurelia-framework';
import {HttpClient} from 'aurelia-http-client';
@inject(HttpClient)
export class ClusterList {
heading = 'Clusters';
url_base = 'https://foobar:443/v1';
fabrics = [];
constructor(http){
You can’t perform that action at this time.