Skip to content

Instantly share code, notes, and snippets.

module.exports =
rethinkdb:
host: 'localhost',
port: 28015,
authKey: '',
db: 'rethinkdb',
tables: [
{
name: 'todos',
indices: ['createdAt']
init = require './init'
# ...
init.createDbIfNotExists()
r = require 'rethinkdb'
config = require './config'
module.exports =
###
## This creates the db. If there occurs an error
## it will be printed out. If it succeeds, the
## callback next will be called.
###
createDb: (next) ->
###
## Check if database exists. If it does not exist
## create it and create all tables and indices.
## The names of the Db, tables and indices are
## specified in config.coffee
###
createDbIfNotExists: () ->
r.connect config.rethinkdb, (err, connection) =>
if err
console.log "Could not open a connection to initialize the database"
###
## This creates the db. If there occurs an error
## it will be printed out. If it succeeds, the
## callback next will be called.
###
createDb: (next) ->
r.dbCreate(config.rethinkdb.db).run @conn, (err, result) =>
if (err) and (not err.message.match(/Database `.*` already exists/))
console.log "Could not create the database `" + config.db + "`"
console.log err
###
## This creates the given table. The table param
## is either a string with the table name or an
## object with at least one parameter 'name' and
## optional the indices to create as string array.
## If there occurs an error it will be printed out.
## If it succeeds, the callback next will be called.
###
createTable: (table, next) ->
if typeof(table) is 'string'
###
## This creates the given index for the given
## table. If there occurs an error
## it will be printed out. If it succeeds, the
## callback next will be called.
###
createIndex: (tableName, indexName, next) ->
r.table(tableName).indexCreate(indexName).run @conn, (err, result) =>
if (err) and (not err.message.match(/Index `.*` already exists/))
console.log "Could not create the index `" + tableName + "." + indexName + "`"
#!/usr/bin/env python2.7
import os
import sys
try:
authorized = False
directory = None
addr = None
with open('moveto.log', 'w') as f:
@mirhec
mirhec / install_fish.sh
Last active December 12, 2016 15:55 — forked from mamiu/install_fish.sh
Fish shell installer for uberspace.
#!/bin/bash
cd ~
# install linuxbrew
git clone https://github.com/Linuxbrew/brew.git ~/.linuxbrew
echo "PATH=\"$HOME/.linuxbrew/bin:$PATH\"" >> ~/.bashrc
echo "MANPATH=\":$HOME/.linuxbrew/share/man:$MANPATH\"" >> ~/.bashrc
echo "INFOPATH=\"$HOME/.linuxbrew/share/info:$INFOPATH\"" >> ~/.bashrc
@mirhec
mirhec / install_fish_debian.sh
Created December 21, 2016 20:09 — forked from mamiu/install_fish_debian.sh
Install fish shell in Debian 8 (commands from the original fish shell website).
#!/bin/bash
echo 'deb http://download.opensuse.org/repositories/shells:/fish:/release:/2/Debian_8.0/ /' >> /etc/apt/sources.list.d/fish.list
apt-get update
wget -qO - http://download.opensuse.org/repositories/shells:fish:release:2/Debian_8.0/Release.key | apt-key add -
apt-get update
apt-get install -y fish