Skip to content

Instantly share code, notes, and snippets.

:shipit:
hg commit

Dan Harper danharper

:shipit:
hg commit
Block or report user

Report or block danharper

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
@danharper
danharper / vscode-settings.js
Last active Aug 18, 2018
italic operator mono
View vscode-settings.js
{
"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": {
View release.js
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 Oct 7, 2016
cycle every SpeechSynthesis voice
View voices.js
// 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)
}
}
@danharper
danharper / RCC-001 PinToBottom.diff
Last active Jun 17, 2016
@ReactJSTraining Challenges
View RCC-001 PinToBottom.diff
// 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 Jun 16, 2016
building an ionic/cordova android app on ubuntu. actually using circle, but needed to test something out on a fresh box
View x.sh
# 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
View ScrollSpy.ts
export type Options = {
blockSelector: () => string,
linkSelector: (id: string) => string,
classToToggle?: () => string,
toggleClass?: (el: Element, isInView: boolean, classToToggle: string) => void,
}
View babel-browser.html
<!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 Aug 17, 2018 — forked from dcramer/normalize-filenames.js
use Sentry (Raven) on PhoneGap
View normalize-filenames.js
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 Oct 8, 2015 — forked from clooth/TimestampToDate.scpt
Applescript to display real date of selected timestamp
View TimestampToDate.scpt
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 Feb 21, 2017
three ways to "waitFor" a prop to become non-null before rendering
View waitFor.js
// 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
You can’t perform that action at this time.