Skip to content

Instantly share code, notes, and snippets.

View bognerf's full-sized avatar

Florian Bogner bognerf

  • University of Regensburg
  • Regensburg, Germany
View GitHub Profile
@bognerf
bognerf / Bootstrap.php
Created June 19, 2013 08:33
Zend Framework 1 Bootstrap for multimodule architecture
<?php
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
protected $config;
protected function _initConfig()
{
$this->config = $this->getOptions();
Zend_Registry::set('config', $this->config);
@bognerf
bognerf / readdir_snippet.php
Created June 19, 2013 13:50
Verkürzte Klasse, um Verzeichnisinhalt zu lesen
<?php
namespace fsp;
class FilesystemProvider
{
private $dir;
public $dirContent;
private $activeDirectory;
@bognerf
bognerf / Modul_UserController.php
Created June 25, 2013 12:29
Front Controller plugin for Zend Framework 1 to automatically check wether user is logged in or not
<?php
class Modul_UserController extends Zend_Controller_Action
{
public function init()
{
$front = Zend_Controller_Front::getInstance();
$front->registerPlugin(new Module_Plugin_Login());
$this->view->credentials = FUNCION_IS_LOGGED_IN();
@bognerf
bognerf / rsync.sh
Created June 28, 2013 11:43
Rsync between two Linux servers
DATUM=`date +%Y-%m-%d_%H-%M`
rsync --update -avW --delete-after --numeric-ids --stats -e "ssh -i /PATH/TO/.ssh/KEYFILE" /backup/ user@10.10.10.10:/raid/user/backup > /root/rsynclogs/rsync_$DATUM.log
# use --dry-run to simulate
@bognerf
bognerf / CSS Animations
Created September 9, 2013 07:21
animo.js is useful for controlling CSS-based animations
http://labs.bigroomstudios.com/libraries/animo-js
@bognerf
bognerf / strace.sh
Created September 13, 2013 09:48
Einzeiler zum schnellen STracen von z.B. Apache
ps auxw | grep sbin/apache | awk '{print"-p " $2}' | xargs strace
@bognerf
bognerf / fileinfo.sh
Created September 13, 2013 09:51
Script zur Auflistung von FILE-Meta-Informationen in einem gegebenen Verzeichnis Usage: # fileinfo.sh /PATH/TO/DIR
#!/bin/bash
FILES=$1/*
for f in $FILES
do
# echo "Processing $f file..."
# take action on each file. $f store current file name
file $f
done
@bognerf
bognerf / prevent_form_send.js
Created September 24, 2013 09:21
Prevent a form from being sent by hitting return or enter key
//Dependency: jQuery
$('form').bind("keyup, keypress", function(e) {
var code = e.keyCode || e.which;
if (code == 13) {
e.preventDefault();
return false;
}
});
@bognerf
bognerf / Default_Model_Cidr.php
Created September 27, 2013 09:59
Prüfung, ob IP-Adresse eines Users innerhalb der CIDR-Maske
<?php
class Default_Model_Cidr
{
public static function match($ip, $range)
{
list ($subnet, $bits) = explode('/', $range);
$ip = ip2long($ip);
$subnet = ip2long($subnet);
$mask = -1 << (32 - $bits);
@bognerf
bognerf / index.php
Created November 13, 2013 09:54
index.php für ZF2 (mit Custom Namespace im Vendor-Verzeichnis durch Autoloader!)
<?php
chdir(dirname(__DIR__));
// Decline static file requests back to the PHP built-in webserver
if (php_sapi_name() === 'cli-server' && is_file(__DIR__ . parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH))) {
return false;
}
// Setup autoloading