Skip to content

Instantly share code, notes, and snippets.

View v6ak's full-sized avatar

Vít Šesták v6ak

View GitHub Profile
@v6ak
v6ak / hello.latte
Created June 23, 2011 11:39
Latte example
Hello {$name}!
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head><title/some title/
<body<p>as>f
<ul<li>foo<>bar</></>
@v6ak
v6ak / emerge-notify
Created July 26, 2011 12:49
Notifikace dokončení všech emerge - snad to funguje
#!/bin/bash
# Busy waiting is very dirty, but it is very simple...
while find /var/tmp/portage/ -name '*_lockfile' | grep lockfile; do
sleep 1
done
notify-send -t $((30*60*1000)) "doemergováno"
@v6ak
v6ak / benchmark-ternary
Created August 17, 2011 08:01
ternary operator benchmark
#!/bin/bash
COUNT=1e6
FUNCTIONS='
function res($x){
//echo $x;
};
'
#CREATE_ARRAY='$a = array_fill(0, '$COUNT', "fofo");'
CREATE_ARRAY='
$a = array();
package com.v6ak.example.geometry
abstract sealed class Shape{
def color: String
}
abstract sealed class Ellipse extends Shape {
def a: Int
def b: Int
}
@v6ak
v6ak / fetch-java
Created October 22, 2011 10:39
#Oracle #JDK|#JRE #fetch #tool for #Gentoo
#!/bin/bash
# input URLs: e.g.: http://www.oracle.com/technetwork/java/javase/downloads/jre-7u1-download-513652.html
# (!) By using this script, you accept some license agreements automatically!
URL_REGEXP='http\:\/\/([a-z0-9]+)(\.[a-z0-9]+)*\/(([0-9a-zA-Z\./]|-)+)'
if [ "$#" == "0" ]; then # no URL given => get them from emerge
echo Getting URLs from emerge...
java_packages=$(grep -E '(sun|oracle)-(jre|jdk)' /var/lib/portage/world)
urls=$(
emerge -uf -- $java_packages 2>&1 | grep -o -E "$URL_REGEXP"
)
@v6ak
v6ak / set-keyboard
Last active September 29, 2015 19:58
Nastaví klávesnici cz qwerty a pro AltGr+ů nastaví dolar místo středníku - stejně jako na cz qwertz
#!/bin/bash
##
## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
## Version 2, December 2004
##
## Copyright (C) 2012 Vít Šesták 'v6ak' <https://contact.v6ak.com/>
##
## Everyone is permitted to copy and distribute verbatim or modified
## copies of this license document, and changing it is allowed as long
## as the name is changed.
@v6ak
v6ak / gist:2568859
Created May 1, 2012 15:30
remote sha1sum for box.com
for url in $(
curl https://www.box.com/api/2.0/folders/$FOLDER_ID -H "$AUTH" |
(sed 's#.*"entries":\[{##' | sed 's/},{/\n/g') | grep file | sed 's#^"type":"file","id":"\([0-9]\+\)".*#https://www.box.com/api/2.0/files/\1#'
); do
curl "$url" -H "$AUTH" | sed 's#\(.*\)"name":"\([^"]\+\)",\(.*\)"sha1":"\([^"]\+\)"\(.*\)$#\4 \2\n#'
done
@v6ak
v6ak / gist:3917173
Created October 19, 2012 09:37
"+" = OK, "-" = "při přidávání selhalo"
-http://twitter.v6ak.com/136264116
-http://twitter.v6ak.com/21125643
+http://twitter.v6ak.com/292489950
+http://twitter.v6ak.com/244909101
+http://twitter.v6ak.com/68161528
+http://twitter.v6ak.com/176118566
+http://twitter.v6ak.com/18788516
-http://twitter.v6ak.com/24889166
-http://twitter.v6ak.com/13898622
+http://twitter.v6ak.com/83027496
@v6ak
v6ak / gist:3917179
Created October 19, 2012 09:38
Export Twitterových účtů z OPML do twitter.v6ak.com
val TwRegex = """^(http|https)://(api\.twitter\.com|twitter.com)(/1)?/statuses/user_timeline(/|\.rss\?screen_name=)([0-9A-Za-z_]+)(\.rss)?$""".r
Set(XML.loadFile("/tmp/google-reader-subscriptions.xml") \\ "outline" \\ "@xmlUrl" map {_.toString} flatMap {_ match {case TwRegex(_, _, _, _, name, _) => Some(name); case _ => None}} : _*) map {"http://twitter.v6ak.com/"+_} foreach println;