Skip to content

Instantly share code, notes, and snippets.

View aurbano's full-sized avatar
🎯
ML

Alejandro U. Alvarez aurbano

🎯
ML
View GitHub Profile
@aurbano
aurbano / joinArrays.js
Created July 2, 2015 14:54
Join two normalized arrays using a join table, returning a copy of the first array containing a property with an array of mapped elements of arr2
/**
* Join two normalized arrays using a join table, returning a copy of
* the first array containing a property with an array of mapped
* elements of arr2
*
* @see normalizeArrayId
*
* @param arr1 Normalized array 1
* @param arr2 Normalized array 2
* @param arrJoin Array with the joins
@aurbano
aurbano / inlineConfirm.js
Created August 7, 2015 12:36 — forked from markthiessen/inlineConfirm.js
AngularJS (+Bootstrap) directive for inline ngClick confirmation
(function () {
'use strict';
angular.module('yourModule', []).directive('inlineConfirm',
['$compile',
function ($compile) {
return {
priority: -100,
link: function (scope, elm, attrs) {
var wrapperTemplate = '<div class="popover inline-confirm" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>';
var template =
// Sift4 - extended version
// online algorithm to compute the distance between two strings in O(n)
// maxOffset is the number of positions to search for matching tokens
// options: the options for the function, allowing for customization of the scope and algorithm:
// maxDistance: the distance at which the algorithm should stop computing the value and just exit (the strings are too different anyway)
// tokenizer: a function to transform strings into vectors of tokens
// tokenMatcher: a function to determine if two tokens are matching (equal)
// matchingEvaluator: a function to determine the way a token match should be added to the local_cs. For example a fuzzy match could be implemented.
// localLengthEvaluator: a function to determine the way the local_cs value is added to the lcss. For example longer continuous substrings could be awarded.
// transpositionCostEvaluator: a function to determine the value of an individual transposition. For example longer transposi
<!DOCTYPE html>
<html><head>
<title>Obfuscated name remapper</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
body {
background: white;
color: black;
font-family: "Trebuchet MS",Helvetica,Tahoma,Arial,sans-serif;
font-size: 90.01%;
@aurbano
aurbano / regex.md
Last active October 27, 2016 14:11
Match a word preceded by specific words, but not others, and with optional appendixes

Regex

((pre1)|pre2)?(?(1)\s)(?<!notallowed )main word(?(2)-appendix1)

This will match

pre1 main word-appendix1 pre2 main word

@aurbano
aurbano / resource-path.js
Last active January 14, 2020 10:44
Standalone resource URL parser - loosely based on Angular's resource. Available as NPM package: https://github.com/aurbano/resource-path
/**
* This method is intended for encoding *key* or *value* parts of query component. We need a
* custom method because encodeURIComponent is too aggressive and encodes stuff that doesn't
* have to be encoded per http://tools.ietf.org/html/rfc3986:
* query = *( pchar / "/" / "?" )
* pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
* unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
* pct-encoded = "%" HEXDIG HEXDIG
* sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
* / "*" / "+" / "," / ";" / "="
@aurbano
aurbano / keybase.md
Created January 12, 2017 15:31
Keybase proof of identity

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@aurbano
aurbano / random.js
Created March 6, 2017 15:28
UTTT Random Player
const UTTT = require('ultimate-ttt');
/**
* Random client implementation of the UTTT Game
*/
class Random{
constructor(player, size = 3){
if(!player || !Number.isInteger(player) || player < 1 || player > 2){
throw new Error('Invalid player');
@aurbano
aurbano / Gemfile
Last active November 8, 2023 01:39
Post code coverage as a comment to a Github PR from Circle CI
source "https://rubygems.org"
gem "octokit"
gem "nokogiri"
gem "json"
@aurbano
aurbano / conversation.md
Last active September 10, 2019 23:46
Bluehost Support regarding malware

The following conversation was literally copy/pasted from Bluehost's support.

I thought it was pretty interesting how they kept trying to upsell an unnecessary "security" service for $80/month for 20 minutes...

The malware in question is a script from Coinhive (I've linked an article as the main site doesn't seem to load) which I was testing out from a security point of view. Unfortunately their security scanner picked it up quickly and suspended the account, which is expected and good.

During the chat I didn't realise this was the problem though, I later saw it when I went to remove the malware and looked at the scanner log (which said it had found SL-CRYPTOMINER-eu.UNOFFICIAL FOUND) and immediately thought of Coinhive.

Malware/Security: Site Deactivated for Malware