Skip to content

Instantly share code, notes, and snippets.

@jsifalda
jsifalda / factory.php
Created October 21, 2013 06:32
Nette link service inject to model
<?php
class FooFactory extends Nette\Object
{
private $link;
public function injectLinkProvider($provider)
{
$this->link = callback($provider);
}
<?php
function work(){
echo "1";
}
while(!sleep(1)) work();
@jsifalda
jsifalda / PostsImporter.php
Created August 23, 2013 16:51
WordPress posts importer
<?php
/**
* PostsImporter.php
*
* @author Jiří Šifalda <[email protected]>
* @package Flame
*
* @date 11.12.12
*/
@jsifalda
jsifalda / composer.json
Created July 20, 2013 15:00
Minimum of composer's repositories definition
"repositories": [
{
"type": "package",
"package": {
"name": "enlan/categorymodule",
"version": "master",
"source": {
"url": "<git-url>",
"type": "git",
"reference": "master"
@jsifalda
jsifalda / gist:5495469
Last active December 16, 2015 20:49
Approach to create local git repository
# Create local repo
cd ~
mkdir repositories
cd repositories
mkdir localRepo.git
cd localRepo.git
git init --bare --shared=true
# Add remote to local repo in your project
cd myProject
@jsifalda
jsifalda / composer.json
Last active December 16, 2015 20:49
Depending on packages without composer.json
"repositories": [
{
"type": "package",
"package": {
"name": "vendor/package",
"version": "1.0.0",
"dist": {
"url": "http://example.org/package.zip",
"type": "zip"
},
@jsifalda
jsifalda / Loader.js
Last active December 12, 2015 02:49
Load dependencies by js
var deps = [
'/js/libs/jquery.min.js',
'/js/libs/address.min.js',
'/js/libs/ui.min.js',
'/js/libs/prefixfree.min.js',
'/js/libs/modernizr.js',
'/js/libs/jqtube.js',
'/js/core.js',
'/js/yt.js',
@jsifalda
jsifalda / gist:4517177
Created January 12, 2013 10:54
List of countries in php array
<?php
/**
* CountryFacade.php
*
* @author Jiří Šifalda <[email protected]>
*
* @date 01.12.12
*/
class CountryFacade extends \Nette\Object
@jsifalda
jsifalda / pre-commit
Last active January 4, 2017 16:04
Run phpUnit tests before commit
#!/bin/sh
#
# An example hook script to verify what is about to be committed.
# Called by "git commit" with no arguments. The hook should
# exit with non-zero status after issuing an appropriate message if
# it wants to stop the commit.
echo "[PRECOMMIT HOOK] Running tests"
if [[ -e "libs/bin/phpunit" ]]; then
if [[ -d "tests" ]]; then
@jsifalda
jsifalda / gist:4259637
Created December 11, 2012 15:59
Get array of variations from charlist
<?php
function powerSet($in,$minLength = 1) {
$count = count($in);
$members = pow(2,$count);
$return = array();
for ($i = 0; $i < $members; $i++) {
$b = sprintf("%0".$count."b",$i);
$out = array();
for ($j = 0; $j < $count; $j++) {