Skip to content

Instantly share code, notes, and snippets.

View yohangdev's full-sized avatar
🏠
Working from home

Yoga Hanggara yohangdev

🏠
Working from home
View GitHub Profile
@yohangdev
yohangdev / Pipeline.php
Last active January 17, 2019 08:36
PHP #2 - Pipeline
<?php
class Pipeline
{
public static function make_pipeline(...$funcs)
{
return function($arg) use ($funcs)
{
$x = $arg;
@yohangdev
yohangdev / Palindrome.php
Created January 17, 2019 08:28
PHP #1 - Palindrome
<?php
class Palindrome
{
public static function isPalindrome($word)
{
$toLowercase = strtolower($word);
$wordLength = strlen($toLowercase);
@yohangdev
yohangdev / selinux_centhos_php.sh
Last active November 14, 2018 04:32
SELinux Centos PHP Hell
ls -lZ
setsebool -P httpd_enable_homedirs true
chcon -R -t httpd_sys_content_t /var/www/html/
setsebool -P httpd_can_network_connect_db on
chcon -R -t httpd_sys_rw_content_t /dir
@yohangdev
yohangdev / moment_duration_format.js
Created October 10, 2018 15:15
MomentJS Duration Custom Format
moment.utc(span.asMilliseconds()).format('HH:mm:ss');
@yohangdev
yohangdev / cheatsheet.sql
Last active October 9, 2018 18:05
MySQL Cheatsheet
ALTER TABLE `absensi_rekap`
CHANGE COLUMN `created_at` `created_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP,
CHANGE COLUMN `updated_at` `updated_at` TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
UPDATE absensi_raw SET absensi_timestamp = CONVERT_TZ(absensi_datetime, 'Asia/Jakarta', 'UTC');
UPDATE absensi_raw SET absensi_timestamp = CONVERT_TZ(absensi_datetime, '+07:00', '+00:00');
DELIMITER //
CREATE TRIGGER absensi_raw_insert_timestamp
BEFORE INSERT
@yohangdev
yohangdev / gcloud.sh
Last active October 8, 2018 18:17
My Google Cloud Engine / Cloud Functions Cheatsheet
gcloud init
export GOOGLE_APPLICATION_CREDENTIALS="/home/secrets.json"
functions-emulator start --tail
functions-emulator deploy attendances --trigger-http
functions-emulator stop
@yohangdev
yohangdev / shell.sh
Last active September 28, 2018 06:25
MongoDB move data directory issues with CentOS SELinux (Attempted to create a lock file on a read-only directory: /data/db, terminating)
ls -dZ /data/db/
ls -dZ /var/lib/mongo/
chcon -R --reference=/var/lib/mongo /data/db
# issues https://github.com/UnderGreen/ansible-role-mongodb/issues/87
docker ps -f status=exited | grep "\-cache-" | awk '{print $1}' | xargs docker rm
@yohangdev
yohangdev / Dockerfile
Created September 14, 2018 16:17
Docker PHP 7.2 FPM + Phalcon 3 + FRAPP
FROM php:7.2.9-fpm
WORKDIR /application
RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y git libpq-dev libldap2-dev libxml2-dev zlib1g-dev libpng-dev libcurl4-gnutls-dev
RUN docker-php-ext-configure pgsql --with-pgsql=/usr/local/pgsql \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/
@yohangdev
yohangdev / docker.sh
Last active December 16, 2020 18:23
My Docker Cheatsheet
docker run --rm -it -v $(pwd):/application --workdir=/application composer install
docker run --rm -it -v $(pwd):/application --workdir=/application composer create-project francescomalatesta/laravel-api-boilerplate-jwt laravel-api
docker run --name mysql5.7 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -p 3306:3306 -d mysql:5.7
docker service create --name mysql -e MYSQL_ALLOW_EMPTY_PASSWORD=yes --publish published=3306,target=3306,protocol=tcp mysql:5.7
docker volume create postgres10.5_data
docker run --name postgres10.5 -v postgres10.5_data:/var/lib/postgresql/data -d -p 5432:5432 postgres:10.5