Skip to content

Instantly share code, notes, and snippets.

@jgimbel
jgimbel / java_gateway
Created May 13, 2015 21:02
java_gateway.lauch_gateway
def launch_gateway():
if "PYSPARK_GATEWAY_PORT" in os.environ:
gateway_port = int(os.environ["PYSPARK_GATEWAY_PORT"])
else:
SPARK_HOME = os.environ["SPARK_HOME"]
# Launch the Py4j gateway using Spark's run command so that we pick up the
# proper classpath and settings from spark-env.sh
on_windows = platform.system() == "Windows"
script = "./bin/spark-submit.cmd" if on_windows else "./bin/spark-submit"
submit_args = os.environ.get("PYSPARK_SUBMIT_ARGS", "pyspark-shell")
try{
var config = require('./config')
} catch(err){
var config = createConfig()
}
module.exports = config
let a = 0
if(true){
let a = 1
console.log(a)
}
@jgimbel
jgimbel / gist:9eade21249d800c8eb1f
Last active February 29, 2016 19:24
form-to-object.js
const formToObj = ({ elements }) => elements.reduce((prev, { name, value }) => prev[name] = value, {})
var myForm = document.querySelector('form')
myForm.addEventListener('submit', function (e) {
e.preventDefault()
fetch('/', {
method: 'post',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
const crimeArray = neighborhood.properties.crime2
console.log(crimeArray[crimeArray.length-1].violent_crime_index < crimeArray[crimeArray.length-2].violent_crime_index)
console.log(crimeArray[crimeArray.length-1].violent_crime_trend === 0)
@jgimbel
jgimbel / build_nginx.sh
Last active June 15, 2016 18:40 — forked from MattWilcox/build_nginx.sh
Fetch, build, and install the latest nginx with the latest OpenSSL for RaspberryPi
#!/usr/bin/env bash
# names of latest versions of each package
export VERSION_PCRE=pcre-8.38
export VERSION_OPENSSL=openssl-1.0.2g
export VERSION_NGINX=nginx-1.11.0
# URLs to the source directories
export SOURCE_OPENSSL=https://www.openssl.org/source/
export SOURCE_PCRE=ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
tar xzvf elm-format-0.17-0.4.0-alpha-mac-x64.tgz
cp elm-format /usr/local/bin/elm-format
rm elm-format
rm elm-format-0.17-0.4.0-alpha-mac-x64.tgz
//Groups of polygons
geosjon
.features
//get area of polygons
.map(area)
//get the average area of polygons
.reduce(
(average, value, size) => (size * average + value) / (size + 1),
0
)
<html>
<head>
<title>
Audio
</title>
</head>
<body>
<audio id="myAudio" autoplay preload="auto" class="audio--source">
var mapValues = function mapValues(obj, map) {
return Object.keys(obj).reduce(function (o, k) {
return Object.assign(o, _defineProperty({}, k, map(obj[k])));
}, {});
}