Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View pawlik's full-sized avatar
🎯
Focusing

Grzegorz Pawlik pawlik

🎯
Focusing
View GitHub Profile
@pawlik
pawlik / delegator.md
Last active August 29, 2015 14:17
Delegator

:trollface: 👍 👎 ✈️ 🎨 🐻 🍺 🚲 💣 📖

@pawlik
pawlik / mgnt-maintenance.go
Created February 13, 2015 14:06
cmd script to enable/disable maintenance mode in magento 1.*
package main
import (
"fmt"
io "io/ioutil"
"os"
"flag"
)
func usage() {
@pawlik
pawlik / gist:5189e75a4ccbd52fa589
Last active August 29, 2015 14:12
is ruby like tap possible in php even in ?
<?php
class Tappable {
private $whatever = null;
public function __construct($whatever) {
$this->whatever = $whatever;
}
public function tap(callable $callback) {
goal: give helper A possibility to inject 'tax helper', if none injected - Mage::helper('tax') should be used by default.
both ways work:
1)
```php
/**
* @var Mage_Tax_Helper_Data
*/
@pawlik
pawlik / gist:93b3d203d9a777916f65
Created September 15, 2014 14:38
Hex color game cheat

http://johnsythinks.com/hex/

Thanks to http://www.javascripter.net/faq/hextorgb.htm

function hexToR(h) {return parseInt((cutHex(h)).substring(0,2),16)}
function hexToG(h) {return parseInt((cutHex(h)).substring(2,4),16)}
function hexToB(h) {return parseInt((cutHex(h)).substring(4,6),16)}
function cutHex(h) {return (h.charAt(0)=="#") ? h.substring(1,7):h}

this is my quick resolve function:

class Iterator2ArrayDecorator {
/**
* @var \Iterator
*/
private $iterator;
public function __construct(\Iterator $iterator)
{
$this->iterator = $iterator;
@pawlik
pawlik / ModuleInjectorTest.php
Created April 18, 2013 14:56
POC how to use traits for injecting functionality to objects
<?php
/**
* Created by JetBrains PhpStorm.
* User: gpawlik
* Date: 4/18/13
* Time: 4:42 PM
* To change this template use File | Settings | File Templates.
*/
class ModuleInjectorTest extends PHPUnit_Framework_TestCase {
@pawlik
pawlik / gist:4052010
Created November 10, 2012 18:20
heroku db:push
/home/greg/.rvm/gems/ruby-1.8.7-p358/gems/sequel-3.20.0/lib/sequel/adapters/postgres.rb:211: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0034 p:---- s:0153 b:0153 l:000152 d:000152 CFUNC :initialize
c:0033 p:---- s:0151 b:0151 l:000150 d:000150 CFUNC :new
c:0032 p:0089 s:0141 b:0141 l:000140 d:000140 METHOD /home/greg/.rvm/gems/ruby-1.8.7-p358/gems/sequel-3.20.0/lib/sequel/adapters/postgres.rb:211
c:0031 p:0012 s:0134 b:0134 l:000768 d:000133 BLOCK /home/greg/.rvm/gems/ruby-1.8.7-p358/gems/sequel-3.20.0/lib/sequel/database/misc.rb:45
c:0030 p:---- s:0131 b:0131 l:000130 d:000130 FINISH
c:0029 p:---- s:0129 b:0129 l:000128 d:000128 CFUNC :call
@pawlik
pawlik / gist:4048819
Created November 9, 2012 22:45
fault spec migration test
# file extract_addresses_from_companies
load 'spec/spec_helper.rb'
load 'db/migrate/20121109212148_extract_addresses_from_companies.rb'
describe ExtractAddressesFromCompanies do
before do
@previous_migration_version = '20121108165838'
@my_migration_version = '20121109212148'
end