Skip to content

Instantly share code, notes, and snippets.

View david-bergstrom's full-sized avatar

David Bergström david-bergstrom

View GitHub Profile
@david-bergstrom
david-bergstrom / choose.cpp
Last active August 29, 2015 14:10
A simple algorithm for calculating the binomial coefficient written i C++.
#include <iostream>
int choose(int n, int k)
{
if(k > n)
return -1;
else if(k > n - k)
return choose(n, n - k);
else if(k == 1)
return n;
@david-bergstrom
david-bergstrom / superset.hs
Last active August 29, 2015 14:10
An implementation of a superset algorithm, give it a list of elements and it will give you all the possible subsets of it.
superset [] = [[]]
superset (x:xs) = rest ++ [x : l | l <- rest]
where rest = superset xs
@david-bergstrom
david-bergstrom / u1.patch
Last active August 29, 2015 14:11
u1.patch
--- config.def.h 2011-12-19 16:02:46.000000000 +0100
+++ config.h 2014-12-16 18:56:14.428360000 +0100
@@ -46,8 +46,8 @@
#define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } }
/* commands */
-static const char *dmenucmd[] = { "dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
-static const char *termcmd[] = { "uxterm", NULL };
+static const char *dmenucmd[] = { "~/dwm/install/usr/local/bin/dmenu_run", "-fn", font, "-nb", normbgcolor, "-nf", normfgcolor, "-sb", selbgcolor, "-sf", selfgcolor, NULL };
+static const char *termcmd[] = { "mate-terminal", NULL };
@david-bergstrom
david-bergstrom / dmenu_run.patch
Last active August 29, 2015 14:11
dmenu_run.patch
--- dmenu_run.ord 2014-12-16 19:10:45.697211000 +0100
+++ dmenu_run 2014-12-16 19:11:09.301515000 +0100
@@ -10,6 +10,6 @@
if stest -dqr -n "$cache" $PATH; then
stest -flx $PATH | sort -u | tee "$cache" | dmenu "$@"
else
- dmenu "$@" < "$cache"
+ ~/dwm/install/usr/local/bin/dmenu "$@" < "$cache"
fi
) | ${SHELL:-"/bin/sh"} &
@david-bergstrom
david-bergstrom / dwm-installer.sh
Created December 16, 2014 18:26
dwm installer
#/bin/bash
# Authors Simon and David
# Go to the correct directory
mkdir ~/dwm
cd ~/dwm
# Download the things
wget http://dl.suckless.org/dwm/dwm-6.0.tar.gz
# Unpack the tar
tar xvf dwm-6.0.tar.gz
#!/bin/bash
cd userprog/build
COUNTER=0
while [ $COUNTER -lt 10 ]; do
echo Running the program for the $COUNTER time.
pintos -v --qemu -- -q run 'pfs' > output_$COUNTER
pintos -v --qemu -- -q cat messages > messages_$COUNTER
tail +12 messages_$COUNTER | head -313 | cut -c 60-75 | tr '\n' '\0' | tr '.' ' ' > messages_cropped_$COUNTER
echo "Number of words:"
wc messages_cropped_$COUNTER
@david-bergstrom
david-bergstrom / pointer.c
Created April 13, 2015 07:14
A small example of pointers of pointers in comparison pointers of instances.
struct Wheel {
int number;
};
struct Car {
struct Wheel* wheel_pointer;
struct Wheel wheel_instance;
};
int main() {
@david-bergstrom
david-bergstrom / choose.hs
Last active August 29, 2015 14:20
An algorithm for calculating the binomial coefficient written i Haskell.
choose n 1 = n
choose n k
| k > n = -1
| k > n - k = choose n (n - k)
| otherwise = ((choose n (k - 1)) * (n - k + 1)) `div` k
#!/bin/python2
# -*- coding: utf-8 -*-
# Author: David Bergström
#
# This script contacts the given gitlab servers and retreives a list
# of all git repositories the user has access to. It then proceeds and
# runs "git clone --mirror" on all the repositories, creating a backup
# of all the repositories.
#
@david-bergstrom
david-bergstrom / tddd37-mysql-howto.md
Last active December 2, 2015 08:56
En kort beskrivning för hur man sätter upp MySQL smidigt

Hur man sätter upp MySQL

Installera först MySQL och starta det. Sedan för att logga in första gången: mysql -u root -p

Använd följande kommando för att skapa en användare med tillåtelse att göra allt:

CREATE USER 'david'@'localhost' IDENTIFIED BY '1234';