Skip to content

Instantly share code, notes, and snippets.

@tynovsky
tynovsky / reverse-quickcheck.hs
Created September 21, 2017 17:26
haskell quickcheck
import Test.QuickCheck
rev :: [a] -> [a]
rev xs = rev' xs [] where
rev' [] acc = acc
rev' (x:xs) acc = rev' xs (x:acc)
prop_revapp :: [Int] -> [Int] -> Bool
prop_revapp xs ys = rev (xs++ys) == rev ys ++ rev xs
@tynovsky
tynovsky / notify.pl
Created September 21, 2017 17:25
perl dbus
#!/usr/bin/perl
use strict;
use warnings;
use Net::DBus;
my $bus = Net::DBus->find;
my $notify_service = $bus->get_service("org.freedesktop.Notifications");
@tynovsky
tynovsky / shallow.pm
Created September 21, 2017 17:23
check syntax without dependencies
BEGIN {
push @INC,
sub { print "Oops: There was an error looking for $_[1]\n"; return \'1' };
}
1
# perl -Mshallow -c yourscript.pl
@tynovsky
tynovsky / sa-watcher.pl
Last active August 29, 2015 14:00
Student Agency free seat watcher
#!/usr/bin/perl
use strict;
use warnings;
use WWW::Mechanize;
use Getopt::Long;
use pQuery;
use Data::Dumper;
use Mail::Sendmail;
@tynovsky
tynovsky / v.pl
Created September 8, 2012 12:07
open file in gvim's tab
#!/usr/bin/perl
use strict;
use warnings;
my $editor = "gvim --remote-tab";
my $linenum_param = "+";
my $linenum_separ = q{ : };
my $command;
@tynovsky
tynovsky / apache_config_lo
Created September 5, 2012 07:39
apache virtualhost config file which imitates VirtualDocumentRoot with pure mod_rewrite
<VirtualHost *:80>
ServerName lo
ServerAlias *.lo
DocumentRoot /home/miroslav/www
#do the magic: something.lo => DocumentRoot/something/document_root
RewriteEngine On
RewriteCond %{HTTP_HOST} ^([^.]*)\.([^.]*)$
RewriteCond %{REQUEST_URI} !document_root
RewriteRule ^(.*)$ /%1/document_root$1
@tynovsky
tynovsky / presenters-HomepagePresenter.php
Created September 9, 2011 21:11
Autocomplete: jqueryUI + Nette
<?php
use Nette\Application\UI\Form;
use Nette\Application\Responses\JsonResponse;
class HomepagePresenter extends BasePresenter
{
private $data = array(
"pozdrav" => array(
'ahoj', 'nazdar', 'cau', 'ahojda', 'nazdarecek', 'caues'
PS1='\n\[\033[01;32m\][\t] \h \[\033[01;34m\]\W \$ \[\033[00m\]'