Skip to content

Instantly share code, notes, and snippets.

View dhfromkorea's full-sized avatar

dh dhfromkorea

View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
hKRib2R5hqhkZXRhY2hlZMOpaGFzaF90eXBlCqNrZXnEIwEgn+cKNDjDeEyrkcOlPC8qsMqzn6sdMRm02EctZ3c/TDcKp3BheWxvYWTESpcCB8QgRqSCJYNPNZpSJdLrBtTxP+Ecsg3gRfV2QcAVT4EA+jrEIC51ewx6VipNATlRp7hXSkJBVkObe7jOqFNep6HwZIaAAgHCo3NpZ8RA0JiwMzC/KJmh0kZ6EKAhWwVNV3nVaViklUNZOHj7ER4//G/CwEIJDNc+rzw8CSe5Bfyu5Wa9Y1kiVJz2wQUBB6hzaWdfdHlwZSCkaGFzaIKkdHlwZQildmFsdWXEIO7cxNT/Bgx3n9SCKx1vVAV49PWWc48WLP90rMI/jI5Xo3RhZ80CAqd2ZXJzaW9uAQ==
@dhfromkorea
dhfromkorea / fix_drafts_deployment.rb
Created July 6, 2019 05:42
A quick fix for Octopress 2 that prevents drafts from being deployed. Preview still possible.
desc "Default deploy task"
task :deploy do
# Check if preview posts exist, which should not be published
if File.exists?(".preview-mode")
puts "## Found posts in preview mode, regenerating files ..."
File.delete(".preview-mode")
Rake::Task[:generate].execute
end
Rake::Task[:copydot].invoke(source_dir, public_dir)
@dhfromkorea
dhfromkorea / keyword.py
Created September 11, 2017 19:55
keyword example
# this model is the most naive one
# find the occurences of the keywords listed and consider them to be matched.
# TODO will be to apply a Bag of Words model or some sort and assign credit score
# read raw caption files
caption_data, metadata = next(load_caption_files(path_to_caption_file))
# combine captions by 10 seconds (i.e. make time blocks)
X = split_caption_to_X(caption_data)
keywords = ['caption', 'type=story', 'type=commercial']
@dhfromkorea
dhfromkorea / example.py
Last active September 11, 2017 19:48
audiofingerprinting example
fp = FingerPrint(path_to_dejavu_config_file)
timestamp_pb = 20000 # program boundary timestamp in secs from
PAD = 10 # temporal padding to apply to the timestamp
# slice an audio segement off the video
fp.slice_audio_segment(path_to_full_video_or_audio, pb - PAD, pb + PAD, "mp4")
# extract the fingerprint of the segment and save it to db
# db's configured in the .config file
# the path for the full video/audio and the segment may be different
@dhfromkorea
dhfromkorea / fizzbuzz.js
Created August 3, 2015 18:27
fizzbuzz.js
var fizzbuzz = function(n){
var answer = '';
if (n % 3 === 0) {
answer = 'Fizz';
}
if (n % 5 === 0) {
answer += 'Buzz';
}
if (!answer){
answer = n;
@dhfromkorea
dhfromkorea / memoized_fibonacci.js
Created August 3, 2015 18:12
memoized_fibonacci
var fibonacci = function(){
var _cache = [];
var fib = function(i){
if (i < 0) {
console.err('invalid input. i must be >= 0');
return;
}
if (i < 2) {
_cache[i] = i;
@dhfromkorea
dhfromkorea / phase_portrait.R
Created August 1, 2015 20:38
plotting a phase portrait of non-linear autonomous ODE's using phaseR
if (!require(phaseR)){
install.packages('phaseR')
require(phaseR)
}
# a system of two non-linear autonomous ODE's
ode = function (t, y, parameters) {
x <- y[1]
y <- y[2]
dy <- numeric(2)
@dhfromkorea
dhfromkorea / filename_fetcher
Last active August 29, 2015 14:07
fetch all the links of files of a certain extension in a webpage.
// by default, it fetches pdf
// change pdf to an extension you want
var pdflinks = [];
Array.prototype.map.call(document.querySelectorAll("a[href$=\".pdf\"]"), function(e, i) {
if ((pdflinks || []).indexOf(e.href) == -1) {
pdflinks.push(e.href);
}
});
console.log(pdflinks.join(" "));
// copy the logged file names
<Response>
<Dial callerId="16501112222" dialMusic="real">
<Number>15556667777</Number>
</Dial>
</Response>