Skip to content

Instantly share code, notes, and snippets.

Avatar

Peter Lyons focusaurus

View GitHub Profile
@focusaurus
focusaurus / ep_app.js
Created Jun 14, 2013
Example of how a main express app can mount sub-applications on a mount point with app.use('/mount-point', subapp); If you GET /, you'll see the main_app's '/' response. If you GET /ep_app, you'll see the ep_app's '/' response.
View ep_app.js
var express = require("express");
var app = express();
app.get('/', function (req, res) {
res.send("This is the '/' route in ep_app");
});
module.exports = app;
@focusaurus
focusaurus / .zshrc
Created Jul 31, 2013
There's got to be something alongs these lines that actually works...the snippet below does not work.
View .zshrc
alias screenunlock='defaults write com.apple.screensaver askForPassword 0 && defaults write com.apple.screensaver askForPasswordDelay 0'
alias screenlock='defaults write com.apple.screensaver askForPassword 1 && defaults write com.apple.screensaver askForPasswordDelay 60'
@focusaurus
focusaurus / chai_reference.js
Last active Nov 18, 2016
Quick reference for the chaijs.com assertion library
View chai_reference.js
/*
run this JavaScript on the chai API doc page:
console.log([].map.call(document.querySelectorAll('div.api_method_wrapper h3'), (x) => x.innerText).join('\n'))
*/
assert(expression, message)
.fail(actual, expected, [message], [operator])
.isOk(object, [message])
.isNotOk(object, [message])
@focusaurus
focusaurus / gist:6905035
Last active Dec 25, 2015
helper function to reduce mongoose/REST boilerplate. Could also monkey patch into OutgoingMessage.prototype perhaps.
View gist:6905035
function oopsAPI(res, error, model) {
if (error) {
logger.error('Unexpected mongoose error during API query', error);
res.status(500).send(error);
return true;
}
if (!model) {
res.status(404).send();
return true;
}
@focusaurus
focusaurus / keybase.md
Created Apr 8, 2014
claiming my github focusaurus identity for keybase.io
View keybase.md

Keybase proof

I hereby claim:

  • I am focusaurus on github.
  • I am focusaurus (https://keybase.io/focusaurus) on keybase.
  • I have a public key whose fingerprint is 6B5E E932 7443 38B7 F12F F706 B2C9 23F1 E205 D5C6

To claim this, I am signing this object:

@focusaurus
focusaurus / index.html
Created Jul 20, 2014
moo.com business card done in HTML/CSS
View index.html
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
@focusaurus
focusaurus / create-github-milestone.js
Last active Aug 29, 2015
node.js script to create a github milestone
View create-github-milestone.js
#!/usr/bin/env node
var request = require('superagent');
var config = require('config');
var GITHUB_API_URL = 'https://api.github.com';
var MILESTONES = '/repos/owner/project/milestones';
request.post(GITHUB_API_URL + MILESTONES)
.set('Authorization', 'token ' + config.githubToken)
.set('User-Agent', 'focusaurus-create-github-milestone')
.send({title: process.argv[2]}).end(function (error, res) {
console.log(error, res.text);
@focusaurus
focusaurus / moin_to_markdown.py
Created Sep 2, 2014
Use for inspiration only. Very much a 1-off tool limited to a specific migration's needs.
View moin_to_markdown.py
#!/usr/bin/python
# This is a simple script to convert a very limited set of MoinMoin wiki syntax
#to markdown. I am using it in my migration from MoinMoin to a gitit+markdown
#wiki.
DO_GIT = False
#DISABLED#DO_GIT = True
import os
import re
REPLACEMENTS = (
("(./)", "[x]"),
@focusaurus
focusaurus / atom packages
Created Jan 13, 2015
Atom text editor setup 2015-01-12
View atom packages
atom-beautify
atom-color-highlight
autoclose-html
autocomplete-plus
git-blame
git-plus
jsdoc
jsformat
language-docker
language-dockerfile
@focusaurus
focusaurus / gist:b7f59b029f66e6b661cf
Created Jun 18, 2015
Review: Metaprogramming in ES6: Symbols and why they're awesome
View gist:b7f59b029f66e6b661cf
class BoringClass  
end  
class CoolClass  
  def ==(other_object)
   other_object.is_a? MyClass
  end
end  
BoringClass.new == BoringClass.new #=> false  
CoolClass.new == CoolClass.new #=> true!  
You can’t perform that action at this time.