Skip to content

Instantly share code, notes, and snippets.

var koa = require('koa');
var route = require('koa-route');
var serve = require('koa-static');
var db = require('./db');
var render = require('./render');
var app = koa();
app.use(serve('public/'));
@jaxbot
jaxbot / callback-equivalent.js
Last active August 29, 2015 14:05
Node.js generators vs. callbacks
function home() {
db.query("SELECT * FROM `posts` ORDER BY `time` DESC LIMIT 10", function(err, rows){
render('home', { posts: rows[0] }, function(err, result){
response.end(result);
});
});
}
function post(id) {
db.query("SELECT * FROM `posts` WHERE `link` = " + db.escape(id)), function(err, rows){
package main
import "fmt"
import "time"
func main() {
timestart := time.Now()
for c := 0; c < 100000000; c++ {
@jaxbot
jaxbot / example.com
Last active August 29, 2015 14:04
Example.com on Brighthouse (RoadRunner)
<!doctype html>
<html>
<head>
<title>Example Domain</title>
<meta charset="utf-8" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style type="text/css">
body {
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/Article">
<head>
<meta charset='utf-8'>
<title>Awesome Post</title>
<meta property="og:title" itemprop="name" content="Awesome Post" />
<meta property="og:image" itemprop="image" content="http://example.com/awesomeimage.jpg" />
<meta property="og:description" itemprop="description" content="This post is awesome" />
</head>
// Testing Gists in Vim
// This is neat!
// Testing from work machine
final int SCAN_QR = 4;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent intent = new Intent(this, CaptureActivity.class);
startActivityForResult(intent, SCAN_QR);
}
@jaxbot
jaxbot / cardscrolladapter.java
Created June 16, 2014 22:39
CardScrollAdapter example on Google Glass
import android.app.Activity;
import android.view.View;
import android.view.WindowManager;
import android.os.Bundle;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
import android.content.res.Resources;
import android.util.Log;
@jaxbot
jaxbot / glass.html
Created April 20, 2014 15:55
[wearscript] playing with accel and gyro
<html ng-app='glassApp'>
<head>
<script src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.0-beta.3/angular.js'></script>
<script>
glassApp = angular.module('glassApp', []);
glassApp.controller('glassController', function($scope) {
function server() {
WS.log('Welcome to WearScript');
WS.sound('SUCCESS')
/*
* Medli.js
* Main entry point for the board system
*/
var cachedDOM = [];
// Because I'm lazy. And it does caching, so that's good, right?
var _g = function(id) { return cachedDOM[id] || (cachedDOM[id] = document.getElementById(id)); }