Skip to content

Instantly share code, notes, and snippets.

View sshine's full-sized avatar
🦀

Simon Shine sshine

🦀
View GitHub Profile
@sshine
sshine / osm-setup.sh
Created April 1, 2013 00:44
Notes on building GCC as a cross-compiler for MIPS
#!/bin/sh
set -e # Stop on first error
PREFIX=/opt/osm
tar xfz binutils-2.23.tar.gz
mkdir build-binutils; cd build-binutils
../binutils-2.23/configure --target=mips-elf --prefix=$PREFIX
make
sudo make install
(defun kb (k) (read-kbd-macro k))
(dolist (pair
'(("C-k" kill-whole-line)
("C-n" dabbrev-expand)
("C-x C-g" goto-line)
("C-<tab>" next-multiframe-window)
))
(global-set-key (kb (car pair)) (cadr pair)))
(* 4M1 *)
local
val jens = PLAYER "Jens"
val mette = PLAYER "Mette"
val ian = PLAYER "Ian"
val helle = PLAYER "Helle"
val yuan = PLAYER "Yuan"
val anne = PLAYER "Anne"
val yasmin = PLAYER "Yasmin"
datatype bentSpil = BentSlutter of int
| BentSpiller of ingeSpil list
and ingeSpil = IngeSlutter of int
| IngeSpiller of bentSpil list
(* bent8 *)
local
val inge3 = IngeSpiller [ BentSlutter 0 ]
val inge4 = IngeSpiller [ BentSlutter 0, BentSlutter 1 ]
datatype bentSpil = BentSlutter of int
| BentSpiller of ingeSpil list
and ingeSpil = IngeSlutter of int
| IngeSpiller of bentSpil list
(* bent8 *)
val inge3 = IngeSpiller [ BentSlutter 0 ]
val inge4 = IngeSpiller [ BentSlutter 0, BentSlutter 1 ]
-module(simple_chatserver).
-export([start/0]).
-define(PORT, 33333).
% External API function for starting chat server
start() ->
% Start a process for coordinating communication between clients
CoordinatorPid = spawn(fun() -> coordinator(dict:new()) end),
% Listen to a TCP socket and start a process that accepts incoming
-module(simple2).
-export([start/0]).
-define(PORT, 33333).
start() ->
{ok, spawn(fun listener/0)}.
listener() ->
ChatMaster = spawn(fun() -> chatmaster(dict:new()) end),
{ok, ListenSocket} = gen_tcp:listen(?PORT, [binary, {active, true}]),
local
fun fbstr i =
case (i mod 3 = 0, i mod 5 = 0) of
(true , true ) => "FizzBuzz"
| (true , false) => "Fizz"
| (false, true ) => "Buzz"
| (false, false) => Int.toString i
fun fizzbuzz' (n, j) =
{
(* A position in a file is identified as a (line,column) : int * int *)
type position = int * int
(* Lexical errors have some error message and a position in the file *)
exception LexicalError of string * position (* (message, (line, column)) *)
(* While scanning the file, line numbers and the character offset (the integer
position for the character in the file) for each beginning line are kept
# RISK Attack Simulation
attack <- function(na, nb) {
die <- 1:6
while (na > 0 & nb > 0) {
attackers <- min(na, 3)
defenders <- min(nb, 2)
fights <- min(attackers, defenders)
hit_a <- sort(sample(die, attackers), decreasing=T)[1:fights]