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 / nap.rb
Last active April 30, 2017 06:04
a more natural alarm clock command line interface
#!/usr/bin/env ruby
require 'time'
def die(str)
$stderr.puts str
exit
end
def usage
@siers
siers / demo
Created June 28, 2015 22:36
Extracts paragraphs to lines in files to allow generic operations be used
demo % cat file
1. Chox4ez9
Oov5iedeiF
ea7eapheeR
2. tu0ahTho
sheit5Kash
aiHiewae1i
3. Gau2Jesu
@siers
siers / git-stack-log.sh
Created December 29, 2014 03:06
git-stack-log
#!/bin/sh
stashes() {
git stash list | sed "s/:.*//" | tr '\n' ' '
}
for s in $(stashes); do
git log -1 --format=short "$s" | cat
echo
git stash show -u "$s" | cat
@siers
siers / skittles.diff
Created August 13, 2014 03:26
A diff for coreutils/src/ls.c to add a purple-colored skittles to every directory listing, even in ls -R.
diff --git a/src/ls.c b/src/ls.c
index cd5996e..102599b 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -2668,6 +2668,10 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
process_signals ();
}
+ total_blocks += gobble_file ("skittles", sock,
+ 0,
@siers
siers / send.c
Last active December 12, 2015 12:00
Obsoleted by xdotool at the time of its creation without me knowing for a couple of years.
// gcc -Wall -Wextra -ggdb -o send send.c
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
#include <X11/keysymdef.h>
@siers
siers / gen.hs
Created May 29, 2014 03:11
gnuplot-sphere.hs
import Numeric.Matrix hiding (map)
import Data.List.Split
import Text.Printf
type Rotation = Matrix D
rotMatrixX :: D -> Rotation
rotMatrixX rad = fromList . chunksOf 3 $
1 : 0 : 0 :
0 : cos rad : -sin rad :
@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:
@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 / 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 / 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