Skip to content

Instantly share code, notes, and snippets.

View hariadi's full-sized avatar
😱
Pemuda yang serius

Hariadi Hinta hariadi

😱
Pemuda yang serius
View GitHub Profile
@hariadi
hariadi / tok.js
Created March 8, 2013 18:11
Formatting number into a string representation.
Handlebars.registerHelper('toK', function(number) {
number = number+'';
if (number < 1000) {
return number;
} else if (number < 10000) {
return number.charAt(0) + ',' + number.substring(1);
} else {
return (number/1000).toFixed(number % 1000 != 0)+'k';
}
});
@hariadi
hariadi / sync.sh
Last active December 18, 2015 02:39
Push site updates from master server to front end web servers via rsync
#!/bin/bash
#sync.sh - Push site updates from master server to front end web servers via rsync
# USAGE:
# ./sync.sh (rsync all node)
# ./sync.sh portal2 portal4 (rsync for node portal2 and portal4)
#
# Original script: http://www.stephenlang.net/2012/09/keeping-multiple-web-servers-in-sync-with-rsync/
WEBSERVERS=(${@-portal1 portal2 portal3 portal4 portal5})
STATUS="/srv/www/htdocs/sync.status"
@hariadi
hariadi / test.js
Created June 19, 2013 08:27
just to save
fs = require('fs');
function getDirectoryFiles(directory, callback) {
fs.readdir(directory, function(err, files) {
files.forEach(function(file){
fs.stat(directory + '/' + file, function(err, stats) {
if(stats.isFile()) {
callback(directory + '/' + file);
}
if(stats.isDirectory()) {
@hariadi
hariadi / dencrypt.asp
Last active December 20, 2015 10:49
HRMIS url parameter insecure P.O.C
<%@ LANGUAGE="VBSCRIPT" %>
<% Option Explicit %>
<%
'Test online: http://www.interactive.jpa.gov.my/smp/hrmis.asp
Dim counter, myArray, parameter, important, notimportant, weneed, userandpass, user, pass, username, password
Private Function Encrypt(ByVal string)
Dim x, i, tmp
For i = 1 To Len( string )
x = Mid( string, i, 1 )
@hariadi
hariadi / httpd-git.conf
Created August 20, 2013 23:46
Apache > 2.4 Git Config
<VirtualHost *:80>
# Configure hostname
ServerAdmin postmaster@jpa.gov.my
ServerName git.jpa.gov.my
# Repository location
DocumentRoot /data/www/jpa.gov.my/git
# Deny to access
<Files ~ "(^\.htaccess|^.*\.conf)">
@hariadi
hariadi / rsync-syslog.sh
Created October 3, 2013 08:17
rsync syslog every day at 4:30 AM
/bin/echo "Attempting to rsync" >> /path/rsync.log
30 4 * * * rsync -avz /var/log/syslog.2.gz root@<remote-ip>:/path/vendor/
@hariadi
hariadi / wpxml2md.js
Last active December 26, 2015 12:09
wp xml to md (wip)
var fs = require('fs');
var parseString = require('xml2js').parseString;
var util = require('util');
var async = require('async');
var file = './hariadiorg.wordpress.2013-10-25.xml';
var file = './simple.xml';
var savedResult = true;
@hariadi
hariadi / redirect
Created January 10, 2014 02:34
redirect
RedirectMatch permanent ^/docs/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/([A-Za-z0-9-]+).(pdf|xls|xlsx|ppt|doc|docx)$ /docs/$1/$2/$4.$5
@hariadi
hariadi / re-sync-mysql-replication.md
Last active August 29, 2015 13:56
Re-sync MySQL Replication

Re-sync MySQL Replication

Do this command in all server. In this example I'm use 2 server master-master replication

MASTER

RESET MASTER;
SHOW MASTER STATUS\G;
@hariadi
hariadi / isogram.js
Created February 6, 2014 07:34
isogram
(function(arg1,arg2,arg3,arg4,arg5,arg6,arg7){arg1['GoogleAnalyticsObject']=arg5;arg1[arg5]=arg1[arg5]||function(){
(arg1[arg5].q=arg1[arg5].q||[]).push(arguments)},arg1[arg5].l=1*new Date();arg6=arg2.createElement(arg3),
arg7=arg2.getElementsByTagName(arg3)[0];arg6.async=1;arg6.src=arg4;arg7.parentNode.insertBefore(arg6,arg7)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-XXXXXX-X', 'example.com');
ga('send', 'pageview');