Skip to content

Instantly share code, notes, and snippets.

View twesolowski's full-sized avatar

Tom Woo twesolowski

View GitHub Profile
@twesolowski
twesolowski / RoboFile.php
Last active June 7, 2016 06:30
RoboFile : Prestashop database backup
<?php
class RoboFile extends \Robo\Tasks
{
function dbbackup($resultFile = "mysqldump.sql")
{
$server = $this->taskExec("presh constant _DB_SERVER_")->printed(false)->run()->getOutputData();
$user = $this->taskExec("presh constant _DB_USER_")->printed(false)->run()->getOutputData();
$name = $this->taskExec("presh constant _DB_NAME_")->printed(false)->run()->getOutputData();
@twesolowski
twesolowski / PolishHoliday.php
Last active February 26, 2016 10:49
PilishHolidays
<?php
class PolishHoliday{
private function holidaysStatic(){
$holiday = array();
$holiday["new_years_eve"] = array("date" => array("m"=>1, "d"=>1), "name" => "New Year's Eve" );
$holiday["epiphany"] = array("date" => array("m"=>1, "d"=>6) , "name" => "Epiphany" );
$holiday["labor_day"] = array("date" => array("m"=>5, "d"=>6), "name" => "Labor Day / May Day" );
@twesolowski
twesolowski / parse.php
Last active March 1, 2018 12:22
Prestashop country translation importer
<?php
/*
* example usage: php parse.php --file="de\data\country.xml" --lang=de --prefix=ps_
* generates imports country translations in DE lang
*/
$options = getopt(null, array(
"file:", // Required
"prefix::", // Optional
"lang::" // Required
@twesolowski
twesolowski / AdminAddressesController.php
Last active August 29, 2015 14:23
Prestashop - addresses export - add Customer ID to csv file (prestashop 1.6.0.11)
<?php
/*
* Should be placed in \override\controllers\admin\AdminAddressesController.php
* remember to delete cache\class_index.php
*/
class AdminAddressesController extends AdminAddressesControllerCore
{
public function __construct()
@twesolowski
twesolowski / getElementByXpath.js
Created June 18, 2015 06:13
getElementByXpath
function getElementByXpath(path) {
return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
console.log( getElementByXpath("//html[1]/body[1]/div[1]") );
@twesolowski
twesolowski / bootstrap_media_queries.less
Last active August 29, 2015 14:21
Bootstrap less media queries
@media(max-width: @screen-xs-max){}
@media(min-width: @screen-sm-min){} /* deprecated: @screen-tablet, or @screen-sm */
@media(min-width: @screen-md-min){} /* deprecated: @screen-desktop, or @screen-md */
@media(min-width: @screen-lg-min){} /* deprecated: @screen-lg-desktop, or @screen-lg */
@twesolowski
twesolowski / install.sql
Last active August 29, 2015 14:20
mysql log
CREATE TABLE `log` (
`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
`message` TEXT NULL,
`level` ENUM('error','warn','info','debug','trace') NULL DEFAULT 'info',
`class` VARCHAR(20) NULL DEFAULT NULL,
`date` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
)
COLLATE='latin1_swedish_ci'
ENGINE=InnoDB
@twesolowski
twesolowski / logquery.lua
Created March 30, 2015 10:49
logquery.lua
function read_query(packet)
if string.byte(packet) == proxy.COM_QUERY then
query = string.sub(packet, 2)
log_query(query)
end
end
function log_query(query)
output = os.date() .. ";QUERY;" .. query
print(output)
@twesolowski
twesolowski / all-hooks.lua
Last active August 29, 2015 14:18
Mysql proxy all hooks
-- all-hooks.lua
local access_ndx = 0
function read_auth( auth )
print_access ('inside read_auth ')
end
function connect_server()
print_access ('inside connect_server')
end
function read_handshake( auth )
print_access ('inside read_handshake' )
@twesolowski
twesolowski / .gitignore
Created February 20, 2015 07:55
Wordpress gitignore
/*
!.gitignore
!wp-content/
*.7z
*.dmg
*.gz
*.iso
*.jar
*.rar