Skip to content

Instantly share code, notes, and snippets.

View ChrisVilches's full-sized avatar

Chris Vilches ChrisVilches

View GitHub Profile
@ChrisVilches
ChrisVilches / npm-run-gruntless.md
Last active July 4, 2017 12:43
Sails.js v1.0: npm run gruntless (lift app without grunt)

I have a heavy grunt setup, so when I'm only working on the backend, I run the app with this command

npm run gruntless

Here's how to make it:

app.js

@ChrisVilches
ChrisVilches / javascript_number_dot_formatting.js
Last active September 8, 2017 06:14
Javascript number formatting 12345 → 12.345
function dots(number, separator = '.') {
return number.toString().replace(/\B(?=(\d{3})+(?!\d))/g, separator);
}
// Positive tests
console.assert(dots(0) === "0");
console.assert(dots(1) === "1");
console.assert(dots(12) === "12");
console.assert(dots(123) === "123");
@ChrisVilches
ChrisVilches / adn_subcadena.js
Last active September 15, 2017 02:07
Detectar subcadenas de ADN en O(n)
/*
* Dada una cadena de ADN (ej: GATACGATCGTACGAT) detectar en tiempo O(n) si una subcadena (ej: GACA) esta contenida.
*
*/
valores = {
A: 1,
C: 2,
G: 3,
T: 4
@ChrisVilches
ChrisVilches / algoritmos_conjuntos_ruby.rb
Last active October 4, 2017 17:54
Dos funciones en Ruby, una para comprimir rangos y otra para diferencia de rangos (o conjuntos).
require 'test/unit'
extend Test::Unit::Assertions
# Comprimir rangos
# [1,2,3,7,8,9,10] => [[1,3], [7,10]]
# Diferencia de rangos
# Se tienen dos listas que se restan A - B
# A = [[1, 100], [200, 500]] esto significa que hay dos rangos 1→100 y 200→500
# B = [[50, 70], [150, 300]] representa lo mismo que lo anterior
@ChrisVilches
ChrisVilches / plugins.md
Created December 4, 2017 10:29
(MO) Especificacion publicacion de plugins y metadatos

Especificaciones de publicacion de plugins

Instrucciones

  1. Tener el codigo en Github
  2. Ir a la pestana releases de Github
  3. Rellenar el formulario y arrastrar un archivo donde dice Attach binaries by dropping them here. (se explica a continuacion que debe contener el archivo)

Archivo a subir

@ChrisVilches
ChrisVilches / twitch_dark.md
Created August 20, 2018 00:54
Twitch - Use the dark theme without an account

Open console.

localStorage.setItem("twilight.theme", 1);

Reload.

@ChrisVilches
ChrisVilches / paragraphs.js
Created August 23, 2018 20:55
Converts a multiline string into a <p>...</p> separated string for HTML use.
function toParagraphs(string){
return string.split(/[\r?\n]+/g)
.map(p => p.trim())
.filter(p => p.length > 0)
.map(p => `<p>${p}</p>`)
.join("");
}
// Tests
@ChrisVilches
ChrisVilches / animated_number_WIP
Created August 27, 2018 19:17
React Component - Animated Number (WIP)
https://codesandbox.io/s/o5r159mpkq
@ChrisVilches
ChrisVilches / mednafen-console-gui.js
Last active October 23, 2018 02:31
Mednafen Console GUI
const fs = require("fs");
const path = require ("path");
const readline = require('readline');
const { spawn } = require('child_process');
let ROMS_FOLDER = "C:/Users/.../PSX";
let MEDNAFEN_HOME = "C:/Users/.../Mednafen";
// Initialize the line reader
const rl = readline.createInterface({
// normalizeTitle :: String -> String
const normalizeTitle = rawTitle => {
const parts = rawTitle.split(" - ");
const right = parts[1].toLowerCase().replace(/\s/g, "_").replace(/[^a-z_0-9]+/g, "");
return `${parts[0]}-${right}`;
}
const rawTitle = document.getElementById("problem-name").innerHTML;