Skip to content

Instantly share code, notes, and snippets.

View jorinvo's full-sized avatar

Jorin jorinvo

View GitHub Profile
@jorinvo
jorinvo / canvas-filter.html
Last active August 29, 2015 14:02
Demo for Basic Image Filtering Using a Canvas Element
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Demo for Basic Image Filtering Using a Canvas Element</title>
</head>
<body>
<div>
<input type="file" id="loader">
@jorinvo
jorinvo / palindrome.js
Last active August 29, 2015 14:04
Check if string is palindrome. More accurate implementation for http://www.toptal.com/javascript/interview-questions#iquestion-34
// Also handles special characters and uppercase
// like in “Amore, Roma“, “A man, a plan, a canal: Panama” or “No ‘x’ in ‘Nixon’“
// (Unfortunately doesn't fit into 80 chars)
function isPalindrome(str) {
var stripped = str.toLowerCase().replace(/[^a-z]/g, '');
return stripped === stripped.reverse();
}
@jorinvo
jorinvo / wordpress-change-url
Last active August 29, 2015 14:08
Wordpress SQL Change URL
UPDATE wp_options SET option_value = replace(option_value, 'http://www.oldurl', 'http://www.newurl') WHERE option_name = 'home' OR option_name = 'siteurl';
UPDATE wp_posts SET guid = replace(guid, 'http://www.oldurl','http://www.newurl');
UPDATE wp_posts SET post_content = replace(post_content, 'http://www.oldurl', 'http://www.newurl');
UPDATE wp_postmeta SET meta_value = replace(meta_value,'http://www.oldurl','http://www.newurl');
@jorinvo
jorinvo / gulpfile.js
Created October 31, 2014 14:59
use es6 transpiler and modules in gulp. also integrates fb-flo and caches builds
var fs = require('fs');
var path = require('path');
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var esnext = require('gulp-esnext');
var es6Modules = require('gulp-es6-module-transpiler');
var concat = require('gulp-concat');
var insert = require('gulp-insert');
var uglify = require('gulp-uglify');
var cache = require('gulp-cached');
@jorinvo
jorinvo / gulpfile.js
Created October 31, 2014 15:00
gulp browserify and livereload
var gulp = require('gulp');
var gutil = require('gulp-util');
var uglify = require('gulp-uglify');
var jshint = require('gulp-jshint');
var insert = require('gulp-insert');
var livereload = require('gulp-livereload');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var browserify = require('browserify');
@jorinvo
jorinvo / screenshot.rb
Last active August 29, 2015 14:10
creates a number of screenshots for all video files in a directory
#!/usr/bin/env ruby
# ABOUT: creates a number of screenshots for all video files in a directory
# ATTENTION: make sure to run `gem install streamio-ffmpeg`
# USAGE: converter.rb <source dir> <target dir>
require "rubygems"
require "streamio-ffmpeg"
# CONFIGURATION:
@jorinvo
jorinvo / js-graphic-designer.js
Last active August 29, 2015 14:10
API Design for js-graphic-designer
// Initialze
var designer = graphicDesigner({
// required:
element: '#container',
// optional:
unit: 'pixel' // `pixel` or `inch` or `mm`
dpi: 300, // only use with inch or mm
width: 500,
height: 500,
scaleFactor: 1,
@jorinvo
jorinvo / long.js
Last active August 29, 2015 14:10
example syntax for declarative aync testing style (answer to http://blog.oozou.com/stateful-context-working-with-multiple-values-in-a-promise-chain/)
describe('following another user', function() {
declare({
// get rid of small functions with partials
firstUser: partial(createUser, 'foo'),
secondUser: partial(createUser, 'bar')
// no need for function introspection with this syntax
// get knows strings describe dependencies and function are async
// getTimeline is a function that accepts a user as arugment now
timeline: partial(get, 'firstUser', getTimeline),
@jorinvo
jorinvo / log_stats.rb
Last active August 29, 2015 14:13
A solution for the Dev Challenge. Analyses a log file.
#!/usr/bin/env ruby
# USAGE:
# Script can be called from the command line with `./log_stats.rb`.
# Optional a log file can be specified: `./log_stats.rb path/to/file.log`.
# This function kicks off the script in case it's called from the command line
def run!
@jorinvo
jorinvo / demo.js
Last active August 29, 2015 14:14
Declare functions in order of importance
var upDown = function(name) {
return up(name) + '-' + down(name)
}
var up = function(s) {
return s.toUpperCase()
}