Skip to content

Instantly share code, notes, and snippets.

View silas's full-sized avatar

Silas Sewell silas

View GitHub Profile
@longcao
longcao / SparkCopyPostgres.scala
Last active September 11, 2024 18:55
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 = {
@silas
silas / README.md
Created September 15, 2014 16:11
Install dotfiles

Clone private

git clone [email protected]:silas/dotfiles.git dotfiles.git

Or public repository

git clone https://github.com/silas/dotfiles.git dotfiles.git
@tadast
tadast / countries_codes_and_coordinates.csv
Last active June 19, 2025 15:16
Countries with their (ISO 3166-1) Alpha-2 code, Alpha-3 code, UN M49, average latitude and longitude coordinates
Country Alpha-2 code Alpha-3 code Numeric code Latitude (average) Longitude (average)
Afghanistan AF AFG 4 33 65
Åland Islands AX ALA 248 60.116667 19.9
Albania AL ALB 8 41 20
Algeria DZ DZA 12 28 3
American Samoa AS ASM 16 -14.3333 -170
Andorra AD AND 20 42.5 1.6
Angola AO AGO 24 -12.5 18.5
Anguilla AI AIA 660 18.25 -63.1667
Antarctica AQ ATA 10 -90 0
@kujohn
kujohn / portforwarding.md
Last active June 5, 2025 22:43
Port forwarding in Mavericks

Port Forwarding in Mavericks


Since Mavericks stopped using the deprecated ipfw (as of Mountain Lion), we'll be using pf to allow port forwarding.

####1. anchor file Create an anchor file under /etc/pf.anchors/<anchor file> with your redirection rule like:

@noamtm
noamtm / OrderedYAML.py
Created November 7, 2012 10:53 — forked from enaeseth/yaml_ordered_dict.py
Load YAML mappings as ordered dictionaries
import yaml
import yaml.constructor
def load(data):
try:
# included in standard lib from Python 2.7
from collections import OrderedDict
except ImportError:
# try importing the backported drop-in replacement
@indexzero
indexzero / round-robin-proxy.js
Created March 14, 2011 20:15
A simple example of how to do round-robin proxying for a single domain
var httpProxy = require('http-proxy');
//
// Addresses to use in the round robin proxy
//
var addresses = [
{
host: 'ws1.0.0.0',
port: 80
},
@tritonrc
tritonrc / ldap_admin.rb
Created January 17, 2011 19:55
Simple Sinatra based LDAP admin tool
require 'rubygems'
require 'sinatra'
require 'net-ldap'
require 'digest/sha1'
require 'base64'
require 'haml'
LDAP_HOST = 'localhost'
ADMIN_DN = 'cn=admin,dc=company,dc=com'
@silas
silas / xe-host-backup
Created September 14, 2010 20:18
Live XCP host backups
#!/usr/bin/env bash
DST_PATH="${DST_PATH:-/tmp}"
backup() {
uuid="$1"
label_name=$( xe vm-list uuid="$uuid" | grep 'name-label' | cut -b 24- )
snapshot_uuid=$( xe vm-snapshot vm="$uuid" new-name-label=backup_vm )
xe template-param-set is-a-template=false ha-always-run=false uuid="$snapshot_uuid"