Skip to content

Instantly share code, notes, and snippets.

View techniq's full-sized avatar

Sean Lynch techniq

View GitHub Profile
@techniq
techniq / axis.d.ts
Created December 30, 2018 15:45
@vx typings
declare module '@vx/axis' {
import React from 'react';
import { ScaleTime } from 'd3-scale';
interface Point {
x: number;
y: number;
}
interface AxisProps {
@techniq
techniq / index.js
Last active April 20, 2017 19:48
Get calendar days
import dateFns from 'date-fns';
function getMonthDays(date) {
const startOfMonth = dateFns.startOfMonth(date);
const endOfMonth = dateFns.endOfMonth(date);
let prevMonthDaysNeeded = startOfMonth.getDay();
const prevMonthDays = prevMonthDaysNeeded ? dateFns.eachDay(
dateFns.subDays(startOfMonth, prevMonthDaysNeeded),
dateFns.subDays(startOfMonth, 1)

Keybase proof

I hereby claim:

  • I am techniq on github.
  • I am techniq (https://keybase.io/techniq) on keybase.
  • I have a public key whose fingerprint is 4128 E489 262F 14C2 6C06 43DE EDE7 A77D 2F9B 9ABD

To claim this, I am signing this object:

@techniq
techniq / README.md
Last active February 18, 2016 16:07
Element prototype oddity in Chrome console

Element prototype oddity in Chrome console

Object.getPrototypeOf(document.createElementNS('html', 'div'))
  1. When I run this from a script on Chrome 48 (stable) or 50 (canary) I get the expected/desired HTMLDivElement (codepen)
  2. When I run this within the console on Chrome 48 I get Element (no HTMLDivElement or HTMLElement)
  3. When I run this within the console on Chrome 50 I get Node (no HTMLDivElement, HTMLElement, or Element)
@techniq
techniq / examples.js
Last active August 29, 2015 14:24
Find all elements with a specific style attribute
getElementsWithStyle('border.*radius');
getElementsWithStyle('box-shadow');
@techniq
techniq / fakeServer-test.js
Created June 14, 2015 02:05
Sinon AJAX tests
import JSData from 'js-data';
import DSHttpAdapter from 'js-data-http';
import sinon from 'sinon';
describe("fakeServer", function() {
beforeEach(function() {
this.server = sinon.fakeServer.create();
// this.server.autoRespond = true;
// this.respondImmediately = true;
@techniq
techniq / README.md
Last active August 29, 2015 14:22
Bash tips

Bash tips

Strip extension (source)

Example: foo.png => foo

for file in *.png; do
    echo $(basename $file .png)
done;

or

@techniq
techniq / README.md
Last active November 26, 2020 15:32
Convert JSON boolean strings ("true"/"false") to boolean values

Convert undefined to false

JSON.parse(someVariable || false)

Returns

  • "true" => true
  • "false" => false
  • undefined => false
@techniq
techniq / README.md
Last active August 29, 2015 14:19
Gerber / KiCAD layer file extensions
KiCAD Layer Name Gerber Name Gerber Extension
F.Cu Top Layer .gtl
B.Cu Bottom Layer .gbl
F.Paste Top Paste .gtp
F.SilkS Top Overlay (silk screen) .gto
B.SilkS Bottom Overlay (silk screen) .gbo
F.Mask Top Solder Resist .gts
B.Mask Bottom Solder Resist .gbs
Edge.Cuts Edges (board outline) .gm1
@techniq
techniq / README.md
Last active July 13, 2019 01:39
curl reference

See response headers

curl -i localhost/api/foo

See request and response headers

curl -v localhost/api/foo

POST with string data

Unix: