Tested with Apache Spark 2.1.0, Python 2.7.13 and Java 1.8.0_112
For older versions of Spark and ipython, please, see also previous version of text.
| var a = ["sdfdf", "http://oooooolol"], | |
| handleNetErr = function(e) { return e }; | |
| Promise.all(fetch('sdfdsf').catch(handleNetErr), fetch('http://invalidurl').catch(handleNetErr)) | |
| .then(function(sdf, invalid) { | |
| console.log(sdf, invalid) // [Response, TypeError] | |
| }) | |
| .catch(function(err) { | |
| console.log(err); | |
| }) |
| "use strict"; | |
| var fs= require('fs'); | |
| var Promise = require('bluebird'); | |
| var parse= Promise.promisify(require('csv-parse')); | |
| var file = fs.readFileSync('test.csv', 'utf8'); | |
| var headerKeys; | |
| var options ={ | |
| trim: true, |
| const flattenTco = ([first, ...rest], accumulator) => | |
| (first === undefined) | |
| ? accumulator | |
| : (Array.isArray(first)) | |
| ? flattenTco([...first, ...rest]) | |
| : flattenTco(rest, accumulator.concat(first)) | |
| const flatten = (n) => flattenTco(n, []); | |
| console.log(flatten([[1,[2,[[3]]]],4,[5,[[[6]]]]])) |
Tested with Apache Spark 2.1.0, Python 2.7.13 and Java 1.8.0_112
For older versions of Spark and ipython, please, see also previous version of text.
| import mechanize | |
| import cookielib | |
| import urlparse | |
| import re | |
| import time | |
| import random | |
| import csv | |
| import pandas as pd | |
| import pickle | |
| import random |
| var useOldDownloadWay = false; | |
| var Nightmare = require('nightmare'); | |
| new Nightmare() | |
| .goto('http://eprint.iacr.org/2004/152') | |
| .evaluate(function ev(old){ | |
| var el = document.querySelector("[href*='.pdf']"); | |
| var xhr = new XMLHttpRequest(); | |
| xhr.open("GET", el.href, false); | |
| if (old) { |
| #!/usr/bin/env bash | |
| # Check we've got command line arguments | |
| if [ -z "$*" ] ; then | |
| echo "Need to specify ssh options" | |
| exit 1 | |
| fi | |
| # Start trying and retrying | |
| ((count = 100)) |
| /** | |
| * Retrieves all the rows in the active spreadsheet that contain data and logs the | |
| * values for each row. | |
| * For more information on using the Spreadsheet API, see | |
| * https://developers.google.com/apps-script/service_spreadsheet | |
| */ | |
| function readRows() { | |
| var sheet = SpreadsheetApp.getActiveSheet(); | |
| var rows = sheet.getDataRange(); | |
| var numRows = rows.getNumRows(); |
Magic words:
psql -U postgresSome interesting flags (to see all, use -h or --help depending on your psql version):
-E: will describe the underlaying queries of the \ commands (cool for learning!)-l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)| git branch -m old_branch new_branch # Rename branch locally | |
| git push origin :old_branch # Delete the old branch | |
| git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote |