Skip to content

Instantly share code, notes, and snippets.

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

Maciej Łebkowski mlebkowski

🤷‍♀️
View GitHub Profile
<?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 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
#!/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 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()
<?php
/**
* @inheritDoc
*/
protected function renderCustomSearchView(NodeTranslation $nodeTranslation, SearchViewTemplateInterface $page)
{
$view = $page->getSearchView();
$renderContext = new RenderContext([
@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
#!/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
#!/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;
#!/bin/bash
#
# Input is tab separated, UTF-8 with " quotes
#
INPUT="${1:-/dev/stdin}"
printf '\xFF\xFE';
cat "$INPUT" | iconv -f UTF-8 -t UTF-16LE
<?php
interface ContactDiffServiceInterface
{
public function generateDiffContact(ContactInterface $baseContact, ContactInterface $toDiff, $cleanup = true);
}
class ContactDiffService implements ContactDiffServiceInterface
{
public function __construct(IpressoFactoryInterface $factory, AttributeTypeFormatter $formatter);