Skip to content

Instantly share code, notes, and snippets.

View nornagon's full-sized avatar

Jeremy Rose nornagon

View GitHub Profile
@nornagon
nornagon / index.html
Created October 16, 2018 21:45
Electron Fiddle Gist
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Hello World!</title>
</head>
<body>
<h1>Hello World!</h1>
<!-- All of the Node.js APIs are available in this renderer process. -->
We are using Node.js <script>document.write(process.versions.node)</script>,
@nornagon
nornagon / what_good_is_a_programmer
Created August 22, 2018 01:33
What good is a programmer if they can't destroy software?
#!/bin/sh
tail +3 "$0" | clang -x c -o "$0" - && exec "$0"
#include <unistd.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <mach-o/dyld.h>
const char what_good_is_a_writer[] =
"What good is a writer if he can’t destroy literature?\n"
"And us... what good are we if we don’t help as much\n"
@nornagon
nornagon / finite_scroll.txt
Created July 2, 2018 15:48
Block infinite scroll with uBlock Origin
||twitter.com/i/timeline$xhmlhttprequest
0
SECTION
2
HEADER
9
$ACADVER
1
AC1014
9
$HANDSEED
@nornagon
nornagon / app-switching.jsx
Last active June 12, 2017 01:38
Switching between apps based on state in Cycle.js
export function App(sources) {
const appSinks$ = sources.onion.state$
.startWith({name: null})
.map(state => state.name)
// drop repeats to prevent Main() being re-called every time the state changes
.compose(dropRepeats())
.map(name => {
if (name == null) {
return SetName(sources);
} else {
tag = (name, text, attrs) ->
parts = (name ? 'div').split /(?=[.#])/
tagName = "div"
classes = []
id = undefined
for p in parts when p.length
switch p[0]
when '#' then id = p.substr 1 if p.length > 1
when '.' then classes.push p.substr 1 if p.length > 1
else tagName = p
@nornagon
nornagon / .bashrc
Last active December 27, 2015 10:59
Become vocabulous with random word definitions on your shell.
# Needs jq. brew install jq.
random_word_def() {
local random_word wordnik_for_word show_definition
random_word() {
perl -e 'rand($.) < 1 && ($line = $_) while <>; print $line' < /usr/share/dict/words
}
wordnik_for_word() {
curl -s http://api.wordnik.com/v4/word.json/"$1"/definitions'?api_key=a2a73e7b926c924fad7001ca3111acd55af2ffabf50eb4ae5'
}
component = (c) ->
c::_added = (gobj) ->
throw 'added twice' if @me?
@me = gobj
@world = @me.world
@init? @_args...
new_c = (args...) ->
r = new c
r._args = args
r
{Collection} = masala = require './masala'
live = require './sugar'
data = new Collection [live {
name: 'list of things'
data: new Collection [live({val:3}),live({val:4})]
}]
http = require 'http'
render = require './render'
@nornagon
nornagon / gist:4670491
Created January 30, 2013 03:57
disintegrate
disintegrate = (fn) ->
tests = []
ret_fn = (args...) ->
args_saved = JSON.stringify(args)
res = fn.apply(this, args)
res_saved = JSON.stringify(res)
tests.push {args:args_saved,res:res_saved}
return res
ret_fn.tests = tests
ret_fn