Skip to content

Instantly share code, notes, and snippets.

View d1rk's full-sized avatar
🖖
Live long and prosper!

Dirk Brünsicke d1rk

🖖
Live long and prosper!
View GitHub Profile
@d1rk
d1rk / Useful git commands
Last active January 15, 2018 19:14 — forked from nas/Useful git commands
useful git commands
#push a local branch to repo if does not exist remotely
git push origin branch_name:refs/heads/branch_name
# to start tracking a branch
git branch --track branch_name origin/branch_name
# create remote git branch from head of master
git push origin origin:refs/heads/branch_name
# create a remote branch from another branch's head
@d1rk
d1rk / backupDb
Created February 21, 2011 15:50 — forked from AD7six/backupDb
mysqldump with database.php settings
#!/usr/bin/php
<?php
if (!defined('TMP')) {
define('TMP', getcwd() . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR);
}
$file = getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
if (!is_readable($file)) {
echo "Can't find database config at : $file\n";
die(1);
@d1rk
d1rk / Navigation.php
Created November 23, 2011 08:58 — forked from fahad19/Navigation.php
Admin navigation management in Lithium PHP framework
<?php
/**
* Navigation class for storing admin panel menu.
*
* @author Fahad Ibnay Heylaal <contact@fahad19.com>
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
namespace core\storage;
use core\util\Set;
@d1rk
d1rk / gist:1731351
Created February 3, 2012 17:45 — forked from anonymous/gist:1731344
Wordpress in Li3
public function load()
{
global $PHP_SELF;
global $wp_embed;
global $wpdb;
$db = Connections::get('default', array('config'=>true));
//set connection to inboundink database just so it has a valid connection for now
//when actually doing something, it will connect to the appropriate db
define('DB_HOST', $db['host'] );
define('DB_NAME', $db['database'] );
@d1rk
d1rk / blowfish.php
Created May 14, 2012 09:21 — forked from xeoncross/blowfish.php
blowfish hashing using PHP's crypt and mcrypt library
<?php
# From my question and answer at SO:
# http://stackoverflow.com/questions/10183103/security-of-generating-hash-salts-using-phps-mt-rand
function blowfish($string, $salt = NULL, $iterations = '12')
{
return crypt($string, $salt ?: "$2a\$$iterations$" . md5(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)));
}
@d1rk
d1rk / cron.php
Created May 16, 2012 14:28 — forked from tmaiaroto/cron.php
Lithium Cron Wrapper
<?php
/**
* This script is meant to be executed via crontab.
* It should help you easily set li3 commands as cron jobs.
*
* You should put this in the root of your application.
* However, you don't need to, but you would then need to
* pass a --path= option with the path to your app.
* This is because the li3 console command must be called
* from a specific location.
@d1rk
d1rk / errors.php
Created August 28, 2012 18:46 — forked from rmarscher/errors.php
li3 airbrake in errors bootstrap
<?php
use lithium\action\Response;
use lithium\core\Environment;
use lithium\core\ErrorHandler;
use lithium\core\Libraries;
use lithium\console\Response as ConsoleResponse;
use lithium\net\http\Media;
use lithium\analysis\Logger;
use lithium\net\http\Service;
@d1rk
d1rk / Base.php
Created September 20, 2012 10:58 — forked from nateabele/Base.php
MongoDB-based model accessors (relationships) in Lithium
<?php
namespace my_app\models;
use MongoId;
use lithium\data\collection\DocumentArray;
use lithium\data\collection\DocumentSet;
use lithium\data\entity\Document;
use lithium\util\Inflector;
use lithium\core\Libraries;
@d1rk
d1rk / Form.php
Last active January 15, 2018 19:25 — forked from wms/Form.php
overwrite li3 default Form->input() to be more bootstrap-ready.
<?php
namespace app\extensions\helper;
class Form extends \lithium\template\helper\Form {
/**
* String templates used by this helper.
*
* @var array
@d1rk
d1rk / virtual.conf
Last active January 15, 2018 19:24 — forked from tmaiaroto/virtual.conf
nginx configuration with subdomain variable extracting
#
# A virtual host using mix of IP-, name-, and port-based configuration.
# This is based on using Homebrew for OS X. You can use this in other
# cases though, but you'll likely need to adjust some of the paths below.
#
server {
# Replace this port with the right one for your requirements
# listen 80 [default|default_server]; #could also be 1.2.3.4:80