Skip to content

Instantly share code, notes, and snippets.

Ben Alman cowboy

Block or report user

Report or block cowboy

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
@cowboy
cowboy / mock-axios.js
Last active Jan 27, 2020
axios mocking via interceptors
View mock-axios.js
import axios from 'axios'
let mockingEnabled = false
const mocks = {}
export function addMock(url, data) {
mocks[url] = data
}
@cowboy
cowboy / E12-resistors.txt
Last active Dec 15, 2017
E12 resistors from tayda
View E12-resistors.txt
A-2754 | 0.47 Ohm 1/4W 1% Metal Film Resistor Royal OHM Top Quality
A-2244 | 1 OHM 1/4W 1% Metal Film Resistor
A-2576 | 1.2 OHM 1/4W 1% Metal Film Resistor
A-2316 | 1.5 OHM 1/4W 1% Metal Film Resistor
A-2757 | 1.8 Ohm 1/4W 1% Metal Film Resistor
A-2600 | 2.2 OHM 1/4W 1% Metal Film Resistor
A-2602 | 2.7 OHM 1/4W 1% Metal Film Resistor
A-2189 | 3.3 OHM 1/4W 1% Metal Film Resistor
A-2311 | 3.9 OHM 1/4W 1% Metal Film Resistor Royal OHM Top Quality
A-2308 | 4.7 OHM 1/4W 1% Metal Film Resistor
@cowboy
cowboy / bird-map.js
Created Oct 27, 2017
i made a bird map
View bird-map.js
'bird'
.split(/^(.)(.)(.)/)
.map(''.constructor.call.bind(''.repeat))
.filter(''.constructor)
.map(''.constructor.call.bind(''.charCodeAt))
.map(n=>n<100?100:n<101?107:n<106?111:n)
.map(''.constructor.fromCharCode)
.join('')
@cowboy
cowboy / paperclips.js
Last active Sep 14, 2018
Universal Paperclips: stuff to paste into console http://www.decisionproblem.com/paperclips
View paperclips.js
_toggles = {}
makeToggle = (id, fn, delay = 250) => {
const elem = document.querySelector('#' + id)
elem.onclick = () => {
if (_toggles[id]) {
clearInterval(_toggles[id])
_toggles[id] = null
} else {
_toggles[id] = setInterval(() => elem.disabled || fn(), delay)
}
@cowboy
cowboy / synth.cpp
Created Sep 14, 2017 — forked from genericpenguin/synth.cpp
Arduino Synth
View synth.cpp
/* Arduino Synth from
https://janostman.wordpress.com/2016/01/15/how-to-build-your-very-own-string-synth/
*/
#include <avr/interrupt.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
View cookie-clicker.ino
@cowboy
cowboy / 1 - install chocolatey.cmd
Created Dec 30, 2016
windows + chocolatey = awesome
View 1 - install chocolatey.cmd
@echo off
echo Administrative permissions required. Detecting permissions...
net session >nul 2>&1
if %errorLevel% == 0 (
echo Success: Administrative permissions confirmed.
) else (
echo Failure: Current permissions inadequate.
pause
exit 1
@cowboy
cowboy / mixin.js
Last active Sep 18, 2019
JavaScript ES6 - mixins with super
View mixin.js
// This mixin might be used to extend a class with or without its
// own "foo" method
const mixin = Base => class extends Base {
foo() {
// Only call super.foo() if it exists!
if (super.foo) {
super.foo();
}
console.log('mixin');
@cowboy
cowboy / index.js
Created Sep 16, 2016
Webpack: build error converting a lib's ... spread operator to ES5?
View index.js
// npm install && npm run build
// In output.js, spreadTest(...args) is converted to ES5
function spreadTest(...args) {
return args;
}
console.log(spreadTest(1, 2, 3));
// But the ...args inside of this lib's "audit" function is NOT converted to ES5
import 'react-axe';
You can’t perform that action at this time.