This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Converts an object or array to an 1 dimensional object | |
* with dot delimited key paths as keys | |
* | |
* @param {(Object|Array)} oldObject | |
* @returns {Object} | |
*/ | |
const flat = oldObject => { | |
// This scope is just to create the new object, to avoid mutating state | |
const newObj = {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fibonacci(limit = 10) | |
limit.times.each_with_object([0,1]) do |elem, accum| | |
accum << accum[-1] + accum[-2] | |
end | |
end | |
# Examples | |
fibonacci | |
#=> [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Hotkeys (While playing): | |
# @see http://linux.die.net/man/1/ffplay | |
# q, ESC Quit | |
# f Toggle full screen | |
# p, SPC Pause | |
# a Cycle audio channel | |
# v Cycle video channel | |
# t Cycle subtitle channel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Autoplay videodirectory | |
import os, xbmc, time | |
usb_dir = "/media" # path of external media | |
delay = 10 # seconds to delay media player | |
# Collect directories (USBs) in usb directory | |
usb_list = [] | |
for fname in os.listdir(usb_dir): | |
fpath = os.path.join(usb_dir, fname) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Directory structure | |
# /path/to/project | |
# |───scss | |
# | |───library | |
# | | |───_all.scss <------- creates/updates this file | |
# | | |───_typography.scss | |
# | | |───_structure.scss | |
# | | └───_responsive.scss | |
# | |───modules | |
# | | |───_all.scss <------- and this file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# To implement extension, run this command in a shell: | |
# $ sass -i -r ./units_sass_extension.rb | |
# Or require it in compass config | |
# require './units_sass_extension' | |
module Sass::Script::Functions | |
# | |
# Strips units from a value, e.g. '10px' or '10in' becomes 10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# To implement extension, run this command in a shell: | |
# $ sass -i -r ./gcd_sass_extension.rb | |
# Or require it in compass config | |
# require './gcd_sass_extension' | |
module Sass::Script::Functions | |
# | |
# Uses the 'greatest common divisor' algorithm to work out if a fraction |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Algorithm to calculate the Lowest Common Denominator | |
@function gcd($a, $b){ | |
@if $b == 0 { | |
@return $a; | |
} @else { | |
@return gcd($b, $a%$b); | |
} | |
} | |
// Example Use-case: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Colors | |
def colorize(text, color_code) | |
"\033[#{color_code}m#{text}\033[0m" | |
end | |
{ | |
:black => 30, | |
:red => 31, | |
:green => 32, | |
:yellow => 33, |
NewerOlder