Skip to content

Instantly share code, notes, and snippets.

View Tritlo's full-sized avatar

Matthías Páll Gissurarson Tritlo

View GitHub Profile
@Tritlo
Tritlo / DCPU16A.py
Created April 22, 2012 05:35
Rudimentary assembler for the DCPU-16
#Matthias Pall Gissurarson/Tritlo's Assembly Compiler for the DCPU-16 22. april 2012
#Use at your own risk.
import sys
import argparse
#Tekur inn hex int, skilar lista af lengd n
def hexToBin(hexint, n):
v = int(hexint,16)
l = [0]*n
@Tritlo
Tritlo / countdown.c
Created May 14, 2012 23:18
Diablo III countdown
#include <stdio.h>
#include <time.h>
#ifdef __unix__
int clear()
{
system("clear");
return 0;
}
#elif defined _WIN32
@Tritlo
Tritlo / 2x.py
Last active October 7, 2015 14:58
A program that finds numbers which when multiplied by two give the number with the last digit put to the front
# Matthias Pall Gissurarson 26. jul 2012
#Copyright (C) 2012 Matthías Páll Gissurarson
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM
@Tritlo
Tritlo / xmonad.hs
Created February 20, 2013 00:48
My current xmonad.hs
import XMonad
--Fyrir gnomepanel
import XMonad.Config.Gnome
import XMonad.Hooks.ManageDocks
import XMonad.Util.Run(spawnPipe)
import System.IO
import XMonad.Hooks.DynamicLog
@Tritlo
Tritlo / PrufuGen.java
Last active December 14, 2015 01:09
A small program that generates variables for Xilinx testbenches, written when I was in digital design.
#Copyright (C) 2012 Matthías Páll Gissurarson
#Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
#The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWA
@Tritlo
Tritlo / McCabeCounter.py
Last active December 14, 2015 15:28
A program that calculates the (McCabe complexity)[https://en.wikipedia.org/wiki/McCabe_complexity] of python programs in a directory and subdirectories. Usage: python McCabeCounter.py directory
#!/usr/bin/python
#encoding utf-8
import sys, os
from itertools import takewhile
def getFuncs(filename, funcDef = "def "):
lines = open(filename,'r').readlines()
funcDefIn = lambda line: True if line.strip().startswith(funcDef) else False
funcs = map(lambda i: [lines[i]] + list(takewhile(lambda x: not funcDefIn(x),lines[i+1:])),filter(lambda i: funcDefIn(lines[i]),range(len(lines))))
# grabs lines until start of next func/end of file lines where functions start
@Tritlo
Tritlo / Heroku.hs
Created November 12, 2013 22:50
Heroku helper for haskell
module Helpers.Heroku (herokuConf) where
import Prelude
import Data.ByteString (ByteString)
import Data.Text (Text)
import Data.Text.Encoding (encodeUtf8)
import Database.Persist.Postgresql (PostgresConf(..))
import Web.Heroku (dbConnParams)
import qualified Data.Text as T
@Tritlo
Tritlo / PlyReader.js
Last active October 27, 2022 07:40
A reader for PLY files for WebGL. Only reads points and normals, currently.
//PlyReader.js (C) 2014 Matthias Pall Gissurarson.
//Partially based on https://github.com/gnomeby/canvas3D, which has no License.
/*
The MIT License (MIT)
Copyright (c) 2014 Matthias Pall Gissurarson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
@Tritlo
Tritlo / cVimrc
Last active August 29, 2015 14:03
cVimrc
map D scrollFullPageDown
map E scrollFullPageUp
map <leader>bh previousTab
map <leader>bl nextTab
map <leader>bn :tabnew<CR>
map <leader>bd :execute x<CR>
let mapleader="<Space>"
map <C-e> E
map <C-d> D
map <C-u> e
### Keybase proof
I hereby claim:
* I am tritlo on github.
* I am mpgis (https://keybase.io/mpgis) on keybase.
* I have a public key whose fingerprint is 050D 101B 1677 E442 C1E1 7659 F365 878C C03C DDFD
To claim this, I am signing this object: