Skip to content

Instantly share code, notes, and snippets.

@mirhec
mirhec / IniFile.cs
Last active February 13, 2017 12:37
IniFile implementation based on the original Windows P/Invoke, grabbed from http://stackoverflow.com/a/14906422/4112816
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Text;
internal class IniFile // revision 11
{
readonly string _path;
readonly string _exe = Assembly.GetExecutingAssembly().GetName().Name;
@mirhec
mirhec / Ini.cs
Last active February 13, 2017 14:15 — forked from Larry57/ini.cs
A single class to read and write INI files.
using System;
using System.Collections.Generic;
using System.Linq;
internal class Ini
{
private readonly Dictionary<string, Dictionary<string, string>> _ini = new Dictionary<string, Dictionary<string, string>>(StringComparer.InvariantCultureIgnoreCase);
private string CurrentSection { get; set; } = "";
public Ini(string iniContents)
#!/bin/sh
cd ~
sudo apt-get update
sudo apt-get install netatalk git python-dev python-pip python-rpi.gpio -y
sudo pip install Flask
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
cd ..
git clone https://github.com/mirhec/raspi-http-switch.git
@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
@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
#!/usr/bin/env python2.7
import os
import sys
try:
authorized = False
directory = None
addr = None
with open('moveto.log', 'w') as f:
###
## 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 + "`"
###
## 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 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
###
## 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"