Skip to content

Instantly share code, notes, and snippets.

View tournasdim's full-sized avatar
🎯
Focusing

Tournas Dimitrios tournasdim

🎯
Focusing
View GitHub Profile
@tournasdim
tournasdim / Bash_install_Gisto
Created February 11, 2014 21:40
A simple Bash script for automatically installation of gisto
#!/bin/bash
if [ "${1}" = "--uninstall" ]; then
/bin/rm -rf /usr/bin/gisto /usr/bin/nw.pak /usr/share/applications/gisto.desktop usr/share/menu/gisto /usr/share/pixmaps/gisto.png /usr/share/pixmaps/gisto.xpm
echo -e '\n\n\n\e[44m \e[0m Congrats! Gisto removed from your machine.\n\n\n'
exit 1
fi
is_root() {
if [[ $EUID -ne 0 ]]; then
@tournasdim
tournasdim / git-stats
Created February 18, 2014 20:52
simply execute the script to have a summary of Git statistics per author . Just copy the script into "/usr/bin/" directory and make it executable "chmod +x"
#!/bin/bash
LOGOPTS=
END_AND_BEGIN=
#https://github.com/esc/git-stats
#argument parsing
while [ -n "$1" ]; do
case "$1" in
"-s")
shift
END_AND_BEGIN="$END_AND_BEGIN --after=$1"
@tournasdim
tournasdim / deny_access_to_directory
Created February 19, 2014 11:18
Deny access to a Directory with .htaccess
Order Deny,Allow
Deny from all
@tournasdim
tournasdim / SPL_ClassLoader.php
Created February 19, 2014 17:38
SplClassLoader implementation that implements the technical interoperability standards for PHP 5.3 namespaces and class names.
<?php
/**
* SplClassLoader implementation that implements the technical interoperability
* standards for PHP 5.3 namespaces and class names.
*
* http://groups.google.com/group/php-standards/web/final-proposal
*
* // Example which loads classes for the Doctrine Common package in the
* // Doctrine\Common namespace.
@tournasdim
tournasdim / SPL_LimitIterator.php
Created February 22, 2014 08:22
SPL's LimitIterator , a simple example
$numbers = array(22, 60, 876, 95, 77);
// Initializing the Iterator
$iterator = new ArrayIterator($numbers);
// Pass the converted array to the LimitIterator
$limiter = new LimitIterator($iterator, 0 , 4);
// Loop through the LimitIterator object
foreach ($limiter as $number) {
@tournasdim
tournasdim / ClassLoader.php
Created February 22, 2014 08:28
A simple ClassLoader (autoloader) with spl_autoload_register function .
/*** nullify any existing autoloads ***/
spl_autoload_register(null, false);
/*** specify extensions that may be loaded ***/
spl_autoload_extensions('.php');
/*** class Loader ***/
function classLoader($class)
{
//$filename = ucfirst(strtolower($class) . '.php') ;
@tournasdim
tournasdim / Localization_codes.php
Created February 25, 2014 08:24
The most used localization codes
English, US (en_US)
German, Germany (de_DE)
Chinese, PRC (zh_CN)
Chinese, Taiwan (zh_TW)
Czech, Czech Republic (cs_CZ)
Dutch, Belgium (nl_BE)
Dutch, Netherlands (nl_NL)
English, Australia (en_AU)
English, Britain (en_GB)
English, Canada (en_CA)
@tournasdim
tournasdim / custom_route.php
Created March 2, 2014 09:02
Add a custom route or alias to your ZF1-application . Paste the code into application/bootstrap.php
protected function _initRouter()
{
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
// Product view route
$route = new Zend_Controller_Router_Route(
'/home',
array(
'controller' => 'index',
@tournasdim
tournasdim / set_Locale_ZF2.php
Created March 12, 2014 16:36
Defining Locale from module's configuration file in ZF2
// BookList/Module.php (a custom ZF2 module)
public function onBootstrap(MvcEvent $e)
{
$translator = $e->getApplication()->getServiceManager()->get('translator') ;
$translator->setLocale(\Locale::acceptFromHttp($_SERVER['HTTP_ACCEPT_LANGUAGE']))
->setFallbackLocale('en_US') ;
}
@tournasdim
tournasdim / ZF2_Doctrine.php
Created April 3, 2014 05:20
Sample Code to connect to the database with doctrine connection
return array (
'Doctrine' => array (
'Connection' => array (
'Orm_ default ' => array (
'DriverClass' => 'Doctrine\DBAL\Driver\PDOMySql\Driver' ,
'Params' => array (
'Host' => 'localhost' ,
'Port' => '3306 ' ,
'User' => 'root' ,
'Password' => '' ,