Skip to content

Instantly share code, notes, and snippets.

@retrography
retrography / json2csv.R
Last active February 26, 2021 23:09
JSON to CSV convertor. Uses `jsonlite` R package, flattens all the hierarchical structure and converts all remaining lists/arrays into strings.
#!/usr/bin/Rscript
if (!require(jsonlite, quietly = TRUE, warn.conflicts = FALSE)) {
stop("This program requires the `jsonlite` package. Please install it by running `install.packages('jsonlite')` in R and then try again.")
}
args <- commandArgs(trailingOnly = TRUE)
if (length(args) == 0) {
input <- readLines(file("stdin"))
@bsweger
bsweger / useful_pandas_snippets.md
Last active April 19, 2024 18:04
Useful Pandas Snippets

Useful Pandas Snippets

A personal diary of DataFrame munging over the years.

Data Types and Conversion

Convert Series datatype to numeric (will error if column has non-numeric values)
(h/t @makmanalp)

/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@janosgyerik
janosgyerik / download-coursera-lecture-notes.bash
Created October 8, 2013 18:51
Recipe to download all lecture notes of a course on Coursera
# requirements: python, virtualenv, pip
#
# create a virtualenv -- I keep all my virtualenvs in ~/virtualenv
virtualenv --distribute ~/virtualenv/coursera
# activate virtualenv
. ~/virtualenv/coursera/bin/activate
# get the coursera downloader tool and install requirements
@endolith
endolith / export_google_starred_locations.py
Created October 16, 2012 02:29
Export Google Maps starred locations
# -*- coding: utf-8 -*-
"""
Go to Google Bookmarks: https://www.google.com/bookmarks/
On the bottom left, click "Export bookmarks": https://www.google.com/bookmarks/bookmarks.html?hl=en
After downloading the html file, run this script on it to generate a KML.
"""
@bobes
bobes / ril_to_instapaper.rb
Created April 13, 2011 06:18
Import your ReadItLater bookmarks into Instapaper
#!/usr/bin/env ruby
# 1. export your RIL bookmarks
# 2. save this file to the same directory where your ril_export.html is
# 3. change username and password in the script bellow
# 4. run 'ruby ril_to_instapaper.rb' in terminal
require "cgi"
require "net/http"
require "net/https"