Skip to content

Instantly share code, notes, and snippets.

<?php
class XYZ{
public function foo(){
wc();
}
}
<?php
/**
* Returns array item or $default if item is not set.
* Example: $val = Arrays::get($arr, 'i', 123);
* @param mixed array
* @param mixed key
* @param mixed default value
* @return mixed
*/
public static function get(array $arr, $key, $default = NULL)
<?php
/**
* Expands %placeholders% in string. Return mixed when expanding pure ^%item%$.
* @param string
* @return mixed
* @throws Nette\InvalidStateException
*/
public function expand($s)
{
/**
* HOW-TO
*/
// same param as $.ajax(option); see http://api.jquery.com/jQuery.ajax/
$.ajaxQueue.addRequest(option);
// start processing one by one requests
$.ajaxQueue.run();
@pavelmaca
pavelmaca / gist:791310
Created January 22, 2011 18:13
EditableGrid - draft
<?php
/**
* Draft for EditableGrid
* @author Pavel Máca
*/
$grid = new Gridito\EditableGrid($this, $name);
$em = Nette\Environment::getService("Doctrine\ORM\EntityManager");
$model = new Model\UsersEditableGriditoDoctrineModel($em);
$grid->setModel($model);
int pridano = 0;
for( .... .... ..){
if(platy[pocet] > 10000){
pridano++;
}
}
var secure = true;
var files = [{
"name" : "file1.txt",
"contents" : "foo1",
"ext" : "txt",
}, {
"name" : "file2.php",
"contents" : "<?php phpinfo();",
"ext" : "php",
@pavelmaca
pavelmaca / backup.sh
Created November 13, 2010 13:29
backup.sh
#!/bin/bash
# My first shell script :)
# Backup domains directories and MySQL database.
clear
# CONFIGURATION
MODE_D="0740"
MODE_F="0640"
DAY=$(date +%F) # YYYY-MM-DD
<?php
public static function scanDir($patch, $pattern = false, $ignore = false){
$dir = new RecursiveDirectoryIterator($patch);
if( !$dir->isDir() ) throw new FileModelException("$patch must by directory");
$files= array();
foreach ($dir as $filename => $cur) {
if($ignore && in_array($file, $ignore)) continue;
<?php
//regex test: http://regexhero.net/tester/?id=c4b2c455-b1e3-40b8-969e-b5b8240b7324
public static function twitterify($text) {
$search = array(
'|(http://[^ ]+)|',
'/(^|[^a-z0-9_])@(\w*[a-z]+[0-9a-ž_]*)/i',
'/(^|[^a-z0-9_])#(\w*[a-z]+[0-9a-ž_]*)/i',
);
$replace = array(