Skip to content

Instantly share code, notes, and snippets.

View ivankristianto's full-sized avatar

Ivan Kristianto ivankristianto

View GitHub Profile
@ivankristianto
ivankristianto / responsive_adsense
Created August 8, 2013 02:07
Responsive Adsense Code
<script type="text/javascript"><!--
adUnit = document.getElementById("menuads");
adWidth = adUnit.offsetWidth;
google_ad_client = "ca-pub-5132818893953017";
google_ad_slot = "8312107528";
@ivankristianto
ivankristianto / git-merge-with-sublime
Created August 16, 2013 08:54
Git merge tools with Sublime 2
git config --global mergetool.sublime.cmd "subl -w \$MERGED"
git config --global mergetool.sublime.trustExitCode false
git config --global merge.tool sublime
git mergetool -y
@ivankristianto
ivankristianto / forbidden-php-exec
Created September 15, 2013 14:51
Forbidden PHP function for Server Security
system, show_source, symlink, exec, dl, shell_exec, passthru, escapeshellarg,escapeshellcmd,apache_child_terminate,apache_setenv,define_syslog_variables,fp,fput,ftp_connect,ftp_exec,ftp_get, ftp_login,ftp_nb_fput,ftp_put,ftp_raw,ftp_rawlist,highlight_file,ini_alter,ini_get_all,ini_restore, inject_code, mysql_pconnect, openlog, phpAds_remoteInfo, phpAds_XmlRpc,phpAds_xmlrpcDecode, phpAds_xmlrpcEncode, popen, posix_getpwuid, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid,posix_setuid,posix_uname, syslog,xmlrpc_entity_decode
@ivankristianto
ivankristianto / gist-wp-embed-url
Created September 22, 2013 01:57
This snippet code is to show gist snippet into the WordPress content with just pasting the URL into post content
wp_embed_register_handler( 'gist', '#https://gist\.github\.com/(.+?)/(.+?)($|&)#i', 'wp_embed_handler_gist' );
function wp_embed_handler_gist( $matches, $attr, $url, $rawattr ) {
$embed = sprintf(
'<script src="https://gist.github.com/%1$s/%2$s.js"></script>',
esc_attr($matches[1]),
esc_attr($matches[2])
);
@ivankristianto
ivankristianto / apachebenchmarking
Created October 7, 2013 17:54
Testing with apache benchmarking
/usr/local/apache/bin/ab -t 30 -c 5 http://www.seputarukm.com/
@ivankristianto
ivankristianto / wp-cli.sh
Created October 15, 2013 10:16
WP CLi command list
wp core install --url=url --title=site-title [--admin_name=username] --admin_email=email --admin_password=password
wp core [download|config|install|install_network|version|update|update_db]
wp db [create|drop|optimize|repair|connect|cli|query|export|import]
wp eval-file
wp eval
wp export [validate_arguments]
wp generate [posts|users]
wp home
wp option [add|update|delete|get]
@ivankristianto
ivankristianto / resumeable-file-download.php
Created December 17, 2013 05:53
Resumeable File Download With PHP
function serve_file_resumable ($file, $contenttype = 'application/octet-stream') {
// Avoid sending unexpected errors to the client - we should be serving a file,
// we don't want to corrupt the data we send
@error_reporting(0);
// Make sure the files exists, otherwise we are wasting our time
if (!file_exists($file)) {
header("HTTP/1.1 404 Not Found");
exit;
@ivankristianto
ivankristianto / delete-file.sh
Created January 16, 2014 01:10
Delete all thumbs.db in Linux
find sip-design/ -iname 'thumbs.db' -exec rm -rfv {} +
@ivankristianto
ivankristianto / wp-submenu.php
Created January 17, 2014 10:55
WordPress show submenu based on active parent menu
<?php
// add hook
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects_sub_menu', 10, 2 );
// filter_hook function to react on sub_menu flag
function my_wp_nav_menu_objects_sub_menu( $sorted_menu_items, $args ) {
if ( isset( $args->sub_menu ) ) {
$root_id = 0;
@ivankristianto
ivankristianto / settings_hook.php
Created April 25, 2014 05:29
Calibrefx Concept Settings Hook
<?php
calibrefx_add_meta_group('themeoption-settings', 'breadcrumb', __('Breadcrumb', 'calibrefx'));
calibrefx_add_meta_group('themeoption-settings', 'content-archive', __('Content Archives', 'calibrefx'));
calibrefx_add_meta_group('themeoption-settings', 'comments', __('Comments', 'calibrefx'));
calibrefx_add_meta_option(
'breadcrumb', // group id
'gplus_profile', // field id and option name
__('Google Plus Profile'), // Label
array(