Skip to content

Instantly share code, notes, and snippets.

View zephraph's full-sized avatar

Justin Bennett zephraph

View GitHub Profile
@capnmidnight
capnmidnight / banquo.js
Last active August 29, 2015 14:14
Javascript named arguments
// so named because why the hell not?
function banquo(func) {
var def = func.toString();
// find the comma-delimeted list of parameters
var params = def.match(/\(\s*(\w+(\s*,\s*\w+)*)\s*\)/)[1].split(',').map(function (p) {
return p.trim();
});
// extract out just the function body
@gr2m
gr2m / octokit_pika_build_setup.md
Last active August 16, 2019 15:42
This is a living document on JavaScript Octokit’s build setup using pika pack and semantic-release on GitHub Actions

Octokit.js build setup using @pika/pack

Install @pika/pack and build plugins

npm install --save-dev @pika/pack @pika/plugin-build-node @pika/plugin-build-web @pika/plugin-ts-standard-pkg

Configuration

import {useState, useCallback, useRef} from 'react'
// Hook
const useHover = <T extends HTMLElement>(): [
(node?: T | null) => void,
boolean,
] => {
const [value, setValue] = useState(false)
// Wrap in useCallback so we can use in dependencies below
(defn point-outside-circle [c r p]
(if (< (vec2/dist c p) r)
(vec2/scale (vec2/normalize (vec2/- p c)) r)
p))
(defn circle-tangent-point [c r b dir]
(let [B (point-outside-circle c r b)
cB (vec2/dist c B)
S (vec2/scale (vec2/normalize (vec2/- B c)) r)
@sibelius
sibelius / Sample.tsx
Created February 27, 2019 15:47
useRelayPagination to be used with React Native Flatlist
const {
isFetchingEnd,
isFetchingTop,
onRefresh,
onEndReached,
} = useRelayPagination(relay, users);
const isRefreshing = isFetchingEnd || isFetchingTop;
<FlatList
@polotek
polotek / pipeaccept.js
Created May 18, 2011 01:16 — forked from heapwolf/pipeaccept.js
accepting input from a pipe, nodejs
var data;
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
data += chunk;
});
process.stdin.on('end', function() {
@jpnelson
jpnelson / split.css
Last active June 14, 2022 16:51
Responsive, resizable panel layout with flexbox
.container {
height: 500px;
border: 2px solid grey;
position:relative;
}
.split {
display: flex;
height: 100%;
border: 1px solid black;
@MaggieAppleton
MaggieAppleton / roam-kanban.css
Created February 3, 2020 09:22
Roam Kanban Styling
.kanban-board {
background-color: #fff;
}
.kanban-card {
background-color: white;
margin: 8px;
box-shadow: 0px 1px 2px #9EB3C0;
padding: 10px;
border-radius: 2px;
@ankurk91
ankurk91 / git_remember_password.md
Last active October 11, 2022 04:57
Git credential cache, why type password again and again

Tired of entering password again and again ?

Run this command to remember your password:

git config --global credential.helper 'cache --timeout 28800'

Above command will tell git to cache your password for 8 hours.

@lurch
lurch / pizero_usb_internet.sh
Last active November 1, 2022 16:59
Script to automatically provide internet access to a PiZero connected to a Linux host over a USB-network (only tested on Ubuntu 14.04)
#!/bin/bash
# Automatically setup routing and DNS for a PiZero connected over a USB-network
# NOTE: Before running this script for the first time, you need to run the
# following two commands on your Linux PC
# sudo sysctl -w net.ipv4.ip_forward=1
# sudo iptables -t nat -A POSTROUTING -s 169.254.0.0/16 -o eth0 -j MASQUERADE
# (replace eth0 in the second command with your internet-facing network device,
# e.g. wlan0 on a laptop)
# The Avahi-discovered hostname