Skip to content

Instantly share code, notes, and snippets.

View siers's full-sized avatar
:octocat:

Raitis Veinbahs siers

:octocat:
View GitHub Profile
@siers
siers / Gamma.rb
Last active April 24, 2021 20:20
Plays from sol to sol.
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# Primitive NoteFactory.
# http://en.wikipedia.org/wiki/Piano_key_frequencies
T = 44000
class NoteFactory
attr_accessor :notes, :notes_in_octave
@siers
siers / backgammon-distribution.rb
Created August 28, 2012 13:13
Dice sum distribution
#!/usr/bin/env ruby
T = 50000
def n
rand(6) + 1
end
def title(x)
puts x
puts "*" * x.length
@siers
siers / extract.rb
Created September 26, 2012 20:52
Savelk kompaktus pasaku HTMLus.
#!/usr/bin/env ruby
# encoding: utf-8
require 'nokogiri'
require 'pry'
def wrap(title, content)
<<-TEMPLATE
<!DOCTYPE html>
<html>
@siers
siers / physics.rb
Created October 23, 2012 21:48
Catching object in orbit with variable catcher force
#!/usr/bin/env ruby
require 'matrix'
module Drawing
ZOOM = 0.5
SCALE = 40
def clear
@@clear ||= %x{clear}
@siers
siers / mmap.c
Created January 19, 2013 12:26
mmap for darwin and linux(might work on some other platforms too)
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <assert.h>
#include <fcntl.h>
#include <sys/mman.h>
#define SHMLEN sizeof(int) * 2
#define TIMES 30
@siers
siers / update.rb
Created February 28, 2013 11:27
Fetches and assembles timetable from school's website into a more usable form.
#!/usr/bin/env ruby
require 'rubygems'
require 'pry'
require 'nokogiri'
require 'mini_magick'
require 'digest'
W = 412
H = 600
@siers
siers / fjzz
Created March 11, 2013 10:25
find me some jazz from reddit, requires ack, zsh
#!/bin/zsh
surl="http://www.reddit.com/r/jazz/search?q=%s&restrict_sr=on&sort=relevance&t=all"
url="http://www.reddit.com/r/jazz/"
find() {
curl -s $1 | ack -o "https?://(www.)?youtu[^'\"&]+"
}
parse() {
@siers
siers / rails-daemon-wrapper.sh
Created March 14, 2013 13:12
wrapper for rails -d functionality
r() {
if [ -z "$1" ]; then
rails
return
fi
case "$1" in
start)
shift
rails s -d "$@"
@siers
siers / digital.rb
Created March 30, 2013 18:57
answer to the question how do I draw digital numbers in ruby?
#!/usr/bin/env ruby
$, = ' '
class Digits
RAW = [
" 111 ",
"4 2",
"4 2",
" 333 ",
@siers
siers / mixin.coffee
Created April 2, 2013 06:51
I want dem mixins in mai coffeescripts whenever I have jQuery.
importize = (mixin, module) ->
$.extend($.extend({}, mixin), module)