Skip to content

Instantly share code, notes, and snippets.

View zzarcon's full-sized avatar
🦍
Generating legacy code

Hector Zarco zzarcon

🦍
Generating legacy code
View GitHub Profile
{
target: "559a65636cc1ceefad000117",
traces: {
559a65636cc1ceefad000117: {
id: 1501,
sample_id: "559a65636cc1ceefad000117",
user_id: "2270751",
path: "LINESTRING (14.2936706542969 48.3098602294922, 14.2931604385376 48.3095512390137, 14.2930936813354 48.3095245361328, 14.2930459976196 48.3095054626465, 14.2929792404175 48.3094635009766, 14.2929191589355 48.3094024658203, 14.2928485870361 48.3093566894531, 14.2927770614624 48.3093185424805, 14.2926845550537 48.3093032836914, 14.292552947998 48.3092842102051, 14.2924461364746 48.3092613220215, 14.2922887802124 48.3091506958008, 14.2922258377075 48.3091011047363, 14.2921466827393 48.3090591430664, 14.2920589447021 48.309024810791, 14.2919750213623 48.3089714050293, 14.2918157577515 48.3088798522949, 14.2917490005493 48.308837890625, 14.2916784286499 48.3087921142578, 14.2914981842041 48.3087158203125, 14.2913036346436 48.3086433410644, 14.291223526001 48.3086204528809, 14.2911424636841 48.3086051940918, 14.2909755706787 48.3085632324219, 14.290885925293 48.30852
@zzarcon
zzarcon / .bash_profile.sh
Created January 8, 2016 07:16
Show the version of any npm package from command line
moduleVersion() {
str=`cat $1/package.json | grep -i '"version"'`
echo $str
}
Ember.LinkView.reopen({
willRender() {
const route = this.attrs.params[0];
let params = this.attrs.params[1];
if (params instanceof Array) {
this.attrs.params = [].concat.apply([route], params);
}
return this._super(...arguments);
{
"words": ["foo", "bar"],
"quote": "A book about $1 that talks about $2"
}
function fetchBlob(uri, callback) {
var xhr = new XMLHttpRequest();
xhr.open('GET', uri, true);
xhr.setRequestHeader("X-Mashape-Key", config.mashapeKey);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
if (this.status == 200) {
var blob = this.response;
var a = 1;
@zzarcon
zzarcon / palindrome.js
Created March 13, 2016 01:38
Palindrome one liner
function isPalindrome(str) {
return str === str.split('').reverse().join('');
}
@zzarcon
zzarcon / palindrome.cc
Created March 13, 2016 11:54
Palindrome C++
#include <nan.h>
using namespace v8;
void IsPalindrome(const FunctionCallbackInfo<Value>& info) {
String::Utf8Value sentence(info[0]->ToString());
std::string str = std::string(*sentence);
int len = str.length();
int half = len / 2;
int start = 0;
@zzarcon
zzarcon / benchmark.js
Created March 13, 2016 15:10
Palindrome benchmark
var Benchmark = require('benchmark');
var palindromeC = require('bindings')('palindrome.node');
var palindromeJs = require('./palindrome.js');
var suite = new Benchmark.Suite;
var str = 'a man a plan a cat a ham a yak a yam a hat a canal panama';
suite
.add('Javascript palindrome', function() {
palindromeJs(str);
})
@zzarcon
zzarcon / palindrome.js
Created March 13, 2016 15:28
Palindrome Javascript 2
function isPalindrome(str) {
var half = Math.round(str.length / 2);
var start = 0;
var end = str.length - 1;
var palindrome = true;
var SPACE = 32;
var COMMA = 44;
var startSpace, endSpace;
while (half && palindrome) {