Skip to content

Instantly share code, notes, and snippets.

View erikccoder's full-sized avatar

erik-joeng erikccoder

View GitHub Profile
@erikccoder
erikccoder / remove_editor.php
Created May 10, 2013 05:07
wordpress remove editor
/*
Disable content editor for specific page template
*/
add_action('admin_init', 'hide_editor');
function hide_editor() {
$post_id = $_GET['post'] ? $_GET['post'] : $_POST['post_ID'];
if (!isset($post_id)) return;
$template_file = get_post_meta($post_id, '_wp_page_template', true);
@erikccoder
erikccoder / ffmpeg.sh
Last active January 27, 2016 01:28
ffmpeg to html5 video.
http://johndyer.name/ffmpeg-settings-for-html5-codecs-h264mp4-theoraogg-vp8webm/
REM mp4 (H.264 / ACC)
ffmpeg -i %1 -b 1500k -vcodec libx264 -vpre slow -vpre baseline -g 30 -s 640x360 %1.mp4
REM webm (VP8 / Vorbis)
ffmpeg -i %1 -b 1500k -vcodec libvpx -acodec libvorbis -ab 160000 -f webm -g 30 -s 640x360 %1.webm
REM ogv (Theora / Vorbis)
ffmpeg -i %1 -b 1500k -vcodec libtheora -acodec libvorbis -ab 160000 -g 30 -s 640x360 %1.ogv
REM jpeg (screenshot at 10 seconds)
ffmpeg -i %1 -ss 00:10 -vframes 1 -r 1 -s 640x360 -f image2 %1.jpg
@erikccoder
erikccoder / disable_bubbling_up_scrolling.js
Created October 17, 2013 06:07
disable touch scrolling bubbling up DOM
//http://stackoverflow.com/questions/16889447/prevent-full-page-scrolling-ios
elem.addEventListener('touchstart', function(event){
this.allowUp = (this.scrollTop > 0);
this.allowDown = (this.scrollTop < this.scrollHeight - this.clientHeight);
this.prevTop = null; this.prevBot = null;
this.lastY = event.pageY;
});
elem.addEventListener('touchmove', function(event){
@erikccoder
erikccoder / drawSkew.cpp
Created February 25, 2014 03:49
draw Skew
void testApp::drawSkew(ofImage * src, ofPoint * tl, ofPoint * tr, ofPoint * br, ofPoint * bl) {
// tl,tr,br,bl = normalized 0.-1.
ofSetColor(255);
src->reloadTexture();
//src->draw(0,0);
//ofDisableArbTex();
src->getTextureReference().bind();
// glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_TEXTURE);
glPushMatrix();
@erikccoder
erikccoder / gl_fbo_alpha_drawing
Last active August 29, 2015 14:03
OpenGL accumulate alpha drawing in FBO
glEnable(GL_BLEND);
//glBlendFuncSeparate(GL_ONE, GL_SRC_COLOR, GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glBlendFuncSeparate(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA,GL_ONE,GL_ONE_MINUS_SRC_ALPHA);
//draw
glDisable(GL_BLEND);
ffmpeg -i "%1" -vcodec copy -acodec pcm_s16le -ac 2 "%1.mov"
property ffplay : "/usr/local/bin/ffplay"
on main(input)
do shell script ffplay & space & quoted form of input
end main
on open argv
repeat with aFile in argv
main(POSIX path of aFile)
end repeat
property ffplay : "/Applications/ffmpeg/ffplay"
on main(input)
do shell script ffplay & space & quoted form of input
end main
on open argv
repeat with aFile in argv
main(POSIX path of aFile)
end repeat
@erikccoder
erikccoder / imageExists.js
Last active August 29, 2015 14:10
imageExists
// The "callback" argument is called with either true or false
// depending on whether the image at "url" exists or not.
function imageExists(url, callback) {
var img = new Image();
img.onload = function() { callback(true); };
img.onerror = function() { callback(false); };
img.src = url;
}
// Sample usage
@echo off
:: app_restart.bat
:: %1 path of application
:loop
tasklist /fi "Status eq NOT RESPONDING" | findstr %~nx1
if %errorlevel%==0 (