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 / 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 / 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 / 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
@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 <sean@iamseanmurphy.com>
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
@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 git@github.com: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 / doctrine.function.convert.using.php
Last active December 21, 2015 18:09
MySql Convert Charset: CONVERT(... USING ...) for Doctrine 2
<?php
namespace Entities\meta\Functions;
use Doctrine\ORM\Query\Lexer;
use Doctrine\ORM\Query\AST\Functions\FunctionNode;
/**
* "CONVERT" "(" ArithmeticPrimary AliasResultVariable AliasResultVariable ")".
* More info:
* http://dev.mysql.com/doc/refman/5.0/en/cast-functions.html#function_convert
var fs = require("fs");
var dir = __dirname+"/functions";
/**
* Build packages by you want.
* Added by ツ Liverbool
*
* List of packages
* @see https://github.com/kvz/phpjs/tree/master/functions
@liverbool
liverbool / intb-dev-env.sh
Last active November 16, 2015 03:50
intb-dev-env
#!/bin/bash
locale-gen en_US.UTF-8
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
echo 'Asia/Bangkok' | sudo tee /etc/timezone
apt-get update
apt-get install -y python-software-properties curl zsh git nodejs npm ruby-dev gem && \