Skip to content

Instantly share code, notes, and snippets.

View ekka21's full-sized avatar

Ekkachai Danwanichakul ekka21

View GitHub Profile
@ekka21
ekka21 / gist:4333020
Last active December 9, 2015 21:48
Linux: gource
gource --user-image-dir .git/avatar/ --max-file-lag 3 --seconds-per-day 1 --hide filenames,mouse,progress -1024x768 -o - | ffmpeg -y -b 3000K -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -vpre /usr/share/ffmpeg/libx264-lossless_slow.ffpreset -threads 0 gource.mp4
@ekka21
ekka21 / gist:3709235
Created September 12, 2012 19:19
Wordpress: wysiwyg editor
//Ref: http://codex.wordpress.org/Function_Reference/the_editor
//== how to add TinyMCE wysiwyg to your custom textarea plugin ==
the_editor($content, $id, $prev_id, $media_buttons, $tab_index, $extended);
@ekka21
ekka21 / gist:3708136
Created September 12, 2012 17:02
Wordpress: pagination pagenavi
<!-- Start Additional Resoruce Loop -->
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'additionalresource',
'posts_per_page' => 10,
'paged' => $paged,
'orderby' => 'date',
);
$the_query = new WP_Query( $args );
@ekka21
ekka21 / disable-plugins-when-doing-local-dev.php
Created August 30, 2012 14:28 — forked from markjaquith/disable-plugins-when-doing-local-dev.php
Disables specified WordPress plugins when doing local development
<?php
/*
Plugin Name: Disable plugins when doing local dev
Description: If the WP_LOCAL_DEV constant is true, disables plugins that you specify
Version: 0.1
License: GPL version 2 or any later version
Author: Mark Jaquith
Author URI: http://coveredwebservices.com/
*/
@ekka21
ekka21 / gist:3512582
Created August 29, 2012 13:34
Javascript: confirm delete alert box
var confirmDel = confirm("Are you sure? This is your last chance!");
if(confirmDel === true)
{
return true;
} else {
return false;
}
@ekka21
ekka21 / linux find permission
Created August 25, 2012 15:30
Linux: find file permission
//find all with permission 777
find / -type f -perm 0777
//find all without permission 777
find / -type f ! -perm 0777
//Wordpress chmod permission
define('FS_METHOD', 'direct');
@ekka21
ekka21 / gist:3465530
Created August 25, 2012 13:17
Linux: tar
#Creating an archive using tar command
*c – create a new archive
*v – verbosely list files which are processed.
*f – following is the archive file name
*z – filter the archive through gzip
Note: .tgz is same as .tar.gz
//compress
tar cvf archive_name.tar dirname/
@ekka21
ekka21 / sql create view
Created August 22, 2012 17:52
sql create view
CREATE VIEW `table_view`
AS
select
*
from
table
where
id=...
@ekka21
ekka21 / Javascript e.preventDefault();
Created August 18, 2012 15:13
Javascript: e.preventDefault()
var normal = document.querySelector('.normal'),
prevent = document.querySelector('.prevent');
prevent.addEventListener('click', function(ev) {
alert('fabulous, really!');
ev.preventDefault();
}, false);
normal.addEventListener('click', function(ev) {
alert('fabulous, really!');
@ekka21
ekka21 / gist:3381924
Created August 17, 2012 19:42
Javascript: allow only digits zipcode zip
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
<input type="text" onkeypress="return isNumberKey(event)" maxlength="5" placeholder="Search by Zip" id="addressInput">