Skip to content

Instantly share code, notes, and snippets.

@ungoldman
ungoldman / curl_post_json.md
Last active April 15, 2024 14:46
post a JSON file with curl

How do you POST a JSON file with curl??

You can post a json file with curl like so:

curl -X POST -H "Content-Type: application/json" -d @FILENAME DESTINATION

so for example:

@longcao
longcao / SparkCopyPostgres.scala
Last active December 26, 2023 14:47
COPY Spark DataFrame rows to PostgreSQL (via JDBC)
import java.io.InputStream
import org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils
import org.apache.spark.sql.{ DataFrame, Row }
import org.postgresql.copy.CopyManager
import org.postgresql.core.BaseConnection
val jdbcUrl = s"jdbc:postgresql://..." // db credentials elided
val connectionProperties = {
@mlehman
mlehman / MultipleOutputsExample.scala
Last active April 11, 2022 06:54
Hadoop MultipleOutputs on Spark Example
/* Example using MultipleOutputs to write a Spark RDD to multiples files.
Based on saveAsNewAPIHadoopFile implemented in org.apache.spark.rdd.PairRDDFunctions, org.apache.hadoop.mapreduce.SparkHadoopMapReduceUtil.
val values = sc.parallelize(List(
("fruit/items", "apple"),
("vegetable/items", "broccoli"),
("fruit/items", "pear"),
("fruit/items", "peach"),
("vegetable/items", "celery"),
("vegetable/items", "spinach")
@takezoe
takezoe / JavaDateTimeSerializers.scala
Last active November 13, 2019 14:41
Java8 Date & Time API support for json4s
package org.scalatra.json
import java.time._
import java.util.{ Date, TimeZone }
import org.json4s._
import org.json4s.ext.DateParser
object JavaDateTimeSerializers {