Skip to content

Instantly share code, notes, and snippets.

View osvein's full-sized avatar

Oskar Sveinsen osvein

  • Norway
View GitHub Profile
@osvein
osvein / LogiLCDImport.cs
Last active August 29, 2015 14:08
Logitech LCD SDK imported from unmanaged dynamic-link library to managed .NET in C#
using System;
using System.Runtime.InteropServices;
public static class LogiLCDImport
{
public static const int MonochromeLCDWidth = 160;
public static const int MonochromeLCDHeight = 43;
public static const int ColorLCDWidth = 320;
public static const int ColorLCDHeight = 240;
@osvein
osvein / Math.asm
Last active August 29, 2015 14:16
Basic arithmetic operators for Hack
(MULTIPLY)
(MULTIPLY.LOOP)
// return if j is greater than or equals to 16
@j
D=M
@16
D=D-A
@R0
D;JGE
@osvein
osvein / multigitdo.sh
Created April 18, 2015 08:57
A collection of scripts for handling multiple Git repositories with ease
#!/usr/bin/env bash
# Perform a command for each repository
# Standard input is the list of repositories, seperated by newline
# Argument 1 is the command to perform for each repository
while read repo; do
echo $repo
cd $repo
eval $1
sed -i 's.</projectDescription>.\t<linkedResources>\r\n\t\t<link>\r\n\t\t\t<name>lib</name>\r\n\t\t\t<type>2</type>\r\n\t\t\t<locationURI>$%7BPARENT-1-PROJECT_LOC%7D/lib</locationURI>\r\n\t\t</link>\r\n\t</linkedResources>\r\n</projectDescription>\r\n.g' .classpath
@osvein
osvein / Veier til god helse - oppgaver.md
Last active August 29, 2015 14:19
Veier til god helse - vitenskap og kjerringråd

Kroppens forsvar mot inntrengere

Hvilken oppgave har slimhinnene? Slimhinnene er en del av det ytre forsvaret, og har ansvaret for å hindre inntrengere på steder det normalt ikke er hud. De utskiller surt sekret som dreper bakteriene.

Hvor dannes de hvite blodcellene? De hvite blodcellene dannes hovedsakelig i beinmargen i skjelettet.

Hvordan kan vi forebygge infeksjonssykdommer?

Hva er inkubasjonstid? Inkubasjonstid er perioden fra man blir smittet av en sykdom til den bryter ut. I denne perioden er man smittebærer og kan bringe sykdommen videre.

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.sshd.SshServer;
import org.apache.sshd.common.Factory;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import org.apache.sshd.server.PasswordAuthenticator;
@osvein
osvein / mave.sh
Last active August 29, 2015 14:21
"Mave" Bukkit plugins
#!/usr/bin/env bash
groupId=$(cat src/plugin.yml | grep '^main: .*$' | sed 's/^main: //g' | sed 's/.[^.]*$//g')
name=$(cat src/plugin.yml | grep '^name: .*$' | sed 's/^name: //g')
artifactId=$(echo $name | tr '[:upper:]' '[:lower:]')
version=$(cat src/plugin.yml | grep '^version: .*$' | sed 's/^version: //g')
description="$1"
inceptionYear="$2"
# backup

Welcome. Welcome to City 17. You have chosen, or been chosen, to relocate to one of our finest remaining urban centers.

I thought so much of City 17 that I elected to establish my administration here, in the citadel so thoughtfully provided by our benefactors. I've been proud to call City 17 my home.

And so, whether you are here to stay, or passing through on your way to parts unknown: Welcome to City 17. It's safer here.

public class KitPlugin extends JavaPlugin {
private final ConcurrentHashMap<String, Kit> kits = new ConcurrentHashMap<>();
@Override
public void onEnable() {
this.saveDefaultConfig();
// read configuration
ConfigurationSection kitsConfig = this.getConfig().getConfigurationSection(CONFIG_KITS);
for (String kitName : kitsConfig.getValues(false).keySet()) {
@osvein
osvein / unsuball.js
Last active April 2, 2016 14:23
Quickly unsubscribe all Steam Workshop subscriptions listed on a page (using JavaScript console)
/*
* This is free and unencumbered software released into the public domain.
*
* Anyone is free to copy, modify, publish, use, compile, sell, or
* distribute this software, either in source code form or as a compiled
* binary, for any purpose, commercial or non-commercial, and by any
* means.
*
* In jurisdictions that recognize copyright laws, the author or authors
* of this software dedicate any and all copyright interest in the