Skip to content

Instantly share code, notes, and snippets.

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

Maciej Łebkowski mlebkowski

🤷‍♀️
View GitHub Profile
#!/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
@mlebkowski
mlebkowski / services.yml
Created April 1, 2016 10:22
Implementing strategy backend using nassau/registry-compiler
#
# 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
<?php
/**
* @inheritDoc
*/
protected function renderCustomSearchView(NodeTranslation $nodeTranslation, SearchViewTemplateInterface $page)
{
$view = $page->getSearchView();
$renderContext = new RenderContext([
@mlebkowski
mlebkowski / AppKernel.php
Created April 15, 2016 08:43
Simple kernel to populate symfony cache for PHPStorm
<?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()
#!/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 / README.md
Last active May 6, 2016 20:16
Choose one of the parent directories to change to

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
<?php
function str_startswith($str, $needle) {
return 0 === strpos($str, $needle);
}
function str_startswith($str, $needle) {
return $needle === substr($str, 0, strlen($needle));
}
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
<?php
Trait OnceTrait {
private $once = [];
protected function once($callback, ...$arguments)
{
$hash = $this->hashOnceMethod(func_get_args());
<?php
function array_to_entries(array $array) {
return array_map(function ($key, $value) {
return [
"key" => $key,
"value" => $value,
];
}, array_keys($array), array_values($array));
}