Skip to content

Instantly share code, notes, and snippets.

View betacar's full-sized avatar
🤓
Tidsoptimist

Carlos Betancourt Carrero betacar

🤓
Tidsoptimist
View GitHub Profile
@betacar
betacar / index.html
Last active April 19, 2019 23:14
Arra#includes vs. Set#has #jsbench #jsperf (http://jsbench.github.io/#c5729bf11396f9577e90fa42964e13ea) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Arra#includes vs. Set#has #jsbench #jsperf</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>

Keybase proof

I hereby claim:

  • I am betacar on github.
  • I am betacar (https://keybase.io/betacar) on keybase.
  • I have a public key ASDzsG0GgvjrU1LKiEDdpVDZyi_KDJBQ3seYAM1Rmrfy1Qo

To claim this, I am signing this object:

@betacar
betacar / vue-feathers.js
Last active November 7, 2017 15:49
NuxtJS plugin to integrate FeathersJS and VueJS
'use strict';
import Vue from 'vue';
import Feathers from 'feathers/client';
import VueFeathers from 'vue-feathers';
import hooks from 'feathers-hooks';
import authentication from 'feathers-authentication/client';
// import rest from 'feathers-rest/client';
import rx from 'feathers-reactive';
import RxJS from 'rxjs';
@betacar
betacar / binary-search.rb
Created February 11, 2017 20:29
Algorithms
require 'benchmark'
Benchmark.bm do |bm|
def binary_search arr, target
med = (arr.length / 2).to_i
return false if med == 1
val = arr[med]
return true if val == target
@betacar
betacar / index.html
Created December 19, 2016 16:15
Date.now() vs. +new Date() (http://jsbench.github.io/#45f153b0c2561bb337ea1a088262b5d7) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>Date.now() vs. +new Date()</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@betacar
betacar / index.html
Created December 9, 2016 19:39
String concatenation vs. interpolation (http://jsbench.github.io/#70dcc32e344391ba889afbec96fb99e0) #jsbench #jsperf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<title>String concatenation vs. interpolation</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/benchmark/1.0.0/benchmark.min.js"></script>
<script src="./suite.js"></script>
</head>
<body>
<h1>Open the console to view the results</h1>
@betacar
betacar / image-to-base64.js
Last active February 11, 2016 20:29
Transform images to base64 strings
const fs = require('fs');
const regex = /(\.|\/)(gif|jpe?g|png|txt)$/i;
const dir = './';
const encoding = 'base64';
fs.readdir(dir, (err, files) => {
if (err) return err;
files.forEach((file) => {
// Skip current file
@betacar
betacar / console-coffee.sublime-snippet
Created July 26, 2015 14:26
Sublime Text snippets
<snippet>
<content><![CDATA[
console.log '######################################################################'
console.log '$1', $2
console.log '######################################################################'
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>console</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.coffee</scope>
@betacar
betacar / package-control-settings.json
Last active August 29, 2015 14:25
Sublime Text Settings
{
"in_process_packages": [],
"installed_packages": [
"Alignment",
"Better CoffeeScript",
"Better RSpec",
"CoffeeCompile",
"Emmet",
"GitGutter",
"HTML Mustache",
@betacar
betacar / collatz_conjecture.js
Last active August 29, 2015 14:21
Famous math problems
var collatz = function(n) {
var result;
console.log(n);
result = n % 2 == 0 ? n/2 : 3 * (n + 1);
return collatz(result);
};