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 / ConvertAlwaysDateTimeToDefaultTimezoneTrait.php
Created August 13, 2018 11:41
Laravel Eloquent Datetime with Timezone
<?php
/**
* Always treats dates as DateTime objects and adjusts their timezone
* to app.timezone, if different.
*
* In combination with Eloquent\Model protected $dates, this trait can ensure
* that:
* a) whever date (string, \DateTime, \Carbon\Carbon) will always
* be treated as \DateTime
@yohangdev
yohangdev / myalias.sh
Created July 15, 2018 03:08
My personal bash shell alias
alias d-yarn-install="docker run --rm -it --workdir=/myapp -v $(pwd):/myapp node yarn install"
@yohangdev
yohangdev / booking.php
Last active January 25, 2021 03:05
Booking, check is room or venue available
<?php
$model = DB::table('kpt160')->whereRaw(
'kpt160.room_name = :room_name AND
(
(kpt160.inspection_date_begin <= :idb AND kpt160.inspection_date_end >= :idb) OR
(kpt160.inspection_date_begin < :ide AND kpt160.inspection_date_end >= :ide) OR
(:idb < kpt160.inspection_date_begin AND :ide > kpt160.inspection_date_begin)
)',
[
'room_name' => $requestRoomId,
@yohangdev
yohangdev / rebase.sh
Created June 25, 2018 19:09
Git Rebase Feature Branch with upstream/master
// from feature branch
git pull upstream master -—rebase
git push origin <nama branch yang di PR> -f
@yohangdev
yohangdev / certbot.sh
Created March 16, 2018 16:14
Certbot Lets Encrypt Wildcard SSL Certificate
./certbot-auto certonly --server https://acme-v02.api.letsencrypt.org/directory --preferred-challenges dns --manual
# https://certbot.eff.org/docs/using.html#dns-plugins
@yohangdev
yohangdev / oauth.js
Created January 29, 2018 18:13 — forked from srph/oauth.js
axios: interceptor which includes your oauth token in every request as an Authorization header
import axios from 'axios';
// You can use any cookie library or whatever
// library to access your client storage.
import cookie from 'cookie-machine';
axios.interceptors.request.use(function(config) {
const token = cookie.get(__TOKEN_KEY__);
if ( token != null ) {
config.headers.Authorization = `Bearer ${token}`;
@yohangdev
yohangdev / twitter_api_v1.1.php
Created December 17, 2017 16:13
Twitter API v1.1 Get Latest Tweet
<?php
// Credit: https://stackoverflow.com/questions/12684765/twitter-api-returns-error-215-bad-authentication-data
$token = 'YOUR_TOKEN';
$token_secret = 'YOUR_TOKEN_SECRET';
$consumer_key = 'CONSUMER_KEY';
$consumer_secret = 'CONSUMER_SECRET';
$host = 'api.twitter.com';
$method = 'GET';
@yohangdev
yohangdev / telnet_indihome_ztef660.txt
Created December 4, 2017 00:48
Ganti Password Modem ZTE F660 Telkom Indihome
telnet
root/Zte521
sendcmd 1 DB all
sendcmd 1 DB p UserInfo
sendcmd 1 DB set 0 Password <PasswordBaru>
sendcmd 1 DB save
sendcmd 1 DB set TelnetCfg 0 TS_UPwd <PasswordBaru>
@yohangdev
yohangdev / git_extract_between_commits.sh
Created October 10, 2017 07:28
Git Extract/List Modified Files Between Commits and Compress ZIP
zip modified-files.zip $(git diff --name-only SHA1 SHA2)
@yohangdev
yohangdev / php_xdebug_start.sh
Created September 20, 2017 12:33
PHPStorm XDebug Auto Start
php -S 0.0.0.0:8000 -t ./public -d xdebug.remote_enable=1 -d xdebug.remote_autostart=1