Skip to content

Instantly share code, notes, and snippets.

@tinkertrain
tinkertrain / fibonacci.js
Last active August 9, 2018 08:58
Even Fibonacci Numbers
/** 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 August 3, 2018 01:40
Flatten an array of arbitrarily nested arrays of integers into a flat array of integers
/**
* 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 February 1, 2017 21:17
Hyper settings
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)',
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 19:11
Autoclose back-ticks for SublimeText
// 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 October 28, 2013 16:07
Add spaces to dock MacOSX
defaults write com.apple.dock persistent-apps -array-add '{"tile-type"="spacer-tile";}'
killall Dock
@tinkertrain
tinkertrain / usa_states.html
Created October 16, 2013 19:30
USA states select
<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>
@tinkertrain
tinkertrain / Flexing-pagination-arrows.markdown
Created September 9, 2013 19:59
A Pen by Hakim El Hattab.
@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 August 6, 2013 14:50
Prevent flicker in webkit
body{
-webkit-backface-visibility: hidden;
-webkit-transform:translate3d(0,0,0);
}