Add a one-sentence description of this project. and a link to the live demo.
- completed feature: What this feature does
- pending feature: What this feature does
Add a one-sentence description of this project. and a link to the live demo.
| /* | |
| Sort array of objects based on another array | |
| Original function: | |
| function mapOrder (array, order, key) { | |
| array.sort( function (a, b) { | |
| var A = a[key], B = b[key]; | |
| if (order.indexOf(A) > order.indexOf(B)) { | |
| return 1; | |
| } else { |
| // Author: Renat Tuktarov (renat@sourcerer.io) | |
| const retry = function(fn, prev) { | |
| return new Promise((current, reject) => { | |
| const resolve = _ => (prev && prev()) || current(); | |
| fn(resolve, delay => { | |
| setTimeout(_ => { | |
| retry(fn, resolve); | |
| }, delay); |
| function promiseMap(xs, f) { | |
| const reducer = (ysAcc$, x) => | |
| ysAcc$.then(ysAcc => f(x).then(y => ysAcc.push(y) && ysAcc)); | |
| return xs.reduce(reducer, Promise.resolve([])); | |
| } | |
| /* Example */ | |
| const axios = require('axios'); |
| # You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine | |
| # This is how I upload my new Sol Trader builds (http://soltrader.net) | |
| # Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash | |
| S3KEY="my aws key" | |
| S3SECRET="my aws secret" # pass these in | |
| function putS3 | |
| { | |
| path=$1 |
| #!/bin/bash | |
| # | |
| # Watch current directory (recursively) for file changes, and execute | |
| # a command when a file or directory is created, modified or deleted. | |
| # | |
| # Written by: Senko Rasic <senko.rasic@dobarkod.hr> | |
| # | |
| # Requires Linux, bash and inotifywait (from inotify-tools package). | |
| # | |
| # To avoid executing the command multiple times when a sequence of |
| package main | |
| import ( | |
| "bufio" | |
| "flag" | |
| "fmt" | |
| "io" | |
| "os" | |
| "path/filepath" | |
| "regexp" |
| # open the CSV file | |
| csv_file = open(CSV_LOCATION, 'r') | |
| csv_reader = csv.reader(csv_file) | |
| values = [] | |
| for row in csv_reader: | |
| values.append(row) | |
| body = { | |
| 'values': values |
| openssl rsa -in ~/.ssh/id_rsa -outform pem > id_rsa.pem | |
| chmod 0600 id_rsa.pem |