Skip to content

Instantly share code, notes, and snippets.

View seanhess's full-sized avatar

Sean Hess seanhess

View GitHub Profile
@seanhess
seanhess / characters-details.html
Created June 26, 2012 16:14
Angular preserve state
<div ng-controller="CharacterDetailCtrl">
<form>
<div>Name: <input ng-model="character.name"></div>
<div>Actor: <input ng-model="character.actor"></div>
<div>Image URL: <input ng-model="character.imageUrl"></div>
<div>
<input type="submit" ng-click="save(character)" value="save">
<input type="submit" ng-click="delete(character)" value="delete" ng-show="character._id">
</div>
</form>
@seanhess
seanhess / chef.sh
Created September 27, 2012 18:45
install chef
#!/bin/bash
echo "YOUR SYSTEM IS COMPROMISED"
@seanhess
seanhess / example.html
Created October 20, 2012 02:03
Example.html
<html>
<head>
<style>
button {
width: 400px;
}
.bob {
background-color: blue;
asdlkjdfskljdsfjlkfsdjkljkl
woot hello
woot hello
woot hello
// creating global parameters and start
// listening to 'port', we are creating an express
// server and then we are binding it with socket.io
var express = require('express'),
app = express(),
util = require('util'),
@seanhess
seanhess / gist:4512738
Created January 11, 2013 18:07
Node HTTP Client
var options = {
hostname: 'www.google.com',
port: 80,
path: '/upload',
method: 'POST'
};
var req = http.request(options, function(res) {
console.log('STATUS: ' + res.statusCode);
console.log('HEADERS: ' + JSON.stringify(res.headers));
@seanhess
seanhess / File-callbacks.js
Last active December 11, 2015 17:39
Example of how promises cleaned up my node.js code
export function addFileToBook(bookId:string, uploadedFile:IUploadFile, cb:(err:Error, file:IFile) => void) {
var file = toFile(bookId, uploadedFile)
uploadToUrl(file, uploadedFile, function(err) {
if (err) return cb(err, null)
insert(file).run(function(err) {
if (err instanceof Error) return cb(err, null)
cb(null, file)
})
})
}