Skip to content

Instantly share code, notes, and snippets.

View nsmaciej's full-sized avatar
🙂
o awen pona

Maciej Goszczycki nsmaciej

🙂
o awen pona
View GitHub Profile
@nsmaciej
nsmaciej / gist:8229078
Last active January 2, 2016 01:18
A very simple rotating turret for Spacejs.org
var turn = 20;
on('start', function(){
ship.ready();
});
on('turn', function(){
//Show current life
utils.print('Life' + ship.life)
//Turn by 20deg
@nsmaciej
nsmaciej / dijkstra.hs
Created January 22, 2014 18:56
Dijkstra algorithm in Haskell.
import System.Environment
import Control.Applicative
check :: Int
check = -1
type Nodeid = Int
type Node = Int
type Graph = [(Node, [Edge])]
data Edge = Edge { enid :: Nodeid
, eprice :: Int } deriving (Show)
@nsmaciej
nsmaciej / .xinitrc
Last active July 13, 2016 16:29
My first try at Xmonad. It's awesome!
xsetroot -cursor_name left_ptr
xrdb ~/.Xdefaults
xmodmap ~/.Xmodmap
xcompmgr -c -l -8 -t -8 -o .50 -r 6 &
sleep 2 && (~/Dotfiles/Bin/8bitday.sh >> /tmp/8bitday.log 3>&1 &)
xrandr --output VGA1 --auto --above LVDS1
exec /home/mgoszcz2/.cabal/bin/xmonad
@nsmaciej
nsmaciej / floodfill.hs
Created February 18, 2014 18:58
Flood fill in Haskell! ^_^
import Data.Array
type Point = (Int, Int)
lo, hi :: Array Point Int -> Point
lo a = fst $ bounds a
hi a = snd $ bounds a
outOfBounds, emptyPoint, takenPoint :: Array Point Int -> Point -> Bool
outOfBounds a (x, y)
@nsmaciej
nsmaciej / inpu.txt
Created February 21, 2014 16:32
Borken knapsack (input in input.txt below)
5 3
1 6
2 10
3 12
@nsmaciej
nsmaciej / artclass.c
Last active August 29, 2015 13:56
artclass.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <limits.h>
#include <math.h>
//#define DEBUG
#define max(_a, _b) (_a > _b ? _a : _b)
@nsmaciej
nsmaciej / list.c
Last active August 29, 2015 13:56
Single linked list in C
typedef struct Node {
struct Node *next;
int val;
} Node;
typedef struct {
int length;
Node *next;
} List;
@nsmaciej
nsmaciej / q2.c
Created February 21, 2014 22:05
AIPO2013 q2 bad solution
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
bool appToParis(unsigned self[3][2], unsigned len, unsigned val1, unsigned val2){
unsigned i = 0;
for(i = 0; i<len; ++i){
if((self[i][0] == val1 && self[i][1] == val2) || (self[i][0] == val2 && self[i][1] == val1)){
return false;
}
@nsmaciej
nsmaciej / s1.c
Created February 22, 2014 18:47
s1.c
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define each(_a, _b) for (_a = 0; _a < _b; ++_a)
bool dow(int a, int b, int c, int x) {
return 0 == a*(x*x) + b*x + c;
}
@nsmaciej
nsmaciej / s2.c
Created February 22, 2014 18:59
s2.c
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#define each(a, b) for (a = 0; a < b; ++a)
int a = 1;
char getValid(void) {
char a;