Skip to content

Instantly share code, notes, and snippets.

<?php
function array_delete_by_key(&$array, $delete_key, $use_old_keys = FALSE) {
unset($array[$delete_key]);
if(!$use_old_keys) {
$array = array_values($array);
}
@jsifalda
jsifalda / gist:4252401
Created December 10, 2012 18:40
Sending basic authentication via curl
<?php
$url = 'http://www.example.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myusername:mypassword");
$result = curl_exec($ch);
echo $result;
@jsifalda
jsifalda / .profile
Created September 25, 2012 07:01
OSX aliases for management nginx + php-fpm + mysql
#add following lines into the ~/.profile file
alias svstart='sudo nginx && mysql.server start && sudo php-fpm'
alias svstop='sudo nginx -s stop && mysql.server stop && sudo killall php-fpm'
alias svrestart='svstop && svstart'
@jsifalda
jsifalda / gist:3780362
Created September 25, 2012 06:54
Installation PHP 5.4 on OSX with Homebrew (PHP-FPM)
#Optional
#add "export PATH=/usr/local/bin:$PATH #homebrew" into your ~/.profile file
#brew update
#brew doctor
# If you see some warnings, resolve it
#Tap the homebrew/dupes repository into your brew installation:
brew tap homebrew/dupes
#Tap the repository into your brew installation:
@jsifalda
jsifalda / pagodabox-init.php
Created August 24, 2012 12:33
Simulations of pagodabox environment on local
<?php
$parts = explode(DIRECTORY_SEPARATOR, $_SERVER['PWD']);
$server = $parts[count($parts) - 1];
switch ($server) {
case 'directory':
$_SERVER['DB1_NAME'] = 'database-name';
break;
@jsifalda
jsifalda / config.neon
Created August 24, 2012 10:23
Nette configurations for PagodaBox cloud hosting (Boxfile)
#config.neon
production < common:
includes:
- production.php
@jsifalda
jsifalda / php.ini
Created August 18, 2012 10:32
Xdebug: nginx (php-fpm) and phpStorm configuration
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
[xdebug]
xdebug.idekey="macgdbp"
xdebug.remote_enable=1
xdebug.remote_host="localhost"
xdebug.remote_port=9089
xdebug.remote_handler="dbgp"
@jsifalda
jsifalda / AdminOrders.php
Created August 15, 2012 07:11
Prestashop: How to allow deleting orders
<?php
# version 1.4.8.2
# in file <folder-with-preshashop>/admin/tabs/AdminOrders.php
# find line "$this->colorOnBackground = true;", after that write: $this->delete = true;
#...
class AdminOrders extends AdminTab
{
public function __construct()
<?php
/**
* Object representing a DOM element.
*
* @package PHPUnit_Selenium
* @author Giorgio Sironi <[email protected]>
* @copyright 2010-2011 Sebastian Bergmann <[email protected]>
* @license http://www.opensource.org/licenses/BSD-3-Clause The BSD 3-Clause License
* @version Release: @package_version@
@jsifalda
jsifalda / gitignore_global
Created August 12, 2012 13:07
GIT: gitignore global
#add with command: git config --global core.excludesfile ~/.gitignore_global
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so