Skip to content

Instantly share code, notes, and snippets.

View brianleroux's full-sized avatar
💚
You are now aware that you are breathing

Brian LeRoux brianleroux

💚
You are now aware that you are breathing
View GitHub Profile
@brianleroux
brianleroux / async-play.js
Created July 17, 2014 20:44
demonstrates refactoring a bunch of node style callbacks with async
/* setup a pile of nodejs style methods that accept nodejs style callbacks (where err is the first argument and data the second)*/
var obj = {msg:'before'}
function first(obj, cb) {
console.log('first', obj.msg)
obj.msg += ' ... first'
cb(null, obj)
}
function second(obj, cb) {
@brianleroux
brianleroux / client.js
Last active January 4, 2016 00:59
example of implementing a file watcher with an http endpoint for client.js to poll for reloads
function checkForReload() {
var xhr = new XMLHttpRequest
xhr.open('get', 'http://localhost:1978', true)
xhr.setRequestHeader('X-Requested-With','XMLHttpRequest')
xhr.onreadystatechange = function() {
if (this.readyState === 4 && /^[20]/.test(this.status)) {
var reload = JSON.parse(this.responseText).reload
if (reload) window.location.reload()
}
}
var connect = require('connect')
var static = connect.static(__dirname + '/public')
var middleware = function(req, res, next) { next() }
var port = 9999
var cb = function() { console.log('Started server localhost:9999') }
connect()
.use(static)
.use(middleware)
.listen(port, cb)
// this thing
connect(
connect.static(_path.join(__dirname, '..', 'thirdparty')),
connect.static(__dirname),
connect.router(function (app) {
app.get('/cordova.test.js', function (req, res) {
/* impl */
}),
app.get('/', function (req, res) {
/* impl */
@brianleroux
brianleroux / config.xml
Created November 28, 2013 21:08
Proposal to simplify Cordova 'hello world'
<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>HelloCordova</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
var path = require('path')
, src = path.join(__dirname, 'test/fixtures/mobile-dark-button.css')
, dest = path.join('tmp/mobile-dark-button.out.css')
require('topcoat-resin')({src:src, dest:dest})
Running "topcoat:compile" (topcoat) task
test/fixtures/mobile-dark-button.css tmp/mobile-dark-button.out.css
Warning: Cannot read property 'r' of undefined Use --force to continue.
@brianleroux
brianleroux / new-machine-install.md
Last active December 25, 2015 22:29
Sometimes I get a new computer and install stuff. I've been slowly trying to move my life into the web browser but clearly we have a way to go. Most of this was thrashing with weird OS X and Xcode black boxes. But anyhow, here's what I did.
  • Firefox
  • Chrome
  • Alfred
  • iTerm
  • Brackets
  • Xcode
  • Xcode > Preferences > Downloads > Command Line Tools (WTFBBQ)
  • git
  • node
  • Android SDK
DGREY="\[\e[0;32m\]"
ENDCOLOR="\[\e[0m\]"
PS1="$DGREY#! $ENDCOLOR"
# allow vi nav on esc
set -o vi
# android business
export PATH=$PATH:~/Repo/android-sdk-macosx/tools
export PATH=$PATH:~/Repo/android-sdk-macosx/platform-tools
@brianleroux
brianleroux / gruntfile.js
Created October 14, 2013 16:08
working gruntfile.js for quickly scaffing a proj
var shell = require('shelljs')
, harp = require('harp')
, path = require('path')
module.exports = function(grunt) {
// init ceremonies
//
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),