This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using DESF; | |
using DESF.Flow.Event; | |
using DESF.Flow.Calendar; | |
using DESF.Tools; | |
namespace CalendarTest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function templatePrepareFilters($template) { | |
$template->registerFilter($latte = new Nette\Templates\LatteFilter()); | |
TwigMacro::register($latte->getHandler()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require("class.php"); | |
$cache = $a->a->a; | |
for ($i=1; $i<=$loopcount; $i++) { | |
$cache->a; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Horner, hovada..... | |
function decToBin($num) { | |
do { | |
$res[] = $rem = $num % 2; | |
$num = floor($num/2); | |
} while ($num); | |
return join("",array_reverse($res)); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author Pavel Kalvoda | |
*/ | |
abstract class BasePresenter extends Nette\Application\Presenter | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @author Pavel Kalvoda | |
*/ | |
abstract class BasePresenter extends Nette\Application\Presenter { | |
protected function getAutosaveableProperties() { | |
$props = $this->getReflection()->getProperties(); | |
$props = array_filter($props, function($prop) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Helpers | |
# Only a few dragons here. This method validates body of the request | |
# against a schema. If no schema was passed to the method, it will | |
# try to find it automagically | |
def validate!(schema = nil) | |
schema ||= Kernel.const_get( | |
settings.validation[:module] | |
).const_get( | |
/^\/(.*)\//.match(request.path)[1].capitalize | |
).const_get( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
data = Array.new | |
50.times { data << rand(100) } | |
def qs(list) | |
return list if list.length < 2 | |
smaller, bigger = list[1..-1].partition {|x| x < list[0] } | |
return qs(smaller) + [list[0]] + qs(bigger) | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pjk@desktop:~/NetBeansProjects/Primes$ time java -jar "/home/pjk/NetBeansProjects/Primes/dist/Primes.jar" | |
[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997] | |
real 0m0.083s | |
user 0m0.064s | |
sys 0m0.012s |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
t = [:r, :g, :b] | |
puts (inp = ARGV[0].split("").map {|x| x.downcase.to_sym}).inspect | |
cc = Hash[t.map {|c| [c,inp.count(c)]}] | |
expec = t.map {|c| [c]*cc[c]}.flatten | |
puts (slc = Hash[t.zip([(0...cc[:r]), (cc[:r]...cc[:r]+cc[:g]), (cc[:r]+cc[:g]...cc[:r]+cc[:g]+cc[:b])])]).inspect | |
inp.each_with_index do |c, i| | |
next if expec[i] == c #ok | |
if inp[slc[c]].index(expec[i]) then # fix 2 positions |
OlderNewer