Skip to content

Instantly share code, notes, and snippets.

View liverbool's full-sized avatar

Ishmael Dos liverbool

  • Earth
View GitHub Profile
@liverbool
liverbool / flatten-array.php
Last active May 14, 2020 08:07
How to fast flatten array in php.
<?php
# Flatten array and modify it's value
# [[1, 2, 3, 4, [3, 4]] => [1, 2, 3, 4, 3, 4]
# php ./script.php to test
$total = 30000;
$mockData = [];
for($i = 1; $i < $total; $i++) {
@liverbool
liverbool / url_slug.php
Created July 11, 2016 17:49 — forked from sgmurphy/url_slug.php
URL Slugs in PHP (with UTF-8 and Transliteration Support)
<?php
/**
* Create a web friendly URL slug from a string.
*
* Although supported, transliteration is discouraged because
* 1) most web browsers support UTF-8 characters in URLs
* 2) transliteration causes a loss of information
*
* @author Sean Murphy <[email protected]>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@liverbool
liverbool / bootstrap_4_horizontal_layout.html.twig
Created March 22, 2016 09:32
bootstrap_4_horizontal_layout.html.twig
{% use "web:Form:bootstrap_4_layout.html.twig" %}
{# Labels #}
{% block form_label -%}
{% if label is same as(false) %}
<div class="{{ block('form_label_class') }}"></div>
{% else %}
{% set label_attr = label_attr|merge({class: (label_attr.class|default('') ~ ' ' ~ block('form_label_class'))|trim}) %}
{{- parent() -}}
@liverbool
liverbool / bootstrap_4_layout.html.twig
Created March 22, 2016 09:32
bootstrap_4_layout.html.twig
{% use "form_div_layout.html.twig" %}
{# Widgets #}
{% block form_widget_simple -%}
{% if type is not defined or 'file' != type %}
{%- set attr = attr|merge({class: (attr.class|default('') ~ ' form-control')|trim}) -%}
{% endif %}
{{- parent() -}}
{%- endblock form_widget_simple %}
@liverbool
liverbool / php70-apcu.sh
Last active March 21, 2016 11:16 — forked from TomK/php70-apcu.sh
PHP7 APCU
#!/bin/bash
# make sure you switch to php70
brew unlink php56 && brew link php70
# checkout and build
git clone [email protected]:krakjoe/apcu
cd apcu
make clean
@liverbool
liverbool / .bash_profile
Created March 12, 2016 14:05
Install NGINX, PHP-FPM (5.5.6), Mongo and MySql
#############################################################################
# current prompt
#############################################################################
# \d – Current date
# \t – Current time
# \h – Host name
# \# – Command number
# \u – User name
# \W – Current working directory (ie: Desktop/)
# \w – Current working directory, full path (ie: /Users/Admin/Desktop)
@liverbool
liverbool / gist:4b62ffe3194110a475c8
Last active August 27, 2015 20:39 — forked from ebuildy/gist:5d4ad0998848eaefdad8
Setup sentry logger on a fresh Ubuntu server
sudo apt-get update
sudo apt-get install python-virtualenv
sudo apt-get install python-dev
sudo apt-get install postgresql
sudo apt-get install postgresql-server-dev-9.3
sudo apt-get install redis-server
sudo -u postgres createuser -s sentry
sudo -u postgres psql -c "alter user sentry with password 'sentry';"
@liverbool
liverbool / basic-mac-dev-setup.sh
Last active August 29, 2015 14:24
Basic Mac Developer Setup
# Basic Mac Developer Setup
# =========================
sudo ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" &&\
brew install wget &&\
brew install caskroom/cask/brew-cask &&\
brew cask install google-chrome &&\
brew cask install google-drive &&\
brew cask install git &&\
brew cask install github &&\
@liverbool
liverbool / README.md
Last active August 29, 2015 14:20 — forked from revett/README.md

Tutum Zero Downtime Re-deploy

cats.jpg

I tweeted Tutum last night asking if they're looking at implementing zero downtime re-deploys for a given service. Slightly surprised by their response as it seems like a critical feature if you want to use the service for a production environment.

"not a top priority, but by Spring :)"

As Tutum currently doesn't support graceful termination of containers within a service, I was experiencing a 5-10 second window of 503 errors, so decided to use the following hack (code below) until the feature is officially implemented.

@liverbool
liverbool / swap.sh
Created April 22, 2015 03:28
mkswap
#!/bin/bash
# https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880
sudo install -o root -g root -m 0600 /dev/null /swapfile
dd if=/dev/zero of=/swapfile bs=1k count=2048k
mkswap /swapfile
swapon /swapfile
echo "/swapfile swap swap auto 0 0" | sudo tee -a /etc/fstab
sudo sysctl -w vm.swappiness=10
echo vm.swappiness = 10 | sudo tee -a /etc/sysctl.conf