Skip to content

Instantly share code, notes, and snippets.

View prasmussen's full-sized avatar

Petter Rasmussen prasmussen

View GitHub Profile
@prasmussen
prasmussen / gist:2890229
Created June 7, 2012 17:34
go-template-example
package main
import (
"fmt"
"bytes"
"text/template"
)
type Person struct {
Name string
@prasmussen
prasmussen / makepasswd.sh
Created June 15, 2012 10:15
Smartos shadow hash generator
#!/bin/bash
read -s -p "New Password: " password
echo
read -s -p "Re-enter new Password: " confirm
echo
if [ "$password" != "$confirm" ]; then
echo "Password don't match!"
exit 1
fi
#!/usr/bin/node
var args = process.argv;
if (args.length < 3) {
console.log("Usage: " + args[1] + " <text file>");
process.exit(1);
}
fs = require('fs');
fs.readFile(args[2], function(err, data) {
@prasmussen
prasmussen / test.js
Created October 25, 2012 16:23
wolfram module test
var time = require("./time.js");
time.now({callback: function(msg) {
console.log("This will be printed to irc:");
console.log(msg);
}});
@prasmussen
prasmussen / gist:4157259
Created November 27, 2012 21:39
snapshots cron
# * * * * * command to be executed
# ┬ ┬ ┬ ┬ ┬
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ └───── day of week (0 - 7) (0 or 7 are Sunday, or use names)
# │ │ │ └────────── month (1 - 12)
# │ │ └─────────────── day of month (1 - 31)
# │ └──────────────────── hour (0 - 23)
# └───────────────────────── min (0 - 59)
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <fcntl.h>
#define MB 1000 * 1000
#define GB 1000 * MB
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#define CMD_OFFSET 2
#define MAX_CMD_LENGTH 2048
int strlen_total(char **str, int length) {
WAN addr: 81.167.4.214
eth0 = LAN
$ ipv6calc --action 6rd_local_prefix --6rd_prefix 2a01:79c::/30 --6rd_relay_prefix 213.167.115.92/0 81.167.4.214
2a01:79d:469c:1358::/62
sudo ip tunnel add 6rdtun mode sit local 81.167.4.214 ttl 64
sudo ip tunnel 6rd dev 6rdtun 6rd-prefix 2a01:79c::/30
sudo ip link set 6rdtun up
@prasmussen
prasmussen / gist:10497516
Last active August 29, 2015 13:59
tmux.conf
# Set ctrl-a as prefix
set -g prefix C-a
unbind C-b
# ctrl-a passthrough by sending ctrl-a 2 times
bind C-a send-prefix
# Less delay
set -sg escape-time 1
postApiR :: Handler ()
postApiR = do
liftIO $ putStrLn "init"
payload <- requireJsonBody :: Handler Payload
now <- liftIO getCurrentTime
_ <- runDB $ insert $ Weather now (temperature payload) (humidity payload)
sendResponseStatus status201 ("CREATED" :: Text)