Skip to content

Instantly share code, notes, and snippets.

Maciej Łebkowski mlebkowski

Block or report user

Report or block mlebkowski

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View OnceTrait.php
<?php
Trait OnceTrait {
private $once = [];
protected function once($callback, ...$arguments)
{
$hash = $this->hashOnceMethod(func_get_args());
View deploy-to-hub-wercker.yml
deploy-to-hub:
steps:
- script:
name: import application slug
code: |-
herokuish slug import < $WERCKER_SOURCE_DIR/slug.tgz
- script:
name: re-create application user
code: |-
useradd -u $(stat -c %u /app) zabka
View str_startswith.php
<?php
function str_startswith($str, $needle) {
return 0 === strpos($str, $needle);
}
function str_startswith($str, $needle) {
return $needle === substr($str, 0, strlen($needle));
}
@mlebkowski
mlebkowski / README.md
Last active May 6, 2016
Choose one of the parent directories to change to
View README.md

up

Interactively choose one of the parent dirs to change to.

Requirements & Installation

  1. Install percol
  2. Setup your shell to load the up function at startup
  • In fish use funced up, paste contents, funcsave up
  • In bash paste it in .bashrc or any other file and source it from .bashrc
View update-heroku-db
#!/bin/bash
set -euo pipefail
parse_dsn() {
declare dsn=$1 part=$2
php -r 'echo parse_url($_SERVER["argv"][1], constant("PHP_URL_" . strtoupper($_SERVER["argv"][2])));' -- "$dsn" $part
}
@mlebkowski
mlebkowski / AppKernel.php
Created Apr 15, 2016
Simple kernel to populate symfony cache for PHPStorm
View AppKernel.php
<?php
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Routing\RouteCollection;
class AppKernel extends Symfony\Component\HttpKernel\Kernel
{
public function registerBundles()
View service.php
<?php
/**
* @inheritDoc
*/
protected function renderCustomSearchView(NodeTranslation $nodeTranslation, SearchViewTemplateInterface $page)
{
$view = $page->getSearchView();
$renderContext = new RenderContext([
@mlebkowski
mlebkowski / services.yml
Created Apr 1, 2016
Implementing strategy backend using nassau/registry-compiler
View services.yml
#
# Convert this configuration value to a container parameter: %foobar.api_strategy%
#
foobar:
api_strategy: readonly
services:
foobar.api.strategy:
class: 'FoobarBundle\Service\Api\StrategyApiService'
public: false
View letsencrypt-renew.sh
#!/bin/bash
set -ueo pipefail
TLS_HOME=${TLS_HOME:-"/etc/letsencrypt"}
NGINX_CERTS=${NGINX_CERTS:-"/home/puck/dotfiles/nginx/certs"}
cert_expires() {
declare cert=$1
View deployment.sh
#!/bin/bash
if [ -z "$AWS_ACCESS_KEY_ID" -o -z "$AWS_SECRET_ACCESS_KEY" ]; then
echo 'Please define AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY' >&2
exit 127;
fi
if [ -z "$BUILDER_APP_ID" -o -z "$BUILDER_STACK_ID" ]; then
echo 'Please define the application and stack for builder using BUILDER_APP_ID and BUILDER_STACK_ID' >&2
exit 127;
You can’t perform that action at this time.