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 / crontab.sh
Created January 24, 2015 15:55
Cron automatic delete .DS_Store files
# sudo crontab -e
0 */2 * * * root find / -name ".DS_Store" -depth -exec rm {} \;
@yohangdev
yohangdev / .bash_profile
Last active August 29, 2015 14:17
OSX switch Java version
# export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/
export JAVA_HOME="`/usr/libexec/java_home -v '1.7.0_25'`
@yohangdev
yohangdev / create_nonlogin_user.sh
Created March 21, 2015 15:48
Create Non Login User
useradd -M --shell /bin/false username
usermod -L username
# http://superuser.com/questions/77617/how-can-i-create-a-non-login-user
@yohangdev
yohangdev / laravel_fetch.php
Created March 25, 2015 17:16
PHP Laravel PDO Fetch (Memory save)
<?php
$query = DB::table('users')->where('name', 'John'); //Pretend this is a huge data set
$statement = $query->getConnection()->getPdo()->prepare($query->toSql());
$statement->execute($query->getBindings());
while ($record = $statement->fetch(PDO::FETCH_ASSOC)) {
//Do whatever you want, one row at a time
}
@yohangdev
yohangdev / gitlab_postgresql.sh
Created April 24, 2015 03:47
Access Gitlab PostgreSQL
su - gitlab-psql
/opt/gitlab/embedded/bin/psql gitlabhq_production
\connect database_name
\dt
@yohangdev
yohangdev / no-ip_ddns_update
Created August 13, 2015 04:38
Mikrotik Script Update Dynamic DDNS / NO-IP
# How To: http://wiki.mikrotik.com/wiki/Dynamic_DNS_Update_Script_for_No-IP_DNS
:log info "START IP Dynamic DNS"
:local NOIPUser "your_email"
:local NOIPPass "your_password"
:local NOIPDomain "your_host_domain"
:log info "Get Public IP Address..."
/tool fetch url="http://myip.dnsomatic.com/mypublicip.txt" mode=http
@yohangdev
yohangdev / pre-commit
Created September 2, 2015 07:27
Git Pre-Commit Hooks Write Commit Hash to File
#!/usr/bin/env bash
set -e
#=== 'prev-commit' solution by o_O Tync
#commit_hash=$(git rev-parse --verify HEAD)
commit=$(git log -1 --pretty="%H%n%ci") # hash \n date
commit_hash=$(echo "$commit" | head -1)
commit_date=$(echo "$commit" | head -2 | tail -1) # 2010-12-28 05:16:23 +0300
branch_name=$(git symbolic-ref -q HEAD) # http://stackoverflow.com/questions/1593051/#1593487
@yohangdev
yohangdev / downgrade_php7.sh
Last active March 14, 2016 22:57
PHP 7.0.4 for Jessie Segmentation Fault Dotdeb
// Rollback to 7.0.0
apt-get install php7.0=7.0.0-1~dotdeb+8.1 \
php7.0-common=7.0.0-1~dotdeb+8.1 \
php7.0-cgi=7.0.0-1~dotdeb+8.1 \
php7.0-fpm=7.0.0-1~dotdeb+8.1 \
php7.0-cli=7.0.0-1~dotdeb+8.1 \
php7.0-json=7.0.0-1~dotdeb+8.1 \
php7.0-mysql=7.0.0-1~dotdeb+8.1 \
php7.0-gd=7.0.0-1~dotdeb+8.1 \
@yohangdev
yohangdev / php-server-router.php
Created May 30, 2016 08:00
PHP Built-in Server Router Script for Laravel
<?php
if (file_exists($_SERVER["DOCUMENT_ROOT"] . $_SERVER["REQUEST_URI"])) {
return false;
} else {
require "public/index.php";
}
@yohangdev
yohangdev / alfresco5_office_preview_fix.md
Last active May 14, 2018 14:35
Alfresco 5 Office Preview Fix

check if libreoffice is running

/opt/alfresco-5.0.a/libreoffice/scripts/libreoffice_ctl.sh status

edit the file /opt/alfresco-5.0.a/alfresco.sh modify the line LIBREOFFICE_SCRIPT with the correct script path

LIBREOFFICE_SCRIPT=$INSTALLDIR/libreoffice/scripts/libreoffice_ctl.sh