Skip to content

Instantly share code, notes, and snippets.

@jorinvo
jorinvo / bubble.html
Created September 1, 2013 11:29
some bubble fun
<title>some bubble fun</title>
<style>
body {
font-family: Arial;
padding-top: 10%; padding-left: 30%;
}
var IncomingForm = require('formidable');
var util = require('util');
var EventEmitter = require('events').EventEmitter;
var GridStore = require('mongodb').GridStore;
var pauseStream = require('pause-stream');
var ObjectID = require('mongodb').ObjectID;
function IncomingFormGridFS(options) {
if(!(this instanceof IncomingFormGridFS)) return new IncomingFormGridFS(options);
@jorinvo
jorinvo / code.js
Last active December 22, 2015 04:38
Some refactoring. What is nicer?
var passport = require('passport');
var BasicStrategy = require('passport-http').BasicStrategy;
var config = require('./config');
passport.use(new BasicStrategy(function(user, pass, done) {
if (user !== config.auth.user) {
return done(null, false, {
message: 'Unknown user ' + user
});
}
@jorinvo
jorinvo / stringFun.js
Last active January 4, 2016 04:08
some string fun
function alphabetSoup(str) {
return str.split(' ').map(function(word) {
var parts = word.substr(1,word.length-2).split('')
.sort(function(){ return Math.random(); })
.join('');
return word[0] + parts + word[word.length-1];
}).join(' ');
}
function rollercaster(str) {
@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: