Skip to content

Instantly share code, notes, and snippets.

View mattmccray's full-sized avatar

Matt McCray mattmccray

View GitHub Profile
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success
@cem2ran
cem2ran / main.js
Created December 28, 2015 01:10
React Getting Started - How it should be!
import React from 'react'
import ReactDOM from 'react-dom'
const Hello = ({name}) => <h1>Hello {name}!</h1>
ReactDOM.render(
<Hello name={"vjeux"}/>,
document.body.appendChild(document.createElement("div"))
)
@demonbane
demonbane / makeapp.sh
Created July 5, 2011 20:05
Create a Fluid-style app launcher for single-window Chrome instances on OSX
#!/bin/sh
echo "What should the Application be called (no spaces allowed e.g. GCal)?"
read inputline
name="$inputline"
echo "What is the url (e.g. https://www.google.com/calendar/render)?"
read inputline
url="$inputline"
@gf3
gf3 / gist:306785
Created February 17, 2010 16:38
Sexy bash prompt
Moved to: http://github.com/gf3/dotfiles/blob/master/bash_prompt
@tobitailor
tobitailor / get_barcode_from_image.js
Created June 1, 2010 19:33
Barcode recognition with JavaScript - Demo: http://bit.ly/djvUoy
/*
* Copyright (c) 2010 Tobias Schneider
* This script is freely distributable under the terms of the MIT license.
*/
(function(){
var UPC_SET = {
"3211": '0',
"2221": '1',
"2122": '2',
@kofifus
kofifus / Codemirror spellchecker with typo corrections
Last active September 23, 2022 17:12
CodeMirror spell checker with typo correction
usage:
------
// include codemirror.js, addon/mode/overlay.js
// include async typo.js from https://github.com/cfinke/Typo.js/pull/45
// include loadTypo.js from: https://github.com/cfinke/Typo.js/pull/50
// loading typo + dicts takes a while so we start it first
// hosting the dicts on your local domain will give much faster loading time
// english dictionaries taken from https://github.com/cfinke/Typo.js/pull/47
@Schniz
Schniz / plaintext-contenteditable.css
Last active April 8, 2022 17:46
Plain-Text ContentEditable div for React.js
.comPlainTextContentEditable {
-webkit-user-modify: read-write-plaintext-only;
}
.comPlainTextContentEditable--has-placeholder::before {
content: attr(placeholder);
opacity: 0.5;
color: inherit;
cursor: text;
}
function whichTransitionEvent(){
var t;
var el = document.createElement('fakeelement');
var transitions = {
'transition':'transitionend',
'MSTransition':'msTransitionEnd',
'MozTransition':'transitionend',
'WebkitTransition':'webkitTransitionEnd'
}
@rgrove
rgrove / Makefile
Created July 30, 2011 22:01
Simple Makefile to minify CSS and JS.
# Patterns matching CSS files that should be minified. Files with a -min.css
# suffix will be ignored.
CSS_FILES = $(filter-out %-min.css,$(wildcard \
public/css/*.css \
public/css/**/*.css \
))
# Patterns matching JS files that should be minified. Files with a -min.js
# suffix will be ignored.
JS_FILES = $(filter-out %-min.js,$(wildcard \
Gem::Specification.new do |s|
s.name = 'bang'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Jeff Kreeftmeijer'
s.email = 'jeff@kreeftmeijer.nl'
s.summary = 'Bang!'
s.description = 'Bangs existing model methods'
s.files = ['bang.rb']