Skip to content

Instantly share code, notes, and snippets.

@robfraz
robfraz / using_ssh_keys_with_github.md
Created April 4, 2018 09:30
Using SSH keys with GitHub

1. Generate an SSH key-pair

First up, generate yourself an SSH key pair - unless you already have one you can reuse, in which case skip this step.

Notes on this step:

  • Replace anything in block caps below with something meaningful - it's just a comment that gets stored with the key to help you tell what it's used for in the future.
  • It will ask you if you want to password-protect (i.e. encrypt) the private half of the key pair. If you're using a Mac, I recommend you set a password as Git integrates with the MacOS keychain really nicely. I'm not familiar with how to setup 'transparent' password-protected private keys on other operating systems, so best to just set no password unless you know what you're doing.
ssh-keygen -t rsa -b 4096 -C "YOUR_NAME github key [email protected]" -f ~/.ssh/id_rsa_github
@robfraz
robfraz / df_to_bigquery_example.py
Last active April 19, 2018 10:47
Example upload of Pandas DataFrame to Google BigQuery via temporary CSV file
from pathlib import Path
from tempfile import NamedTemporaryFile
import numpy as np
import pandas as pd
from google.cloud.bigquery import Client, SchemaField
def main():
[01:45:18][rob@Pestilence2] ~/cloudant/dbcore> cat rel/remsh
#!/bin/bash
if [ -z $NODE ]; then
if [ -z $1 ]; then
NODE=1
else
NODE=$1
fi
fi
@robfraz
robfraz / gist:5564935
Created May 12, 2013 21:08
check bulk insert
def check_bulk_insert(self, response):
# Some basic checks
assert_that(response.status_code, is_(accepted()),
"Bulk docs POST failed")
assert_that(response.json(), is_(instance_of(list)),
"Bulk docs insert didn't return a list")
# Now ensure that none of the individual document inserts had an error.
if type(response.json()) == list:
for insert_result in response.json():
import inspect
import sys
def src(obj):
"""Read the source of an object in the interpreter."""
def highlight(source):
try:
import pygments