Skip to content

Instantly share code, notes, and snippets.

@mkrogh
mkrogh / SimpleTemplate.rb
Created September 1, 2014 12:00
A simple template for smaller template files.
class SimpleTemplate
attr_accessor :token_start, :token_end
def initialize(file)
@content = open(file).read
@token_start = "{{"
@token_end = "}}"
@token_status = :on
end
def replace(token,content)
@mkrogh
mkrogh / jsconnect.php
Last active August 29, 2015 14:07
SimpleSAMLphp and jsConnect
<?php
header('Content-type: application/javascript');
require_once('../../lib/_autoload.php');
require_once dirname(__FILE__).'/functions.jsconnect.php';
$clientID = "saml-login";
$secret = "TOP_SECRET!";
$as = new SimpleSAML_Auth_Simple('default-sp');
@mkrogh
mkrogh / vanilla-upgrade.sh
Last active August 29, 2015 14:08
Simple upgrate script for vanilla forums (2.1)
#!/bin/bash
if [ "$#" -ne 2 ]; then
echo "Usage: sudo $(basename $0) /path/to/updated_vanilla_git/ /path/to/current_vanilla_installation/"
exit 1
fi
new_vanilla=$1
install_dir=${2:=/var/www/vanilla/}
tmp=/tmp
branch=2.1
http_group=www-data
@mkrogh
mkrogh / modules.json
Created January 9, 2015 14:03
A simple js include
[
"js/util/dom-creator.js",
"js/main.js"
]

Keybase proof

I hereby claim:

  • I am mkrogh on github.
  • I am mkrogh (https://keybase.io/mkrogh) on keybase.
  • I have a public key whose fingerprint is 9C3F 46F4 FEC5 8097 D8CC 65E9 981B 1E5E B208 0BDC

To claim this, I am signing this object:

@mkrogh
mkrogh / aliases
Created June 10, 2015 12:59
A collection of useful bash aliases.
# git
alias gits='git status -uno' #don't show untracked files
# OpenSSL
function ssltest() {
local SN=${2:-1}
echo QUIT | openssl s_client -showcerts -connect $1:443 -servername $SN | grep -A 1 "s:/"
}
alias ssltest=ssltest

NORDUnet NI 2.0 router hardware model

// Create nodes
CREATE (router1:Physical:Router{name:'Router1', serial_number:'1'}),
       (midplane:Physical:Module{name:'Midplane', model_number:'CHAS-1'}),
       (fpmDisplay:Physical:Module{name:'FPM Display', model_number:'CRAFT-MX80-S'}),
from chinchilla import *
import time
GREEN = "\x1b[32m"
RED = "\x1b[31m"
ORANGE = "\x1b[33m"
RESET = "\x1b[0m"
success,error = 0,0
def check_link(txt,content):
global success, error
@mkrogh
mkrogh / gist:1220514
Created September 15, 2011 21:22
Markdown syntax oddity

One would suspect that the following markdown code would yield first an un-ordered list followed by an ordered list.

  • An item
  • Another item
  • Just an extra item to make it interesting
  1. First you would expect this ordered list item to be a separate list due to the double linebreak
  2. Secondly you would not expect the above item to be wrapped in a paragraph tag.
@mkrogh
mkrogh / ruby-1.8.7.rb
Created January 12, 2012 21:32
rubyzip + open-uri (1.8.7 and 1.9.2)
require "open-uri"
require "zip/zip"
img_url = "http://jquery.com/demo/thickbox/images/plant4.jpg"
img_name = "plant4.jpg"
#this works in 1.8.7, but not in 1.9.2:
Zip::ZipFile.open("test.zip", Zip::ZipFile::CREATE) do |zipfile|
img = open(img_url)
zipfile.add(img_name, img.path)