This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdint.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
#define MKEY(size, keys) ((keys)|((size)<<5)) | |
#define MSIZE(m) ((m)>>5) | |
#define MSEQ(m) ((m)&0x1f) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HeaderType | |
attr_reader :header | |
ATTRS = {string: :string, int: :int, number: :int, integer: :int } | |
def initialize | |
@header = [] | |
end | |
# Define methods string, integer, etc., | |
# for schema definition dynamically | |
class_eval do | |
ATTRS.each do |attr, type| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <avr/io.h> | |
void changeFrequency(unsigned int freq) | |
{ | |
int ocr = F_CPU/freq-1; | |
cli(); | |
TCCR1A = _BV(COM1A0); | |
OCR1A = ocr; | |
sei(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <inttypes.h> | |
#include <string.h> | |
#include <fcntl.h> | |
#include <linux/fb.h> | |
#include <sys/mman.h> | |
#define RGB565(r, g, b) (uint16_t)(b|(g<<5)|(r<<11)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set PATH=%PATH%;"C:\Program Files\Java\jdk1.7.0_25\bin" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
screens = `screen -ls` | |
screens.lines do |l| | |
if l =~ /\s+(\d+)\./ | |
puts "Attaching to screen #{$1}..." | |
`screen -x #{$1}` | |
exit 1 | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make_pi :: Int -> Double | |
make_pi n = product [2.0/(a x)|x <- [0..n]] where | |
a 0 = 1.0 | |
a 1 = sqrt 2 | |
a n = sqrt(2+(a (n-1))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# A very simple and awesome Lisp interpreter in ruby | |
# Usage: | |
# require './rb_lisp.rb' | |
# RBLisp::Interpreter.new("(print (+ 5 (* 99 5)))") # => will print 500 | |
module RBLisp | |
class Value | |
attr_accessor :type, :value | |
def initialize(args) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module MyList where | |
data MyList a = Cons a (MyList a) | |
| MyNil deriving (Show, Eq) | |
{- | |
A simple linked list module | |
Some examples: | |
mylist = (Cons 10 (Cons 99 (Cons 11 (Cons 1 MyNil)))) | |
myHead myList # => 10 | |
myTail myList # => Cons 99 (Cons 11 (Cons 1 MyNil)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main where | |
import System.Environment (getArgs) | |
import Data.List | |
import Matrix | |
import IO | |
main :: IO () | |
main = do | |
hSetBuffering stdout NoBuffering |