Skip to content

Instantly share code, notes, and snippets.

View v6ak's full-sized avatar

Vít Šesták v6ak

View GitHub Profile
{,pac}man
#!/bin/bash
cat "$1" \
| php -r \
'foreach(token_get_all(file_get_contents("php://stdin")) as $token){
echo is_array($token)
?token_name($token[0]).":\t$token[1]\n"
:"$token\n";
};' \
| less
<?php
namespace V6;
/**
* @author Vít Šesták 'v6ak'
* @license BSD
*/
final class NamespacedLoader {
private $path;
<?php
echo 'runkit.internal_override:', ini_get('runkit.internal_override'), "\n";
//ini_set('runkit.internal_override', true); // Does not work, because it is PHP_INI_SYSTEM
runkit_function_rename('register_shutdown_function', 'v6ak_internal_register_shutdown_function'); // You have to enable runkit!
if(true){ // It reports redeclaration of function without whis.
function register_shutdown_function($func){
$args = func_get_args();
array_shift($args);
v6ak_internal_register_shutdown_function(function() use($args){
try{
filterPrimes (x:xs) = x:filterPrimes (filter isNotDivisible xs) where isNotDivisible n = (n `mod` x) /= 0
primes = filterPrimes [2,3..]
main = print (takeWhile (<100000) primes)
@v6ak
v6ak / Primes.scala
Created October 31, 2010 12:32
No řekněte sami, kdo z vás tohle má? Scala rulez! Functional programming rulez!
object Primes extends Application{
def sieve(s:Stream[Int]):Stream[Int] = Stream.cons(s.head, sieve(s.tail.filter(_%s.head != 0))) // Sieve of Eratosthenes
val primes = sieve(Stream from 2) // Stream of all primes
primes take 10 foreach println // print first 10 primes
}
This file has been truncated, but you can view the full file.
main = print (((
curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurry.curry.uncurr
@v6ak
v6ak / Trees.scala
Created January 12, 2011 19:17
Generování stromů pro experiment se stromy - kód je místy psán narychlo. S kódem si můžete dělat co chcete, pokud po mě nebudete chtít jakékoli záruky k jeho kvalitám. Záruky k některým jeho nekvalitám poskytnout mohu.
import scala.util.Random
import java.util.NoSuchElementException
class Tree (val food:String, val n:Double, val ord:Int, val children:List[Tree]){
def value = "(\""+food+"\", "+n+")";
override def toString = toString(0, " | ", " -");
def toString(indent:Int, indentString:String, elString:String):String = "["+ord+"]\t"+indentString*indent +elString +value+
def timeBench(t: =>Unit, count: Int){
val t1 = System.currentTimeMillis
try{
(1 to count).foreach{x =>
t/*()*/
}
}finally{
val t2 = System.currentTimeMillis
val timeSec = (t2-t1)/1000.0;
println("\ntotal time:\t" + timeSec + "s");
@v6ak
v6ak / gist:849855
Created March 1, 2011 20:42
These commands create links for Busybox on Android
adb shell
su
mount -o rw,remount /dev/block/mtdblock0 /system;D=/system/bin/;BB=${D}busybox;for i in $($BB|$BB grep -e "\,$"); do n=$(echo -n "$i"|$BB sed s/,//);ln -s $BB "$D$n";done;mount -o ro,remount /dev/block/mtdblock0 /system