Skip to content

Instantly share code, notes, and snippets.

View matchilling's full-sized avatar
🎯
Focusing

Matías J. Schilling matchilling

🎯
Focusing
View GitHub Profile
@matchilling
matchilling / README-Template.md
Created November 4, 2017 01:16 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@matchilling
matchilling / flattenArray.js.js
Created June 12, 2017 10:25
flattenArray.js created by matchilling - https://repl.it/IhOJ/0
const arr = [
1, 2, 3, 4, 5, 6, [1, 2, 3, 4], [1, 2, 3, 4], [ [1, 2, [['x']], 4], [1, () => 2, 3, 4], [1, 2, {}, 4, [1, 2, 3, 4]]]
],
flatten = arr => arr.reduce((acc, val) => acc.concat(
Array.isArray(val) ? flatten(val) : val), []
);
console.log(
flatten(arr)
);
@matchilling
matchilling / Convert an ip address to long integer.php
Created May 17, 2017 11:09
Convert an ip address to long integer created by matchilling - https://repl.it/ICl2/1
function ipToInteger ($ip) {
if (empty($ip)) return 0;
$parts = explode('.', $ip);
return $parts[3] + $parts[2] * 256 + $parts[1] * 256 * 256 + $parts[0] * 256 * 256 * 256;
}
$id = '5.148.106.4';
$uk = [35149824, 93968953];
$ipNumber = ipToInteger($id);
@matchilling
matchilling / The Meaning Of Life ... in lolcode.lol
Created April 17, 2017 10:48
The Meaning Of Life ... in lolcode created by matchilling - https://repl.it/HMBo/0
HAI 1.2
I HAS A AGE ITZ 0
I HAS A ENDOFLIFE ITZ 80
IM IN YR LOOP UPPIN YR AGE TIL BOTH SAEM AGE AN ENDOFLIFE
VISIBLE "Eat, poop, sleep, laugh, observe, teach ..."
IM OUTTA YR LOOP
VISIBLE "Well done, you're now dead at an age of " AGE ". Hope you've enjoyed the experience"
KTHXBYE
@matchilling
matchilling / Convert wind direction in angles to cardinal direction.js
Created April 17, 2017 09:44
Convert wind direction in angles to cardinal direction created by matchilling - https://repl.it/HCSI/3
/**
* Convert wind direction in angles to cardinal direction
* @see https://en.wikipedia.org/wiki/Cardinal_direction
*
* @param {Number} degree
* @return {String}
*/
function degreeToCardinalDirection(degree) {
const val = Math.floor(0.5 + (degree / 22.5)),
@matchilling
matchilling / calculateWindChillFactor.js
Last active April 9, 2017 11:42
Calculate the wind chill factor created by matchilling - https://repl.it/HCIg/0
'use strict';
/**
* Calculate the wind chill factor
* @see https://www.weather.gov/media/epz/wxcalc/windChill.pdf
*
* @param {Float} temperature - temperature in Fahrenheit
* @param {Float} windSpeed - wind speed in miles per hour
* @return {Float}
*/
@matchilling
matchilling / gen_unique_image.sh
Last active October 29, 2016 12:35
This script generates an unique image with an uuid and an embedded qr code
#!/usr/bin/env sh
# -----------------------------------------------------------------------------
# This script generates an unique image with an uuid and an embedded qr code
# Usage `./gen_unique_image.sh unique_image.(jpg|jpeg|png|gif|bmp)`
# -----------------------------------------------------------------------------
readonly PACKAGE='gen_unique_image'
readonly COLOR_BACKGROUND='0F3244'
readonly COLOR_BLUE='58C0F9'
readonly COLOR_FOREGROUND='FFFFFF'
<div class="wrapper">
<div class="arrow left">&nbsp;</div>
<br />
<div class="arrow right">&nbsp;</div>
</div>
<style>
body {
padding: 0;
margin: 0;
@matchilling
matchilling / motd.sh
Last active June 22, 2016 13:41
Get the message of the day
#!/bin/bash
# ------------------------------------------------------------------------------
# Get the message of the day :)
# ------------------------------------------------------------------------------
motd=`curl --silent -H "Accept: text/plain" https://api.chucknorris.io/jokes/random 2>&1 /dev/null`
echo -e "\n\n$motd\n\n\033[0;31m¯\_(ツ)_/¯ Have a good day dude ...\033[0m\n\n";
function getJoke() {
var req = new XMLHttpRequest();
req.onreadystatechange = function() {
if (4 == req.readyState && 200 == req.status) {
var reponse = JSON.parse(req.responseText);
console.log(reponse);
}
}