Skip to content

Instantly share code, notes, and snippets.

View klaemo's full-sized avatar

Clemens Stolle klaemo

View GitHub Profile
@klaemo
klaemo / couch-stub.js
Created November 17, 2011 20:25
klaemo's couch problem
// this is a very simplified version of what's going on in my app
// First I parse some CSV file (into valid JSON)
parseFile(myfile, function(err, fileJSON) {
if(err) {
throw err;
} else {
// db is the connection to my couch server
db.save(fileJSON, function(err, response) {
@klaemo
klaemo / gist:1860089
Created February 18, 2012 16:34
express route conditional response
app.get('/users', function(req, res){
if (req.xhr) {
// respond with the each user in the collection
// passed to the "user" view
res.partial('user', users);
} else {
// respond with layout, and users page
// which internally does partial('user', users)
// along with other UI
res.render('users', { users: users });
@klaemo
klaemo / doc.json
Created April 1, 2012 16:15
sample result file
{
"hasThumbnail": true,
"result": {
"solidTone": {
"blk": {
"name": "Black",
"actDens-dE": [
[
1.698,
3.684
@klaemo
klaemo / gist:3710789
Created September 12, 2012 23:37
v8 deopt
// the function:
Helpers.prototype.round = function (num, decimals) {
decimals = decimals || this.precision
return Math.round( num * Math.pow(10, decimals) ) / Math.pow(10, decimals)
}
// snippet of the --trace-deopt output
**** DEOPT: Helpers.round at bailout #9, address 0x0, frame size 8
@klaemo
klaemo / gist:5382743
Created April 14, 2013 13:30
nodejitsu error
info: Creating snapshot 0.8.0-7
info Uploading: [=============================] 100%
info: Updating app print-io.de
info: Activating snapshot 0.8.0-7 for print-io.de
info: Starting app print-io.de
error: Error running command deploy
error: Nodejitsu Error (500): Internal Server Error
error:
error: There was an error while attempting to start the app
error: Error spawning drone
@klaemo
klaemo / initial.sh
Last active March 8, 2016 02:00
initial ubuntu server setup
printf '\e[1;34m%b\e[m' "\nUpdating the system...\n"
apt-get -y -qq update
DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" dist-upgrade
NEW_USER=${1:-admin}
SSH_PORT=${2}
if [ ! -d /home/${NEW_USER} ]; then
printf '\e[1;34m%b\e[m' "\nCreating user '$NEW_USER'...\n"
adduser --gecos "" $NEW_USER
@klaemo
klaemo / gist:8866044
Created February 7, 2014 16:17
boot2docker info
Name: boot2docker-vm
Groups: /
Guest OS: Linux 2.6 / 3.x (64 bit)
UUID: bc98eef8-e6ed-44c9-bc6f-5cbd59430c73
Config file: /Users/clemens/VirtualBox VMs/boot2docker-vm/boot2docker-vm.vbox
Snapshot folder: /Users/clemens/VirtualBox VMs/boot2docker-vm/Snapshots
Log folder: /Users/clemens/VirtualBox VMs/boot2docker-vm/Logs
Hardware UUID: bc98eef8-e6ed-44c9-bc6f-5cbd59430c73
Memory size: 1024MB
Page Fusion: off
@klaemo
klaemo / setup-docker-on-ubuntu.sh
Created February 8, 2014 12:55
Setup docker on ubuntu
printf '\e[1;34m%b\e[m' "\nInstalling Docker...\n"
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9
sh -c "echo deb http://get.docker.io/ubuntu docker main\
> /etc/apt/sources.list.d/docker.list"
apt-get -y update
apt-get -y install lxc-docker
printf '\e[1;34m%b\e[m' "\nConfiguring firewall for Docker...\n"
VirtualBox VM 4.3.8 r92456 darwin.amd64 (Feb 25 2014 18:04:29) release log
00:00:00.995066 Log opened 2014-02-26T14:54:00.135741000Z
00:00:00.995068 Build Type: release
00:00:00.995083 OS Product: Darwin
00:00:00.995090 OS Release: 13.1.0
00:00:00.995096 OS Version: Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64
00:00:00.995307 DMI Product Name: MacBookPro7,1
00:00:00.995416 DMI Product Version: 1.0
00:00:00.995426 Host RAM: 8192MB total, 5046MB available
00:00:00.995429 Executable: /Applications/VirtualBox.app/Contents/MacOS/VirtualBoxVM
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 3.13.3-tinycore64 (root@11238c149617) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #1 SMP Wed Feb 19 01:15:06 UTC 2014
Command line: loglevel=3 user=docker console=ttyS0 console=tty0 nomodeset norestore base initrd=/boot/initrd.img BOOT_IMAGE=/boot/vmlinuz64
e820: BIOS-provided physical RAM map:
BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
BIOS-e820: [mem 0x00000000000f0000-0x00000000000fffff] reserved
BIOS-e820: [mem 0x0000000000100000-0x000000003ffeffff] usable