Skip to content

Instantly share code, notes, and snippets.

View marktellez's full-sized avatar

Mark Tellez marktellez

View GitHub Profile
@marktellez
marktellez / flatten.js
Created November 7, 2016 19:50
Flattening an array is easy if you know recursion and map/reduce!
// 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))
@marktellez
marktellez / gist:0ebc9714ed44df60633cc8c12c6f2461
Created November 7, 2016 20:05
Flattening an array in ruby is easy too! Your friend again is splat and recursion
# 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

JavaScript

Intro to coding

  1. Basic code structure
  2. Control Flow
  3. Storing and retrieving values
  4. Data types
  5. Arrays
@marktellez
marktellez / mining-script.md
Created March 2, 2018 15:59
Breaking down the mining process to automate it
  1. Start Ubuntu
  2. 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
{
"product": {
"regions": [
{
"vendor-ids": [
2098
],
"subcategories": [
{
"attributes": [
@marktellez
marktellez / readme.md
Last active May 27, 2018 22:16
Installing a new Miner - Instructions

Installing a new Miner - Instructions

Steps

Install Ubuntu 17.04

Update Ubuntu

  1. sudo apt-get update
  2. sudo apt-get upgrade
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 => {
@marktellez
marktellez / 20-habits-wealthy-traders.md
Last active July 4, 2018 21:39
TRADING: 20 Habits of Wealthy Traders
  1. Wealthy Traders are patient with their winning trades and enormously impatient with their losing trades
  2. Wealthy Traders realize quickly that making money is more important than being right
  3. Wealthy Traders look at charts and see where other traders are lining up to buy and sell
  4. Before Wealthy Traders enter a trade, they know exactly where they will exit for a gain or loss
  5. Wealthy Traders approach trade number 5 with the exact same mindset they did on the 4 preious losing trades
  6. Wealthy Traders use naked charts and focus on trading zones
  7. Wealthy Traders realized a long time ago that being uncomfortable while trading is ok
  8. Wealthy Traders know that their workplace is the market - they are a participant not an onlooker
  9. Wealthy Traders stopped trying to picks tops and bottoms
  10. Wealthy Traders stopped thinking about the market being cheap or expensive
@marktellez
marktellez / mp3player.js
Last active July 16, 2018 15:57 — forked from TooTallNate/mp3player.js
node.js command line MP3 player in 9 lines of code!
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))
})

// Esta es tu tarea para el miércoles 18