Skip to content

Instantly share code, notes, and snippets.

Avatar

Ken-ichi kueda

  • iNaturalist.org
  • Oakland, CA
View GitHub Profile
View inaturalist-oauth-pkce-flow.rb
require "rubygems"
require "rest_client"
require "digest"
require "base64"
site = "https://www.inaturalist.org"
app_id = 'YOUR_APP_ID'
redirect_uri = 'YOUR_REDIRECT_URL' # you can set this to some URL you control for testing
code_verifier = "supersecretverifier"
@kueda
kueda / .block
Last active Jan 12, 2020
CNC2017 Species in Common
View .block
height: 800
@kueda
kueda / inat-password.py
Created Jul 31, 2015
iNaturalist API Resource Owner Password Credentials Flow Example (Python)
View inat-password.py
import requests
site = "https://www.inaturalist.org"
app_id = 'YOUR APP ID'
app_secret = 'YOUR APP SECRET'
username = 'YOUR USERNAME'
password = 'YOUR PASSWORD'
# Send a POST request to /oauth/token with the username and password
payload = {
@kueda
kueda / img2pdf
Last active Jul 16, 2018
OS X bash script that turns a collection of images into an OCR'd PDF
View img2pdf
#!/bin/sh
#
# img2pdf
#
# OS X bash script that turns a collection of images into an OCR'd PDF
#
# Adapted from http://apple.stackexchange.com/questions/128384/ocr-on-pdfs-in-os-x-with-free-open-source-tools,
# where it was in turn adapted from
# http://www.morethantechnical.com/2013/11/21/creating-a-searchable-pdf-with-opensource-tools-ghostscript-hocr2pdf-and-tesseract-ocr/
# from http://www.ehow.com/how_6874571_merge-pdf-files-ghostscript.html
@kueda
kueda / esslinger.rb
Last active Jul 31, 2022
Script to parse Esslinger's A Cumulative Checklist for the Lichen-forming, Lichenicolous and Allied Fungi of the Continental United States and Canada into machine-readable CSV
View esslinger.rb
#encoding: utf-8
#
# Script to parse Esslinger's A Cumulative Checklist for the Lichen-forming,
# Lichenicolous and Allied Fungi of the Continental United States and Canada
# into machine-readable CSV.
#
# Esslinger's checklist (e.g.
# http://www.ndsu.edu/pubweb/~esslinge/chcklst/chcklst7.htm) is considered
# authoritative for North American lichens, but it's authored with MS Word and
# has incosistent formatting. This script attempts to smooth that out and
@kueda
kueda / gist:a466810f4f5495c43f67
Created Oct 14, 2014
curl request to POST and observation to iNaturalist
View gist:a466810f4f5495c43f67
> curl -H 'Authorization: Bearer MY_ACCESS_TOKEN' \
> --data "observation[species_guess]=test1" \
> --verbose \
> 'https://inaturalist.org/observations.json'
* Adding handle: conn: 0x7fe173818800
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe173818800) send_pipe: 1, recv_pipe: 0
* About to connect() to inaturalist.org port 443 (#0)
@kueda
kueda / time_zones_by_abbreviation.rb
Created Jun 20, 2014
Took me a while to figure out how to get at all the time zone abbreviations stored within the TZInfo gem. I'm sure there's a better way, but this works.
View time_zones_by_abbreviation.rb
abbrevs = {}
TZInfo::Timezone.all.each do |tz|
tz = tz.send(:real_timezone) unless tz.class == TZInfo::Timezone
tzi = tz.send(:info)
offsets = tzi.instance_variable_get(:@offsets)
next if offsets.blank?
offsets.values.each do |offset|
abbrevs[offset.abbreviation] ||= []
abbrevs[offset.abbreviation] << tz.identifier
end
@kueda
kueda / xcode_pending_translations.rb
Created May 19, 2014
Find strings that need translating in an xcode project.
View xcode_pending_translations.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'trollop'
require 'nokogiri'
require 'tmpdir'
opts = Trollop::options do
banner <<-EOS
Find strings that need translating in an xcode project.
@kueda
kueda / xibstrings.rb
Created May 19, 2014
Spit out text from a .xib or .storyboard file as it appears in xcode. Useful for diffing and working with translations.
View xibstrings.rb
#!/usr/bin/env ruby
require 'rubygems'
require 'trollop'
require 'nokogiri'
require 'tmpdir'
opts = Trollop::options do
banner <<-EOS
Spit out text from a .xib or .storyboard file as it appears in xcode. Useful
for diffing and working with translations.
@kueda
kueda / fireslurp.rb
Created May 6, 2014
Simple (too simple) script to retrieve info about social media for Nerds for Nature Monitor Change project
View fireslurp.rb
# This is a pretty dumb script that gets pics matching some tags from social
# media services and writes info about them to a local CSV file. Yes, it could
# be much better. Right now it only downloads *recent* data, not all data, so
# it's designed to run frequently. Improvements could include
# * writing to a single file, w/ de-duping
# * writing to a Google Spreadsheet
# * retrieval of all matches for Flickr and Instagram (impossible w/ Twitter)
require 'rubygems'
require 'twitter'