Skip to content

Instantly share code, notes, and snippets.

@uestla
uestla / project-euler.php
Last active January 12, 2024 21:13
Project Euler - solutions written in PHP
<?php
declare(strict_types = 1);
final readonly class solution {
public function __construct(
public int $n,
public string $info,
) {}
@uestla
uestla / watch-tree
Last active August 29, 2023 15:56
Run command when any file in working directory changes (recursive check)
#!/usr/bin/env php
<?php
declare(strict_types = 1);
namespace Scripts;
// run given command when any file changes in given paths or in working directory
if (!isset($_SERVER['argv'][1])) {
<?php
$counter = 0;
for ($i = 0; $i <= 2359; $i++) {
$n = str_pad($i, 4, '0', STR_PAD_LEFT);
$ciphers = str_split($n);
if ($ciphers[2] > 5) {
continue ;
<script type="text/javascript">
(function (window, $) {
window['grecaptchaInit'] = function () {
$.nette.ext({
init: function () {
$('.g-recaptcha').each(function () {
var recaptcha = $(this);
if (recaptcha.children().length) { // already processed -> skip
return ;
\documentclass[a4paper]{article}
\usepackage[czech]{babel}
\usepackage[utf8x]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{graphicx}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{fullpage}
@uestla
uestla / jquery.nette.forms.live.js
Last active December 10, 2015 23:08
Nette+jQuery live form validation
(function ($, window) {
if (!window.Nette) {
console.log('Error: Nette form validation not loaded.');
return ;
}
var live;
require_once __DIR__ . '/geocaching.php';
var_dump( getFoundCacheCount( '3f4da330-f5d0-411d-bcee-74672b284351' ) );
<?php
use Nette\Forms\Form,
Nette\Forms\Controls\TextInput;
class AntispamControl extends TextInput
{
/**
* @return void
@uestla
uestla / jquery.nette.js
Created April 12, 2012 18:40
Ajax s jQuery (Nette framework addon)
(function ($, window) {
$(function () {
// navazani validate Nette formularu
$('form').livequery(function () {
var $this = $(this);
Nette.initForm($this[0]);
});
<?php
interface INavigationLoader
{
/** @return Nette\ArrayHash */
function loadNavigation();
}