Skip to content

Instantly share code, notes, and snippets.

View dipanjannag's full-sized avatar
🏠
Working from home

Dipanjan dipanjannag

🏠
Working from home
View GitHub Profile
@dipanjannag
dipanjannag / SparkCopyPostgres.scala
Created July 23, 2017 15:38 — forked from longcao/SparkCopyPostgres.scala
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 = {
@dipanjannag
dipanjannag / tcp_server.c
Created January 10, 2016 11:30
Simple socket server in C using threads (pthread library) Compiles on linux
/*
C socket server example, handles multiple clients using threads
Compile
gcc server.c -lpthread -o server
*/
#include<stdio.h>
#include<string.h> //strlen
#include<stdlib.h> //strlen
#include<sys/socket.h>