Skip to content

Instantly share code, notes, and snippets.

@MartinMajor
MartinMajor / DatabaseDeployPresenter.php
Created July 24, 2013 12:47
Tools for database versioning. For more informations see: http://www.youtube.com/watch?v=KTmlw5AKM8E (in CZ). - database.sql script is written for PostgreSQL - DatabaseDeployPresenter.php script is a snippet from Nette presenter - post-checkout is Git hook, that calls shell script that just runs your Nette presenter
/**
* Startup
*/
public function startup()
{
parent::startup();
// plain text output when http request
$this->getHttpResponse()->setContentType('text/plain');
@mishak87
mishak87 / editor.reg
Created September 16, 2013 21:10
Nette tool to ease up pain from errors (bind to editor: protocol via reg) PHPStorm and with fallback to Sublime Text
REGEDIT4
[HKEY_CLASSES_ROOT\editor]
@="URL:editor Protocol"
"URL Protocol"=""
[HKEY_CLASSES_ROOT\editor\shell\open\command]
@="wscript \"C:\\bin\\scripts\\run-editor.js\" \"%1\""

Git push deploy

Requires installed gitolite in /home/git and following directory structure

/var
    /www
        /apps
        /hosts

/libs

DELIMITER ;;
DROP PROCEDURE IF EXISTS `normalize_foreign_key_name`;;
CREATE PROCEDURE `normalize_foreign_key_name`(IN `param_database_name` varchar(100) CHARACTER SET 'ascii', IN `param_table_name` varchar(100) CHARACTER SET 'ascii', IN `param_column_name` varchar(100) CHARACTER SET 'ascii')
BEGIN
DECLARE var_constraint_name_current VARCHAR(100);
DECLARE var_constraint_name_new VARCHAR(100);
DECLARE var_constraint_target_table VARCHAR(100);
@kaja47
kaja47 / burst.scala
Created April 2, 2016 23:22
quick and dirty sketch of burstsort
import java.util.Arrays
// BurstSort
// Cache-Conscious Sorting of Large Sets of Strings with Dynamic Tries
// http://goanna.cs.rmit.edu.au/~jz/fulltext/alenex03.pdf
class BurstLeaf(initSize: Int) {
var size: Int = 0
@JanTvrdik
JanTvrdik / add_pull_request_to_issue_github.sh
Last active June 6, 2016 19:25
Add pull request to existing issue on github
#!/bin/bash
current_branch="$(git symbolic-ref HEAD 2>/dev/null)" || current_branch="(unknown)"
current_branch=${current_branch##refs/heads/}
github_username="JanTvrdik"
github_token="..."
if [[ $current_branch = "(unknown)" ]]
then
@dg
dg / output detector.php
Created June 20, 2013 18:59
How can I find out where my output started?
<?php
ob_start(function($s, $flag) {
if ($flag & PHP_OUTPUT_HANDLER_START) {
$e = new \Exception;
$s = nl2br("Output started here:\n{$e->getTraceAsString()}\n\n") . $s;
}
return $s;
}, 2);
@JanTvrdik
JanTvrdik / loadCacheFile.php
Last active December 13, 2016 21:51
General purpose thread-safe cache function
<?php
/**
* @param string $file
* @param callable $tryLoad (string $file, mixed & $data): bool
* @param callable $isExpired (string $file): bool
* @param callable $fallback (string $file): string
* @return mixed
*/
function loadCacheFile($file, $tryLoad, $isExpired, $fallback)
@hrach
hrach / nginx.conf
Created June 9, 2014 20:50
nginx + Nette framework rewrite
server {
listen 80;
server_name example.com;
root d:/webs/example.com/www;
index index.php index.html;
try_files $uri $uri/ /index.php?$args;
location ~ \.phpt?$ {
try_files $uri @missing;
@hrach
hrach / dynamicReturnTypeMeta.json
Last active April 11, 2017 10:35
Dynamic Return Type
{
"methodCalls": [
{
"class": "\\Mockery",
"method": "mock",
"position": 0,
"mask": "%s|\\Mockery\\MockInterface"
},
{
"class": "\\Nette\\DI\\Container",