Skip to content

Instantly share code, notes, and snippets.

Avatar

Juan Pablo Lomeli Diaz tinkertrain

View GitHub Profile
@tinkertrain
tinkertrain / fibonacci.js
Last active Aug 9, 2018
Even Fibonacci Numbers
View fibonacci.js
/** Class to produce Fibonacci series and actions on them */
class Fibonacci {
/**
* Initialize the arrays to store the Fibonacci series
* complete: All the values that have been calculated across uses
* current: The current list of values
*/
constructor() {
this.series = {
complete: [],
@tinkertrain
tinkertrain / flattenArray.js
Created Aug 3, 2018
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
View flattenArray.js
/**
* Function that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers
* @param arr The array to flatten
* @param removeNonItems A flag to remove `undefined` and `null` values if set to true
*
* @returns Array
*/
function flatten(arr, removeNonItems = false) {
var nested = false;
@tinkertrain
tinkertrain / .hyper.js
Last active Feb 1, 2017
Hyper settings
View .hyper.js
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 13,
// font family with optional fallbacks
fontFamily: '"Meslo LG L DZ", Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.8)',
View flattenArray.js
import { isArray } from './utils';
export default function flattenArray(arr) {
// Use Array.reduce to get our result
let flattened = arr.reduce(function(current, item) {
// Store a reference to the current item
let temp = item;
// Check if the item is an array
@tinkertrain
tinkertrain / back-ticks.json
Created May 14, 2015
Autoclose back-ticks for SublimeText
View back-ticks.json
// Add this to your user keybindings file
{ "keys": ["`"], "command": "insert_snippet", "args": {"contents": "`$0`"}, "context":
[
{ "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|$)", "match_all": true },
{ "key": "preceding_text", "operator": "not_regex_contains", "operand": "[`a-zA-Z0-9`]$", "match_all": true },
{ "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.backtick", "match_all": true }
]
},
@tinkertrain
tinkertrain / add_spaces.txt
Created Oct 28, 2013
Add spaces to dock MacOSX
View add_spaces.txt
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
View usa_states.html
<select name="State">
<option value="" selected="selected">Select a State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
<option value="AZ">Arizona</option>
<option value="AR">Arkansas</option>
<option value="CA">California</option>
<option value="CO">Colorado</option>
<option value="CT">Connecticut</option>
<option value="DE">Delaware</option>
View offset.scss
@mixin _position($position, $args) {
$offsets: top right bottom left;
@each $o in $offsets {
$i: index($args, $o);
@if $i
and $i + 1 <= length($args)
and type-of( nth($args, $i + 1) ) == number {
#{$o}: nth($args, $i + 1);
}
@tinkertrain
tinkertrain / flicker.css
Created Aug 6, 2013
Prevent flicker in webkit
View flicker.css
body{
-webkit-backface-visibility: hidden;
-webkit-transform:translate3d(0,0,0);
}
You can’t perform that action at this time.