- Basic code structure
- Control Flow
- Storing and retrieving values
- Data types
- Arrays
This file contains hidden or 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
// I prefer NOT to monkey-patch, also you can't do lazy operations | |
// if we stick this on the array prototype! | |
function flatten (arr, depth=Infinity) { | |
if (depth === 0) return arr | |
return arr.reduce( (acc, v) => { | |
// normally I would ternary something like this, but the spread operator | |
// prevents it :) | |
if (Array.isArray(v)) { | |
acc.push(...flatten(v, depth-1)) |
This file contains hidden or 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
# I dont like to monkey-patch, so I dont add this to Array | |
# also, this method allows for lazy eval, something you cant | |
# do if you bind this to an array! | |
def flatten(arr, depth=Float::INFINITY) | |
return arr if depth.zero? | |
return arr.reduce([]) do |acc, v| | |
if v.kind_of?(Array) | |
acc.push(*flatten(v, depth-1)) | |
else | |
acc.push v |
- Start Ubuntu
- Set headless mode
# Start X as a background process and set the default screen to 0
X :0 &
# Export the default display
export DISPLAY=:0
# Sleep for 3 seconds to allow X to start
sleep 3
This file contains hidden or 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
{ | |
"product": { | |
"regions": [ | |
{ | |
"vendor-ids": [ | |
2098 | |
], | |
"subcategories": [ | |
{ | |
"attributes": [ |
This file contains hidden or 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
require('es6-promise').polyfill() | |
require('isomorphic-fetch') | |
// get listings - https://api.coinmarketcap.com/v2/listings/ | |
// get ticker - https://api.coinmarketcap.com/v2/ticker/1 | |
function getAssets(symbols) { | |
return fetch('//api.coinmarketcap.com/v2/listings/') | |
.then(resp => resp.json()) | |
.then(json => { |
- Wealthy Traders are patient with their winning trades and enormously impatient with their losing trades
- Wealthy Traders realize quickly that making money is more important than being right
- Wealthy Traders look at charts and see where other traders are lining up to buy and sell
- Before Wealthy Traders enter a trade, they know exactly where they will exit for a gain or loss
- Wealthy Traders approach trade number 5 with the exact same mindset they did on the 4 preious losing trades
- Wealthy Traders use naked charts and focus on trading zones
- Wealthy Traders realized a long time ago that being uncomfortable while trading is ok
- Wealthy Traders know that their workplace is the market - they are a participant not an onlooker
- Wealthy Traders stopped trying to picks tops and bottoms
- Wealthy Traders stopped thinking about the market being cheap or expensive
This file contains hidden or 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
trs = $($(".paper_trading table.balances")[2]).find(".tv-data-table__tbody tr").map((_, value) => $(value).find("td").map((_, value) => value.innerText)) | |
trades = Object.values(trs.map((_, tr) => [Object.values(tr).slice(0,5)])) | |
var toTimestamp = val => { | |
var parts = val.split(' ') | |
switch(parts[1]) { | |
case "Minutes": | |
var d = new Date(new Date().getTime() - (parts[0] * 60 * 60)) | |
break; | |
case "Hours": |
This file contains hidden or 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
var fs = require('fs') | |
var lame = require('lame') | |
var Speaker = require('speaker') | |
fs.createReadStream("./applaud.mp3").pipe(new lame.Decoder()).on('format', function (format) { | |
this.pipe(new Speaker(format)) | |
}) |
OlderNewer