Other: Windows Batch for Symfony2 with xampp, git, mysql

Windows-Console mit php, git in PATH-Variable für Symfony, Doctrine und Co.

@set git_install_root=C:\Tools\PortableGit-1.7.10-preview20120409
@set xampp_install_root=C:\xampp\
 
 
@set PATH=%git_install_root%\bin;%git_install_root%\mingw\bin;%git_install_root%\cmd;%PATH%
@

PHP: search multidimensional array recursive on key

search php multidimensional array and return parent array

/**
 *
 * @param array $array
 *  Array to search
 * 
 * @param type $search
 *  key to search
 * 
 * @return type 
 *  false or array
 * 
 */
function array_search_recursive_single(array 

Other: Block Google Bot on apache2 htacces or Directory Directive

<Directory "/var/www/yourpage">
  SetEnvIf  User-Agent .*google.* search_robot
  SetEnvIf  User-Agent .*yahoo.* search_robot
  SetEnvIf  User-Agent .*bot.* search_robot
  SetEnvIf  User-Agent .*as

MySQL migrate users, rights, and databases

Hat man mehrere MySQL User, ist es recht umständlich sie via SHOW GRANTS zu exportieren und wieder anzulegen. Viel eleganter geht das mit mk-show-grants aus der maatkit Suite.
Alle MySQL User

mk-show-grants -u root -p PASSWORD > grants.sql

Ohne root und debian-sys-maint

mk-show-grants -u root -p PASSWORD --ignore root@127.0.0.1,root@localhost,debian-sys-maint@localhost > grants.sql

Alle MySQL User
mk-show-grants -u root -p PASSWORD > grants.sql
 
Ohne root und debian-sys-maint
mk-show-grants -u root -p PASSWORD --ignore root@127.0.0.1,root@localhost,debian-sys-maint@localhost

Apache2 Performance Config

#dont log static file requests
SetEnvIf Request_URI "\.(jpg|xml|png|gif|ico|js|css|swf|js?.|css?.)$" DontLog
CustomLog /var/log/apache2/access-example.com.log combined Env=!DontLog

Apache proxy redirect dns

<VirtualHost *:80>
        ServerName  servername.de
        #Include     /var/www/alias.conf
 
    ProxyRequests Off
    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>
Termlisting: 

PHP: tabledrag / tablesort drupal7

$test = ParserBase::InstanceOnDir($cid);
 dpm($bs = $test->GetBouquetsRaw());
 
 $form = array();
 
 $rows = array();
 $i = 0;
 foreach ($bs as $key => $b) {
  $row = array(
    'name' => '<inp
Termlisting: 

SSH: SSH public/private key

#ssh-keygen -t rsa1	  # für Protokol 1 (!! nicht mehr verwenden !!)
ssh-keygen -t rsa	  # für Protokol 2
ssh-keygen -t dsa	  # für Protokol 2
 
ssh-copy-id -i ~/.ssh/id_rsa.pub user@remote-system

PHP: select keys from array

/**
 * Description
 * array array_select_key( array array, array keys )
 * Returns any values from the array $array which have keys that are in the array $keys
 * http://snippets.bigtoach.com/snip
function array_select_key($array, $keys) {
 
 if (!is_array($keys)) {
  $keys = func_get_args(); 
  array_shift($keys); 
 }
 
 return array_intersect_key($array, array_fill_keys($keys, 1));
 
Termlisting: 

PHP: Same form with ID on one page

Overwrite ID to get same form multiple times on one page

function hpsolan_forms_page($data = array()) {
  for ($i=0; $i < count($data); $i++) {
    $output  = drupal_get_form("hpsolan_message_form_" . $i, $data[$i]);
  }
  return $output;
}
 
function
Termlisting: 

Pages

Subscribe to snippet.espend.de RSS