Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
Happy to be here!

Bodo Kaiser bodokaiser

😀
Happy to be here!
View GitHub Profile
View mongoi.js
var mongoi = require('mongoi');
// connect to test database
mongoi.connect('mongodb://localhost/test');
// register generic middleware
mongoi.use(function(context, next) {
// do some logging
next();
});
@bodokaiser
bodokaiser / node.service
Created Apr 1, 2014
systemd service config for nodejs
View node.service
[Service]
Restart=always
StandardOutput=syslog
SyslogIdentifier=nearby
Environment=PATH=/usr/bin
Environment=NODE_ENV=production
ExecStart=/usr/bin/node /srv/nearby/lib/index.js
[Install]
WantedBy=multi-user.target
View client.js
var superagent = require('superagent')
var element = document.querySelector('#light');
superagent.get('/light').end(function(err, res) {
element.dataset.state = res.body.on;
updateInnerText(element);
element.addEventListener('click', function(e) {
View server.js
var fs = require('fs');
var http = require('http');
var express = require('express');
var app = express();
app.use(express.static(__dirname + '/../srv'));
fs.writeFile('/sys/class/gpio/export', '34', function(err) {
if (err) throw err;
@bodokaiser
bodokaiser / builder.js
Last active Aug 29, 2015
koa middleware to build component.
View builder.js
var fs = require('fs');
var builder = require('component-builder');
var resolver = require('component-resolver');
module.exports = function(options) {
var style, script = builder.scripts.require;
return function* builder(next) {
if (/build\.(js|css)/.test(this.url)) {
View stack.out
CPU ID FUNCTION:NAME
10 57934 :tick-60s
0x825c32c
0x8534229
0x85272b1
0xfed12dbd
0xfed12f50
1
@bodokaiser
bodokaiser / node-manifest.xml
Last active Aug 29, 2015
SmartOS service manifest for node applications.
View node-manifest.xml
<?xml version="1.0"?>
<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
<service_bundle type="manifest" name="node-app">
<service name="node/node-app" type="service" version="1">
<create_default_instance enabled="true"/>
<single_instance/>
<dependency name="network" grouping="require_all" restart_on="error" type="service">
<service_fmri value="svc:/milestone/network:default"/>
</dependency>
<dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
@bodokaiser
bodokaiser / node-init
Last active Aug 29, 2015
node init script without supervisor (supervisor takes a few resources)
View node-init
#!/bin/sh
#
# chkconfig: 35 99 99
# description: node.js /home/bodokaiser/tmp/<name>
#
. /etc/rc.d/init.d/functions
# application name
@bodokaiser
bodokaiser / bash_profile.sh
Last active Aug 29, 2015
Autoloader for janls cl add on
View bash_profile.sh
#!/bin/sh
# https://twitter.com/bodojs/status/476973611753152512
# https://twitter.com/bodojs/status/476974684974501888
# Bash Add-On Autoloader
[[ -d "$HOME/.bash" ]] || mkdir -p "$HOME/.bash"
[[ -f "$HOME/.bash/cl.sh" ]] || curl -o "$HOME/.bash/cl.sh" https://gist.githubusercontent.com/janl/e6ceb14ffcfca3556ba5/raw/b89254f3babe217bbdb085ad9a4df30cbbd6c1d8/cl.sh
source "$HOME/.bash/cl.sh"
@bodokaiser
bodokaiser / post-receive
Last active Aug 29, 2015
git post receive hook for nvm environments
View post-receive
#!/bin/bash
source $HOME/.bash_profile
set -u
set -e
# directory name
NAME=$(basename $(pwd) .git)