Skip to content

Instantly share code, notes, and snippets.

View vojtech-dobes's full-sized avatar

Vojtěch Dobeš vojtech-dobes

View GitHub Profile
@vojtech-dobes
vojtech-dobes / validatedButton.ajax.js
Last active January 4, 2016 05:29
Keeps form buttons with [data-button-validated] data attribute in disabled state, until the form passes validation. Extension for nette.ajax.js.
$.nette.ext('validatedButton', {
load: function () {
var that = this;
$('[data-button-validated]').each(function () {
var button = $(this);
var form = button.closest('form');
that.tryEnable(form, button);
form.find('input, select').on('change input', function () {
that.tryEnable(form, button);
});
@vojtech-dobes
vojtech-dobes / debug.php
Created April 29, 2013 14:19
Getting to stacktrace in n-iteration easily
<?php
function stop($step = 1) {
static $i = 0;
$i++;
if ($i >= $step) {
$stop();
}
}
$.nette.init(function (rh) {
$(this.linkSelector).off('click.nette', rh).on('click.nette', rh);
$(this.formSelector).off('submit.nette', rh).on('submit.nette', rh);
$(this.buttonSelector).off('click.nette', rh).on('click.nette', rh);
}, {
linkSelector: 'a.ajax',
formSelector: 'form.ajax',
buttonSelector: 'input.ajax[type="submit"], button.ajax[type="submit"], input.ajax[type="image"]'
});
@vojtech-dobes
vojtech-dobes / Usage.md
Created October 19, 2012 10:31
Require.js + Mocha + Sinon
var load = requirejs('bootstrap')('nameOfTestedThing', {
	nameOfDependency: mockOfDependency
}, function (test) {

describe('foo', function () {
	test('bar', function (testedThing, mockOfDependency) {
		...
 test.done();
@vojtech-dobes
vojtech-dobes / gist:3775104
Created September 24, 2012 09:24
Flush DNS cache on Mac
dscacheutil -flushcache
@vojtech-dobes
vojtech-dobes / build.xml
Created September 21, 2012 12:53
Composer via Ant
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="curl -s https://getcomposer.org/installer | php" />
</exec>
<exec executable="php" failonerror="true">
<arg value="composer.phar" />
<arg value="install" />
</exec>
<div n:class="tab-pane, $tab == 'content' ? active" id="component-{$id}-{$tab}">
{snippet tab}
{include #content}
{/snippet}
</div>
@vojtech-dobes
vojtech-dobes / bootstrap.php
Created September 4, 2012 11:48
ExtensionsList, hack for Nette 2.0.0-4 because of https://github.com/nette/nette/pull/720
<?php
$config = __DIR__ . '/config/config.neon';
$configurator->addConfig($config, FALSE);
foreach (Nette\Utils\Arrays::get(Nette\Utils\Neon::decode(
file_get_contents($config)
) ?: array(), 'extensions', array()) as $name => $class) {
$configurator->onCompile[] = function ($configurator, $compiler) use ($name, $class) {
$compiler->addExtension($name, new $class);
@vojtech-dobes
vojtech-dobes / editor.html
Created September 3, 2012 08:27
Distraction-less text editor
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<style>
body { width: 100%; margin: 0; padding: 20xp; height: 100%; position: relative; }
div {
color: #555555;
cursor: text;
display: block;
@vojtech-dobes
vojtech-dobes / MultiAuthenticator.php
Created August 31, 2012 12:40
Multiple ways of authentication in Nette
<?php
namespace VojtechDobes\NetteSecurity;
use Nette\InvalidArgumentException;
use Nette\Security\IAuthenticator;
use Nette\Security\IIdentity;
/**