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.
| /** | |
| * 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(); |
| #!/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)) |
| 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) { |
| import mechanize | |
| import cookielib | |
| import urlparse | |
| import re | |
| import time | |
| import random | |
| import csv | |
| import pandas as pd | |
| import pickle | |
| import random |
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.
| 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]]]]])) |
| "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, |
| 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); | |
| }) |
| // These window.navigator contain language information | |
| // 1. languages -> Array of preferred languages (eg ["en-US", "zh-CN", "ja-JP"]) Firefox^32, Chrome^32 | |
| // 2. language -> Preferred language as String (eg "en-US") Firefox^5, IE^11, Safari, | |
| // Chrome sends Browser UI language | |
| // 3. browserLanguage -> UI Language of IE | |
| // 4. userLanguage -> Language of Windows Regional Options | |
| // 5. systemLanguage -> UI Language of Windows | |
| var browserLanguagePropertyKeys = ['languages', 'language', 'browserLanguage', 'userLanguage', 'systemLanguage']; |
| /* | |
| A script to generate a Google BigQuery-complient JSON-schema from a JSON object. | |
| Make sure the JSON object is complete before generating, null values will be skipped. | |
| References: | |
| https://cloud.google.com/bigquery/docs/data | |
| https://cloud.google.com/bigquery/docs/personsDataSchema.json | |
| https://gist.github.com/igrigorik/83334277835625916cd6 | |
| ... and a couple of visits to StackOverflow |