Skip to content

Instantly share code, notes, and snippets.

@thiagomata
thiagomata / file-tree.txt
Last active August 29, 2015 14:03
A workaround to be able to create the maps files into a separate file of the javascript files from the coffescript files what are into a tree structure.
project
src
coffee
foo.coffee
component
bar.coffee
animals
dog.coffee
cat.coffee
public
<?php
namespace App\Models\Traits;
use \Validator;
trait ValidateModelTrait
{
private $errors;
private $objValidator;
/**
* Based on the mysql cluster
* @link http://jonisalonen.com/2012/k-means-clustering-in-mysql/
*/
-- SELECT
-- * FROM
-- unnest(kmeans(array(SELECT
-- (
-- lat,
/*
-- EXAMPLE --
SELECT
* FROM
unnest(grid(array(SELECT
(
lat,
@thiagomata
thiagomata / sed-replace-accents-chars.sh
Last active June 28, 2016 03:47
Replace Accents Characters to Ascii in Regex Variable using Sed.
echo '{"doNotReplaceKey":"bábögêjírù","replaceValueKey":"bábögêjírù"}' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[áâàãä]/replaceValueKey":"\1a/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[éêèë]/replaceValueKey":"\1e/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[íîìï]/replaceValueKey":"\1i/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[óôòõö]/replaceValueKey":"\1o/g;ta' \
| sed -e ':a;s/replaceValueKey":"\(.*\)[úûùü]/replaceValueKey":"\1u/g;ta'
# result:
# {"doNotReplaceKey":"bábögêjírù","replaceValueKey":"babogejiru"}
@thiagomata
thiagomata / TidyPrint.Rmd
Last active February 3, 2019 03:30
Printing Properly the Output of Functions on R Markdown
# What is this?
Many R functions have a nice printable version that is accessible throw the print function.
But, when we want to get this content and using it to print inside of the HTML or PDF document, the result is not good.
This function helps to get the printable content into a varible.
## The Function
```{r tidy_print_function}
library(stringr)
@thiagomata
thiagomata / test.js
Created April 23, 2019 13:02
Playing around creating combinations from number based on dic
const exec = require('child_process').exec;
var letters = " abcdefghijklmnopqrstuvxz".split("");
var args = process.argv.slice(2);
function number_to_word(number) {
let result = "";
while (number > 0 ) {
let pos = number % letters.length;
let char = letters[ pos ];
@thiagomata
thiagomata / machine.js
Last active August 12, 2021 13:07
Generated by XState Viz: https://xstate.js.org/viz
// Invoked child machine
const counterMachine = Machine({
id: 'counter',
initial: 'active',
context:{
current: 0,
times: 0,
timesLimit: 5,