21. October 2019

Uploading and sorting photos from android over sftp using termux.

I was super excited to find that I can install bash on my phone, then scp and ruby. It opens up a lot of possibility of what a phone should really be able to do. Too often I feel constrained by limited options in apps.

An example of this is taking old photos and putting them into my long term storage on my home computer. I backup to google photos, but I like to keep a local copy too. My old workflow for organizing files was to either use usb or “andftp” app on my android to get the files onto my machine, then sort them roughly by date into folders for ease of retrieval. Both of these methods are time consuming and don’t give the best result.

Here is my new work flow…

userhost = 'someguy@'
destpath = '/mnt/big/camera'

['PIC', 'VID'].each do |type|

def transfer_files(type)
  fs = ` ls storage/dcim/camera/#{t}* `.split("\n")

  prefixess = fs.map {|f| f.gsub(/.+#{t}_/, '').gsub(/_.+/,'')}.uniq

  years = prefixes.map{|p| p.slice(0,4)}.uniq

  prefixes.each do |p|

def handle_date_prefix(p)
  year = p.slice(0,4)

  mth = p.slice(4,2)
  day = p.slice(6,2)

  prefs.each do |p|
    transfer(year, mth, day)

def transfer(year, mth, day)
 `ssh #{userhost} "mkdir #{destpath}/#{year}" `
 `ssh #{userhost} "mkdir #{destpath}/#{year}/#{mth}" `
 `ssh #{userhost} "mkdir #{destpath}/#{year}/#{mth}/#{day}" `

  c= `scp storage/dcim/camera/#{t}_#{p}* #{user_host}:#{destpath}m/#{year}/#{mth}/#{day} && rm storage/dcim/camera/#{t}_#{p}*`
  puts c

This nicely organizes all my files by date and clears out the space on my phone.

19. September 2018

Deep Learning Fundamentals

Here’s a talk I gave at work that gives a run-down of some fundamental concepts in deep learning, and I finished the talk with an example of a convolutional neural network in keras.


02. February 2018

A Ruby Pipe

Javascript is going to get a pipeline operator any day now, and I love working with it in elixir, so I thought I’d try to make one in ruby.


17. January 2018

Introduction to J

I tried using j for some of my advent of code puzzles. I found it wasn’t totally suitable for a lot of the challenges, but I had fun learning about J nonetheless.