Skip to content

Instantly share code, notes, and snippets.

View tawfekov's full-sized avatar
🏠
Working from home

Tawfek Daghistani tawfekov

🏠
Working from home
View GitHub Profile
@tawfekov
tawfekov / gittyup.sh
Created July 25, 2012 09:37 — forked from EvanDotPro/gittyup.sh
Easily keep master in sync with upstream.
####################################################################################
## ##
## gittyup() - Easily keep master in sync with upstream. ##
## ##
## Author: Evan Coury, http://blog.evan.pro/ ##
## URL: https://gist.github.com/1506822 ##
## ##
## This bash function is a simple shortcut for keeping your local (and public ##
## fork / origin remote) master branch up to date and in sync with the upstream ##
## master. To use gittyup(), simply drop this in your ~/.bashrc. ##
@tawfekov
tawfekov / generator.php
Last active March 2, 2024 16:06
Doctrine2 Generate Entities form Existing Database
<?php
include '../vendor/autoload.php';
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();
// config
$config = new \Doctrine\ORM\Configuration();
<?php
define('ZF2_PATH', realpath(__DIR__ . '/../vendor/ZendFramework/library'));
@tawfekov
tawfekov / Selenium2.php
Created February 11, 2013 10:24
Selenium2Driver screenshot example
<?php
include_once 'vendor/autoload.php';
$driver = new \Behat\Mink\Driver\Selenium2Driver();
// init session:
$session = new \Behat\Mink\Session($driver);
// start session:
$session->start();
// open some page in browser:
$session->visit('http://www.facebook.com/');
<?php
/**
* @package toolkit
*/
/**
* URL rewriter for use in conjunction with the PHP 5.4 internal HTTP server and `rounter.php`.
*/
namespace Rewrite;
@tawfekov
tawfekov / console.php
Created June 25, 2013 13:17
ZF2 application with Symfony Console
#!/usr/bin/php
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
@tawfekov
tawfekov / update_currency.php
Last active December 30, 2015 03:29
update magento currency via cron or simple php script
<?php
include("app/Mage.php");
Mage::app();
$now = new \DateTime();
echo "start downloading rates : {$now->format("Y-m-d H:i:s")}\n";
$model = Mage::getModel("directory/currency");
$currency_converter= Mage::getModel("directory/currency_import_webservicex");
$rates = $currency_converter->fetchRates();
echo json_encode($rates) . "\n";
echo "has been downloaded\n";
<?php
/*
To make the cleaning expired carts automatic, override cleanExpiredQuotes with the following
version which will also take care of the old active carts: app/code/core/Mage/Sales/Model/Observer.php
*/
public function cleanExpiredQuotes($schedule)
{
// extending limit
@tawfekov
tawfekov / .vimrc
Created June 15, 2014 18:23 — forked from JeffreyWay/.vimrc
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...