Skip to content

Instantly share code, notes, and snippets.

@kopiro
kopiro / serializer.js
Created January 18, 2017 12:06
Serialize data objects in URI
function deserializeObjectInURI(obj) {
return obj.map(function(value, key) {
return [ key, (_.isArray(value) ? value.join(',') : value) ].join('=');
}).join('&');
}
function serializeObjectInURI(str) {
try {
// Retrocomp
@kopiro
kopiro / neftojpg.sh
Created January 5, 2017 13:55
NEF to JPG (parallel)
#!/bin/bash
mkdir -p JPG
find . -name "*.NEF" -print0 | xargs -0 -P 4 -I file sips -s format jpeg file --out JPG/file.jpg
@kopiro
kopiro / sdkinstall.sh
Created November 3, 2016 09:00
Install Titanium GA SDK
#!/bin/bash
# Usage sdkinstall "5.5.0 5.5.1"
rm -rf /tmp/tisdk
mkdir -p /tmp/tisdk
function install_sdk() {
if [ -d ~/Library/Application\ Support/Titanium/mobilesdk/osx/$2 ]; then
echo "Titanium SDK $2 already installed!"
var RomanNumerals = {
fromRoman: function(roman) {
var map = {IV:4,IX:9,XL:40,XC:90,CD:400,CM:900,I:1,V:5,X:10,L:50,C:100,D:500,M:1000};
var value = 0;
for (var i = 0; i < roman.length; i++) {
var two = map[roman[i]+roman[i+1]], one = map[roman[i]];
if (two != null) { value += two; i++; }
else if (one != null) value += one;
}
return value;
/*
Solution of: https://www.codewars.com/kata/545434090294935e7d0010ab
*/
var query = function () {
var self = {};
var tables = [];
var selector = null;
@kopiro
kopiro / fix.sh
Created August 3, 2016 10:42
Solve `/dev/tty/ bug in Tower / GIT UI when signing commits with GPG
echo 'no-tty' >> ~/.gnupg/gpg.conf
@kopiro
kopiro / browser-os-detect.js
Created August 2, 2016 14:42
Browser/OS detection
var IS_IOS = /iphone|ipad|ipod/i.test(navigator.userAgent);
var IS_IEMOBILE = /iemobile/i.test(navigator.userAgent);
var IS_ANDROID = /android/i.test(navigator.userAgent);
var IS_IE = /msie/i.test(navigator.userAgent);
var IS_TOUCH_DEVICE = (function() {
var el = document.createElement('div');
el.setAttribute('ongesturestart', 'return;');
return typeof el.ongesturestart === "function";
})();
@kopiro
kopiro / openssl-yosemite-curl-fix.md
Created August 1, 2016 13:54
OpenSSL Yosemite problem
@kopiro
kopiro / mysql2sqlite.sh
Created July 12, 2016 07:50 — forked from esperlu/mysql2sqlite.sh
MySQL to Sqlite converter
#!/bin/sh
# Converts a mysqldump file into a Sqlite 3 compatible file. It also extracts the MySQL `KEY xxxxx` from the
# CREATE block and create them in separate commands _after_ all the INSERTs.
# Awk is choosen because it's fast and portable. You can use gawk, original awk or even the lightning fast mawk.
# The mysqldump file is traversed only once.
# Usage: $ ./mysql2sqlite mysqldump-opts db-name | sqlite3 database.sqlite
# Example: $ ./mysql2sqlite --no-data -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
@kopiro
kopiro / messenger-soccer.cy
Last active July 25, 2016 12:55
Hack Facebook Messnger iOS Soccer Game
@import com.saurik.substrate.MS;
var _setScore_pointer = {};
MS.hookMessage(MNSoccerGame, @selector(_setScore:), function(arg0) {
return _setScore_pointer->call(this, 9009);
}, _setScore_pointer);