Skip to content

Instantly share code, notes, and snippets.

View erikccoder's full-sized avatar

erik-joeng erikccoder

View GitHub Profile
@erikccoder
erikccoder / delay promise.js
Created October 7, 2016 05:52
create a promise which will resolve after given ms.
let delay = ms => new Promise(r => setTimeout(r, ms));
@erikccoder
erikccoder / gist:e3915e737214736c381a
Created October 3, 2015 19:15
Kodi_bookmarklet.js
var videos = document.querySelectorAll("video");
if(videos.length<1){ alert("no video found!"); return;
}
var i=0;
var src = prompt("playIt? " + i + "/" + videos.length, videos[i].src);
if(src == null){ alert("no src found"); return;
}
on open theFileDropped
display alert "Are you sure you want to permanently delete " & the length of theFileDropped & " file(s)?" message "You cannot undo this action." as warning buttons {"Cancel", "OK"} default button 2
if the button returned of the result is "OK" then
repeat with aFile in theFileDropped
do shell script "rm -Rf " & quoted form of POSIX path of aFile
end repeat
do shell script "afplay \"/System/Library/Components/CoreAudio.component/Contents/SharedSupport/SystemSounds/finder/empty trash.aif\""
end if
end open
@erikccoder
erikccoder / VideoAlpha.glsl
Last active August 29, 2015 14:22
Unity3d alpha channel shader
Shader "Custom/VideoAlpha" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_AlphaOffsetX ("alpha offset x", float) = 0.5
_AlphaOffsetY ("alpha offset y", float) = 0
_Cutoff ("Cutoff", Range (0,1)) = .5
}
SubShader {
AlphaTest Less [_Cutoff]
CGPROGRAM
<?php
function pc_validate($user,$pass) {
/* replace with appropriate username and password checking,
such as checking a database */
$users = array('430' => '');
if (isset($users[$user]) && ($users[$user] == $pass)) {
return true;
} else {
@echo off
:: app_restart.bat
:: %1 path of application
:loop
tasklist /fi "Status eq NOT RESPONDING" | findstr %~nx1
if %errorlevel%==0 (
@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
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
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
ffmpeg -i "%1" -vcodec copy -acodec pcm_s16le -ac 2 "%1.mov"