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 / 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)
@siers
siers / trans-console-railway.rb
Created April 8, 2013 09:59
send serialized data from one ruby console to another
def _open name, mode
fn = "/tmp/.marshal.store.#{ name.to_s.gsub(/[^\w]/, '') }"
File.open(fn, mode)
end
# burry some_data => :significant_name
def b opts
data, name = opts.first
name = name.chr if name.is_a? Fixnum # in case of b stuff => ?a for 1.8.7
(f = _open(name, 'w')).write((m = Marshal.dump(data)))
@siers
siers / script.js
Last active December 16, 2015 06:08
an attempt at signaling
$(function() {
"use strict";
function log() {
window.console && console.log.apply(console, arguments);
}
var thing = $("#victim");
var fns = {
// rotatable = c = (l | r | s); if r = s then nil -> movable else rotate(c) -> rotatable
@siers
siers / collect-times
Last active December 16, 2015 12:15
Vim startup time profiler
#!/bin/bash
while sleep 0.5; do vim --startuptime "$@" >(./startup-info) +qall; done
# usage: ./collect-times
# Running this will collect startup times in `times' directory.
# It will run it multiple times so that the averages start converging.
# Whenever you remove a plugin, it gets stored as a different version,
# which will be shown at 'watch ./watcher'.
@siers
siers / harmony-pump.rb
Last active December 22, 2015 04:39
Creates a MIDI file with chords, declared by a cryptic chord syntax.
#!/usr/bin/env ruby
# self(44aa 78ea 455d), /03.09.2013./
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@siers
siers / monad..hard.monad.hs
Created November 6, 2013 11:51
I did some monad magic, and it actually worked.
import Control.Monad.Loops
import System.Random
specifify :: Int -> Int
specifify i = i `mod` 100
use :: (Int, StdGen) -> IO StdGen
use (i, g) = (putStrLn $ "New rand int: " ++ show (specifify i)) >> return g
main = getStdGen >>= iterateM_ (use . random)
@siers
siers / scrot-select.c
Created December 2, 2013 19:38
I extracted the X selection making code from xclip and it resulted in this gist.
/*
Code is taken from scrot, and is currently having some
redundant code in it.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions: