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 / list_array_items.php
Last active April 7, 2017 07:35
Menampilkan elemen-elemen Array dengan elemen terakhir diberi tambahan 'dan' atau 'and'
<?php
$last = array_slice($array, -1);
$first = join(', ', array_slice($array, 0, -1));
$both = array_filter(array_merge(array($first), $last));
echo join(', dan ', $both);
@yohangdev
yohangdev / chmod_755_644.sh
Created September 23, 2014 04:06
Chmod all files (644), folder (755), and subdirectories
find . -type d -print0 | xargs -0 chmod 0755 # For directories
find . -type f -print0 | xargs -0 chmod 0644 # For files
<?php
/**
* LDAP PHP Change Password Webpage
* @author: Matt Rude <http://mattrude.com>
* @website: http://technology.mattrude.com/2010/11/ldap-php-change-password-webpage/
*
*
* GNU GENERAL PUBLIC LICENSE
* Version 2, June 1991
@yohangdev
yohangdev / ip-down
Last active August 29, 2015 14:09
OSX Selectively route traffic through VPN /etc/ppp/ip-up
#!/bin/bash
IFNAME="${1}"
LOCALIP="${4}"
REMOTEIP="${5}"
if [[ "${REMOTEIP}" == "10.1.15.1" ]]; then
/sbin/route -n delete "10.0.0.0/8" "10.1.15.1"
fi
@yohangdev
yohangdev / utserver
Last active August 29, 2015 14:09
utorrent server auto start / as service
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=utserver
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/home/javan/utorrent/utserver
#!/bin/sh
# Quick start-stop-daemon example, derived from Debian /etc/init.d/ssh
set -e
# Must be a valid filename
NAME=foo
PIDFILE=/var/run/$NAME.pid
#This is the command to be run, give the full pathname
DAEMON=/usr/local/bin/bar
@yohangdev
yohangdev / switchjava.sh
Created November 15, 2014 06:22
OSX switch JDK/JRE version
export JAVA_HOME=`/usr/libexec/java_home -v 1.7.0_71`
@yohangdev
yohangdev / select.js
Created December 1, 2014 09:02
What is the best way to add options to a select from an array
selectValues = { "1": "test 1", "2": "test 2" };
$.each(selectValues, function(key, value) {
$('#mySelect')
.append($('<option>', { value : key })
.text(value));
});
@yohangdev
yohangdev / postgresql_id.sql
Last active January 17, 2023 07:19
PostgreSQL Better ID & UUID Generator
create schema shard_1;
create sequence shard_1.global_id_sequence;
CREATE OR REPLACE FUNCTION shard_1.id_generator(OUT result bigint) AS $$
DECLARE
our_epoch bigint := 1314220021721;
seq_id bigint;
now_millis bigint;
-- the id of this DB shard, must be set for each
-- schema shard you have - you could pass this as a parameter too
@yohangdev
yohangdev / catalina.sh
Created January 13, 2015 07:40
Tomcat Increase PermSize & MaxPermSize
; /usr/share/tomcat7/bin/catalina.sh
JAVA_OPTS="$JAVA_OPTS -Xmx768m -Xms256m -XX:PermSize=512m -XX:MaxPermSize=1024m"