Skip to content

Instantly share code, notes, and snippets.

View mlebkowski's full-sized avatar
🤷‍♀️

Maciej Łebkowski mlebkowski

🤷‍♀️
View GitHub Profile
@mlebkowski
mlebkowski / goat.js
Created January 22, 2015 12:23
Codility challenge
function solution(N) {
// sorry, not really my kind of thing, but here’s a goat:
console.log("\n\
\n\
/) (\\ \n\
)\\.:::::::::./( \n\
\\( o o )/ \n\
'-./ / _.-'`-. \n\
( oo ) / _ \\ \n\
@mlebkowski
mlebkowski / post-release
Last active August 29, 2015 14:15
dokku post-release hook for crontab jobs
#!/usr/bin/env bash
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
APP="$1"; IMAGE="dokku/$APP"
CRONTABS_DIR=$DOKKU_ROOT/.crontab
CONFIG_FILE=$CRONTABS_DIR/$APP.conf
mkdir -p "$CRONTABS_DIR";
<?php
class QueryDependent
{
/**
* @var Callable
*/
private $queryFactory;
<?php
namespace Metricso\Fetcher\ObjectProcessor ;
use Generator ;
use Metricso\Model\Fb\AppUser ;
use Metricso\Model\Fb\FbPage ;
use Metricso\Model\Fb\FbPageFeedQuery ;
class PageProcessor extends AbstractObjectProcessor implements ObjectProcessorInterface, UsingAlternateTokensInterface {
private $queryFactory ;
private $tokenSource ;
<?php
$retry = [
"today" => 'failure-notification',
'+1 day' => 'none',
'+3 days' => 'failure-notification',
'+1 week' => 'failure-notification',
'+2 weeks' => 'failure-notification, suspend'
];
?>
<?php
interface EmailNotifierInterface {
/**
* Client was successfully charged for a project
*
* context: payment_history model (with access to project & invoice)
*/
const NOTIFICATION_CHARGED = 'charged';
<?php
class PaymentsFacade extends Container
{
private $requiredKeys = [
'factory.project',
'price-calculator',
'repository.plan',
'repository.coupon',
'service.authorize-card',
@mlebkowski
mlebkowski / s3.sh
Last active August 29, 2015 14:20 — forked from chrismdp/s3.sh
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@mlebkowski
mlebkowski / functional.php
Last active August 29, 2015 14:25
Functional PHP with a little OOP aid
<?php
// Node[] -> (map) -> NodeTranslation[] -> (map) -> Category[] -> slice
// Purely „functional” PHP:
$parents = array_slice(array_map(function (NodeTranslation $nt)
{
return new Category($nt->getTitle(), $nt->getNode()->getId(), $nt->getSlug());
}, array_map(function (Node $node)
{
@mlebkowski
mlebkowski / dabblet.css
Created February 16, 2012 11:13
The first commented line is your dabblet’s title
/**
* The first commented line is your dabblet’s title
*/
* {
border: 1px dashed silver; width: 100px; height: 100px;
background: #f06;
background: linear-gradient(45deg, #f06, yellow);
min-height:100%;
}