Skip to content

Instantly share code, notes, and snippets.

View yfyf's full-sized avatar

Ignas Vyšniauskas yfyf

View GitHub Profile
@yfyf
yfyf / .bashrc
Last active December 21, 2015 16:29
.bashrc hack for preserving shell directory in newly opened shells
# there's probably a nicer way to do this, but anyway:
# path where to hold the last cwd
SUPER_CWD_FILE=/tmp/scwd
# store the cwd on each command
export PROMPT_COMMAND="pwd > $SUPER_CWD_FILE; $PROMPT_COMMAND"
# restore the cwd when starting a new shell
[ -r $SUPER_CWD_FILE ] && cd `cat $SUPER_CWD_FILE`
@yfyf
yfyf / ccalc.c
Last active December 23, 2015 12:59 — forked from motiejus/calc.c
A pointless, but epic C vs Haskell battle!
/*
* Byte calculator. Sums bytes of a given file and displays to screen.
*
* Compile:
* gcc ccalc.c -o ccalc -O2
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
@yfyf
yfyf / batwidget.lua
Created September 25, 2013 19:32
awesomewm battery widget with colour reflecting the remaining battery life and a notification for low battery
-- Tooltip comes from: https://github.com/liliff/web/blob/master/_posts/2012-04-05-first-dive-into-lua-battery-widget.md
function rgbToHex(r, g, b)
return string.format("#%0.2X%0.2X%0.2X", r, g, b)
end
function chargeToColour(charge)
local unit = 255 / 100
local amount = math.floor(unit * charge)
return rgbToHex(255 - amount, amount, 25)
### output of ./configure && make deps && make
checking whether necessary dependencies are already installed...
xmlm is installed in /usr/lib/ocaml/xmlm
ulex is installed in /usr/lib/ocaml/ulex
easy-format is installed in /usr/lib/ocaml/easy-format
mkdir -p /home/yfyf/sandbox/piqi/build/lib/ocaml
make -C deps
make[1]: Entering directory '/home/yfyf/sandbox/piqi/deps'
set -e; \
@yfyf
yfyf / example.piqi
Created December 4, 2013 10:47
piqi top-level declarations converted with `piqi convert -f piqi -t xml -o example.xml example.piqi`
.module example
.custom-field erlang-type-prefix
.erlang-type-prefix ""
.alias [
.name itemid
.type uint32
]
.record [
@yfyf
yfyf / PKGBUILD
Last active December 30, 2015 07:19
piqi PKGBUILD
# Maintainer: Taylor Venable <taylor@metasyntax.net>
pkgname=piqi-git
pkgver=20131204
pkgrel=1
pkgdesc='A set of languages and open-source tools for working with structured data.'
arch=('i686' 'x86_64')
url='http://piqi.org/'
license=('Apache')
makedepends=('git' 'ocaml' 'ocaml-findlib' 'pandoc')
@yfyf
yfyf / update-resolv-conf
Created March 25, 2014 18:06
Update resolv.conf using openresolv with (DNS) settings pushed by OpenVPN
#!/bin/bash
#
# Requires openresolv.
#
# This file goes into
#
# /usr/share/openvpn/update-resolv-conf
#
# And this goes into your OpenVPN conf:
#
@yfyf
yfyf / beam.rst
Last active August 29, 2015 14:15 — forked from kuenishi/beam.rst

BEAM

assemble

$ erlc -S test.erl
@yfyf
yfyf / bad.html
Last active August 29, 2015 14:16
Pandoc issue
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="generator" content="pandoc">
<title></title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="reveal.js/css/reveal.min.css"/>
@yfyf
yfyf / primes.hs
Created February 25, 2015 10:06
Primes a la Yves Bertot
---- Prime sieve based on co-inductive streams
---- Taken from "Filters on coinductive streams, an application to
---- Eratosthenes’ sieve" by Yves Bertot
-- a 'stateful' filter
fm p n (x:xs) | (n < x) = fm p (n+p) (x:xs)
fm p n (x:xs) | (n == x) = fm p (n+p) xs
fm p n (x:xs) | (x < n) = x : (fm p n xs)
primes = sieve [2..] where