Skip to content

Instantly share code, notes, and snippets.

@danharper
danharper / vscode-settings.js
Last active August 18, 2018 14:26
italic operator mono
{
"editor.fontFamily": "Operator Mono, Menlo, Monaco, 'Courier New', monospace",
"editor.fontSize": 13,
"window.zoomLevel": 0,
"editor.tabSize": 2,
"editor.fontLigatures": true,
"workbench.colorTheme": "Default Light+",
"editor.cursorBlinking": "solid",
"editor.minimap.enabled": false,
"editor.tokenColorCustomizations": {
const { execSync } = require('child_process')
const SENTRY_URL = 'https://app.getsentry.com/api/0/projects/radweb/inventorybase-go/releases'
const SENTRY_API_KEY = process.env.SENTRY_API_KEY
const VERSION = process.env.CIRCLE_SHA1
function createSentryRelease() {
execSync(`curl ${SENTRY_URL} -u ${SENTRY_API_KEY} -X POST -d '${JSON.stringify({ version: VERSION })}' -H 'Content-Type: application-json'`)
}
function uploadToSentry(file, filename) {
@danharper
danharper / voices.js
Last active October 7, 2016 16:45
cycle every SpeechSynthesis voice
// would've been awesome if `speechSynthesis.speak` returned a promise which resolves on finish.. :(
const sleep = ms => new Promise(r => setTimeout(r, ms))
async function go(msg) {
for (let v of speechSynthesis.getVoices()) {
speechSynthesis.speak(u = new SpeechSynthesisUtterance(msg), u.voice = v, u)
await sleep(1000)
}
}
// https://twitter.com/ReactJSTraining/status/743567989434286080
// https://codepen.io/ReactJSTraining/pen/MeePdW?editors=0010
const { render, findDOMNode } = ReactDOM
////////////////////////////////////////////////////////////
// Only code you need to change is inside this component
class PinToBottom extends React.Component {
static propTypes = {
@danharper
danharper / x.sh
Created June 16, 2016 15:46
building an ionic/cordova android app on ubuntu. actually using circle, but needed to test something out on a fresh box
# starting with a Ubuntu 14 box on AWS
# increase swap
# https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04
sudo fallocate -l 4G /swapfile
ls -lh /swapfile
sudo chmod 600 /swapfile
ls -lh /swapfile
sudo mkswap /swapfile
export type Options = {
blockSelector: () => string,
linkSelector: (id: string) => string,
classToToggle?: () => string,
toggleClass?: (el: Element, isInView: boolean, classToToggle: string) => void,
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="main"></div>
@danharper
danharper / normalize-filenames.js
Last active August 17, 2018 19:32 — forked from dcramer/normalize-filenames.js
use Sentry (Raven) on PhoneGap
Raven.config(dsn, {
dataCallback(data) {
const normalize = filename => filename.split('/www/', 2)[1]
data.exception.values[0].stacktrace.frames.forEach(frame => {
frame.filename = normalize(frame.filename)
})
data.culprit = data.exception.values[0].stacktrace.frames[0].filename
@danharper
danharper / TimestampToDate.scpt
Last active October 8, 2015 10:47 — forked from clooth/TimestampToDate.scpt
Applescript to display real date of selected timestamp
on run {input, parameters}
tell application "System Events"
set activeApp to name of first process whose frontmost is true
end tell
set _timestamp to (input as string)
tell application activeApp
set realDate to ((do shell script "date -r " & _timestamp) as string)
@danharper
danharper / waitFor.js
Last active February 21, 2017 12:38
three ways to "waitFor" a prop to become non-null before rendering
// decorate the class, composition
function waitFor(prop) {
return ChildComponent => class extends Component {
render() {
return this.props[prop] ? <ChildComponent {...this.props} /> : null
}
}
}
// decorate the class, inheritance