Skip to content

Instantly share code, notes, and snippets.

View archie's full-sized avatar
😃

Marcus Ljungblad archie

😃
View GitHub Profile
@archie
archie / playcount.py
Created April 19, 2012 16:30
Playcount.py
import sys
import random
import math
if len(sys.argv) != 3:
print "Usage: ./playcount.py <file_to_parse> <output_counts_to_file>"
exit(1)
countmap = {}
@archie
archie / gist:1922816
Created February 27, 2012 09:38
Signature Matrix Creation
def createSignatureMatrix(characterMatrix: Array[Array[Int]], hashFunctions: List[HashFunction]): Array[Array[Int]] = {
val signatureMatrix: Array[Array[Int]] = createEmptySignatureMatrix(hashFunctions.length, characterMatrix(0).length)
characterMatrix.zipWithIndex.foreach { case (row, i) =>
row.zipWithIndex.foreach { case (character, j) =>
/* only apply hash functions if character is not 0 */
if (character == 1) {
hashFunctions.zipWithIndex.foreach { case (hasher, k) =>
val hashedRowValue: Int = hasher.apply(i)
if (isReplaceable(signatureMatrix(k)(j), hashedRowValue)) {
signatureMatrix(k)(j) = hashedRowValue
@archie
archie / mf.py
Created January 17, 2012 14:58
Simple Matrix Factorization
#!/usr/bin/python
#
# Created by Albert Au Yeung (2010)
# Updated by Marcus Ljungblad (2012)
#
# An implementation of matrix factorization
#
try:
import numpy
@archie
archie / dummy.erl
Created November 29, 2011 20:31
Dummy application that use gaoler
-module(dummy).
-export([important_task/0]).
important_task() ->
gaoler:acquire(beer),
drink_beer(),
gaoler:release(beer).
drink_beer() ->
io:format("I'm a happy application!", []).
@archie
archie / xor.c
Created September 27, 2011 12:05
Xor arbitrary number of files hack
#include <stdlib.h>
#include <stdio.h>
int xor_files(FILE *files[], int number_of_files, char *outputfilename) {
int file_index;
int x = 0;
FILE* output;
output = fopen(outputfilename, "wb");
@archie
archie / cmov_summaries.txt
Created June 5, 2011 16:27
Mobile Computing Paper summaries
- Some computer science issues in Ubiquitous computing (M. Weiser)
Takes inspiration from everyday objects and how we interact with them such that the interaction is unconscious and non-intrusive. The objects of interaction are proactive in a way that makes humans "think less". Developed three prototypes: Tab (post-it like), Pad (think iPad), and Smartboard (interactive whiteboard). Identified X areas for future work: 1) Hardware - such as pens, battery life, wireless scalability. 2) Network protocols - media access, real-time capabilities, mobile IP. 3) Interaction substrates - surface on which users can pass commands, other ways of passing commands (speaking), separating view from logic, moving views around. 4) Applications - location-awareness, context-aware, collaboration, not only technical challenges. 5) Privacy - what information is the user willing to share, number of devices increasing, voluntary vs involuntary sharing. 6) Computational Methods - caching, disconnected operations.
- Pervasive Compu
@archie
archie / mover.py
Created May 11, 2011 23:25
Updating Android Emulator gps coordinates using Telnet
# Script to instruct Android emulator to move to coordinates
# Heavily inspired by @pauloricardomg's GPS-server
# Parses a file that contains lat-long tuples, i.e "-91.7674044575329,73.90620635916805"
# KML files can be converted using:
# cat file.kml | grep coordinates | sed 's/.*>\(.*\),0/\1/;s/<\/coordinates>//g' > coords.out
# Hacked by @mljungblad
import socket
@archie
archie / gist:950442
Created May 1, 2011 11:48
My .bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
import os, glob
import subprocess
path = 'cases/ex/'
if len(sys.argv) > 1:
path = sys.argv[1]
files = glob.glob(os.path.join(path, '*.txt'))
times = []
times_all = {}
/* API Mapping ---------------------------------------------------------------*/
#ifndef RTE_CORE
#define Rte_Receive_RXIface1_RxSig001 Rte_Receive_SwcPubSub_RXIface1_RxSig001
#define Rte_Write_TxIface1_TxSig001 Rte_Write_SwcPubSub_TxIface1_TxSig001
#define Rte_Feedback_TxIface1_TxSig001 Rte_Feedback_SwcPubSub_TxIface1_TxSig001
#define Rte_Pim_mem() ((Rte_Inst_SwcPubSub->Pim_mem))
#endif
/* Port handle API Mapping ---------------------------------------------------*/
#ifndef RTE_CORE