Monday, August 29, 2016

get movie length (duration) for all movies in a directory tree using mediainfo


/Users/smr/bin/get-movie-lengths.rb

#!/usr/bin/env ruby
require 'find'

ARGV.each do |look_here_path|
  puts "look_here_path=#{look_here_path}"
  total_minutes = 0

  Find.find(look_here_path) do |path|
    if path =~ /\.mp4|\.mkv|\.m4v/
      # puts "path=#{path}"
      filename = File.basename(path, ".*")
      puts "filename=#{filename}"
      metadata = `mediainfo "#{path}"`
      # puts "metadata=#{metadata}"
      duration = /Duration\s+:\s*(.*)$/.match(metadata)[1]
      puts "duration=#{duration}"
      hours_match = /(\d+)h/.match(duration)
      if hours_match
        hours = hours_match[1]
        puts "hours=#{hours}"
        total_minutes += hours.to_i * 60
      end
      minutes_match = /(\d+)mn/.match(duration)
      if minutes_match
        minutes = minutes_match[1]
        puts "minutes=#{minutes}"
        total_minutes += minutes.to_i
      end
    end

    puts "total_minutes=#{total_minutes}"

  end
end

# duration=12mn 14s




Wednesday, August 24, 2016

script to zap xcode derived data



#!/usr/bin/env ruby
require "fileutils"

path = "/Users/smr/Library/Developer/Xcode/DerivedData"

FileUtils.cd(path)
FileUtils.rm_rf(Dir.glob("*"))





Tuesday, August 16, 2016

how-to-turn-off-and-on-spotlight-in-mac-os-x-el-capitan

http://recomhub.com/blog/how-to-turn-off-and-on-spotlight-in-mac-os-x-el-capitan/

password generator


#!/usr/bin/env ruby
# returns a 16 character password
require 'securerandom'
# puts SecureRandom.hex(8)  #returns all lowercase

# the result may contain A-Z, a-z, 0-9, “-” and “_”. “=” is also used if padding is true.
# puts SecureRandom.urlsafe_base64
pw = SecureRandom.hex(8)
# uppercase the first contiguous block of non-digits
puts pw.sub(/(\D+)/) { |m| m.upcase() }

# In the block form, the current match string is passed in as a parameter, and
# variables such as $1, $2, $`, $&, and $' will be set appropriately. The
# value returned by the block will be substituted for the match on each call.


updates.txt - use 'Replaces = All' to prevent multiple, sequential updates when using Advanced Installer



;aiu;

[2017_001]
Name = Prepware 2017_001
ProductVersion = 17.0.1
URL = http://updates.prepware.com.s3.amazonaws.com/Install_Prepware_2017_001_win.exe
Size = 313805704
MD5 = 7f427279868e141bb89f5873cb3ddd01
ServerFileName = Install_Prepware_2017_001_win.exe
Flags = NoCache
RegistryKey = HKUD\Software\ASA\Prepware\Version
Version = 17.0.1
Description = This updater will update your installation of Prepware 2016 to version 2017_001.
Description1 = <b>Note for Prepware 2014 Users:</b> ASA provides updates for 2 years. Prepware 2014 is no longer supported with updates. If you must access the question databases represented by your old activation(s), do not do run update because it is going to remove all access to this old activation.
Feature = 07-2016 question databases
Feature1 = added Remote Pilot Unmanned Aircraft System
Feature2 = updated Inspection Authorization study guide
AutoCloseApplication = [APPDIR]Prepware.exe|;Prepware
Replaces = All

[2017_000]
Name = Prepware 2017_000
ProductVersion = 17.0.0
URL = http://updates.prepware.com.s3.amazonaws.com/Install_Prepware_2017_000_win.exe
Size = 312822840
MD5 = 484f23bf74366fd53efd28ff0c282eba
ServerFileName = Install_Prepware_2017_000_win.exe
Flags = NoCache
RegistryKey = HKUD\Software\ASA\Prepware\Version
Version = 17.0.0
Description = This updater will update your installation of Prepware 2016 to version 2017_000.
Description1 = <b>Note for Prepware 2014 Users:</b> ASA provides updates for 2 years. Prepware 2014 is no longer supported with updates. If you must access the question databases represented by your old activation(s), do not do run update because it is going to remove all access to this old activation.
Feature = 06-2016 question databases
AutoCloseApplication = [APPDIR]Prepware.exe|;Prepware

[2016_200]
Name = Prepware 2016_200
ProductVersion = 16.2.0
URL = http://updates.prepware.com.s3.amazonaws.com/Install_Prepware_2016_200_win.exe
Size = 356668280
MD5 = e0b97497d5b5302af83acd293f906fd7
ServerFileName = Install_Prepware_2016_200_win.exe
Flags = NoCache
RegistryKey = HKUD\Software\ASA\Prepware\Version
Version = 16.2.0
Description = This updater will update your installation of Prepware 2016 to version 2016_200.
Description1 = <b>Note for Prepware 2014 Users:</b> ASA provides updates for 2 years. Prepware 2014 is no longer supported with updates. If you must access the question databases represented by your old activation(s), do not do run update because it is going to remove all access to this old activation.
Feature = 02-2016 question databases
AutoCloseApplication = [APPDIR]Prepware.exe|;Prepware

[2016_100]
Name = Prepware 2016_100
ProductVersion = 16.1.0
URL = http://updates.prepware.com.s3.amazonaws.com/Install_Prepware_2016_100_win.exe
Size = 356235776
MD5 = 03ad573db06a698a995d13b24d052d60
ServerFileName = Install_Prepware_2016_100_win.exe
Flags = NoCache
RegistryKey = HKUD\Software\ASA\Prepware\Version
Version = 16.1.0
Description = This updater will update your installation of Prepware 2016 to version 2016_100.
Description1 = <b>Note for Prepware 2014 Users:</b> ASA provides updates for 2 years. Prepware 2014 is no longer supported with updates. If you must access the question databases represented by your old activation(s), do not do run update because it is going to remove all access to this old activation.
Feature = 10-2015 question databases
AutoCloseApplication = [APPDIR]Prepware.exe|;Prepware



Saturday, August 13, 2016

ASA notes - faramt android crashing upon initial run on test device (6.0.1)


faramt android crashing upon initial run on test device (6.0.1)

appears to have something to do with downloading the zip of figs.

fix:
apk file size limit on google play increased to 100MB:
http://android-developers.blogspot.com/2015/09/support-for-100mb-apks-on-google-play.html

if we include the ac figs we're still within this limit.
so do that.



##################################################
# notes
##################################################
Running dex in-process requires build tools 23.0.2.
For faster builds update this project to use the latest build tools.

08-13 07:26:29.908 30706 30706 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asa2fly.faramtandroid/com.asa2fly.faramtandroid.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array



08-13 07:36:24.962   624   673 I ActivityManager: Start proc 31332:com.asa2fly.faramtandroid/u0a278 for activity com.asa2fly.faramtandroid/.MainActivity

08-13 07:36:25.029 31332 31332 W System  : ClassLoader referenced unknown path: /data/app/com.asa2fly.faramtandroid-1/lib/arm

08-13 07:36:25.062 31332 31332 I FARAIM  : db size=0

08-13 07:36:25.062 31332 31332 I FARAIM  : faramt_android.db will be copied

08-13 07:36:26.856 31332 31332 D AndroidRuntime: Shutting down VM

08-13 07:36:26.857 31332 31332 E AndroidRuntime: FATAL EXCEPTION: main

08-13 07:36:26.857 31332 31332 E AndroidRuntime: Process: com.asa2fly.faramtandroid, PID: 31332

08-13 07:36:26.857 31332 31332 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.asa2fly.faramtandroid/com.asa2fly.faramtandroid.MainActivity}: java.lang.NullPointerException: Attempt to get length of null array

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread.-wrap11(ActivityThread.java)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.os.Handler.dispatchMessage(Handler.java:102)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.os.Looper.loop(Looper.java:148)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread.main(ActivityThread.java:5417)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at java.lang.reflect.Method.invoke(Native Method)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

08-13 07:36:26.857 31332 31332 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to get length of null array

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at com.asa2fly.faramtandroid.FigDownloadChecker.figsNeedToBeDownloaded(FigDownloadChecker.java:33)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at com.asa2fly.faramtandroid.FigDownloadChecker.shouldInitiateFigureDownload(FigDownloadChecker.java:20)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at com.asa2fly.faramtandroid.MainActivity.onStart(MainActivity.java:54)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1237)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.Activity.performStart(Activity.java:6268)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2379)

08-13 07:36:26.857 31332 31332 E AndroidRuntime:  ... 9 more

08-13 07:36:26.860   624  2776 W ActivityManager:   Force finishing activity com.asa2fly.faramtandroid/.MainActivity

08-13 07:36:27.165   624  2776 I WindowManager: Screenshot max retries 4 of Token{4ebc683 ActivityRecord{b623932 u0 com.asa2fly.faramtandroid/.MainActivity t3180 f}} appWin=Window{c2c64c4 u0 Starting com.asa2fly.faramtandroid} drawState=4

08-13 07:36:27.205   624   989 I OpenGLRenderer: Initialized EGL, version 1.4

08-13 07:36:27.447   624 31357 W DropBoxManagerService: Dropping: data_app_crash (1603 > 0 bytes)

08-13 07:36:27.495  5886 31359 D DropBoxEntryAddedChimeraService: User is not opted-in to Usage & Diagnostics or Lockbox.




08-13 07:44:35.110   624  2308 I ActivityManager: START u0 {cmp=com.asa2fly.faramtandroid/.DownloadFigsActivity} from uid 10279 on display 0

08-13 07:44:35.124 32016 32035 D OpenGLRenderer: Use EGL_SWAP_BEHAVIOR_PRESERVED: true

08-13 07:44:35.541 32016 32035 I Adreno-EGL: <qeglDrvAPI_eglInitialize:379>: QUALCOMM Build: 10/21/15, 369a2ea, I96aee987eb

08-13 07:44:35.543 32016 32035 I OpenGLRenderer: Initialized EGL, version 1.4

08-13 07:44:35.710   624   681 I ActivityManager: Displayed com.asa2fly.faramtandroid/.DownloadFigsActivity: +282ms (total +3m38s734ms)

08-13 07:44:36.373   194   613 D audio_hw_primary: disable_audio_route: reset and update mixer path: low-latency-playback

08-13 07:44:36.373   194   613 D audio_hw_primary: disable_snd_device: snd_device(2: speaker)

08-13 07:44:40.818   194   613 D audio_hw_primary: out_set_parameters: enter: usecase(1: low-latency-playback) kvpairs: routing=2

08-13 07:44:40.828   194   613 D audio_hw_primary: select_devices: out_snd_device(2: speaker) in_snd_device(0: none)

08-13 07:44:40.828   194   613 D ACDB-LOADER: ACDB -> send_afe_cal

08-13 07:44:40.828   194   613 D audio_hw_primary: enable_snd_device: snd_device(2: speaker)

08-13 07:44:40.836   194   613 D audio_hw_primary: enable_audio_route: apply and update mixer path: low-latency-playback

08-13 07:44:41.459   624   673 W InputMethodManagerService: Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@365cc3 attribute=null, token = android.os.BinderProxy@11cb309

08-13 07:44:41.474 32016 32058 E Decompress: unzip

08-13 07:44:41.474 32016 32058 E Decompress: java.io.FileNotFoundException: /storage/emulated/0/faramt_figs.zip: open failed: ENOENT (No such file or directory)

08-13 07:44:41.474 32016 32058 E Decompress:  at libcore.io.IoBridge.open(IoBridge.java:452)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.io.FileInputStream.<init>(FileInputStream.java:76)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.io.FileInputStream.<init>(FileInputStream.java:103)

08-13 07:44:41.474 32016 32058 E Decompress:  at com.asa2fly.faramtandroid.DownloadFigsActivity$UnzipFileAsync.doInBackground(DownloadFigsActivity.java:166)

08-13 07:44:41.474 32016 32058 E Decompress:  at com.asa2fly.faramtandroid.DownloadFigsActivity$UnzipFileAsync.doInBackground(DownloadFigsActivity.java:141)

08-13 07:44:41.474 32016 32058 E Decompress:  at android.os.AsyncTask$2.call(AsyncTask.java:295)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.util.concurrent.FutureTask.run(FutureTask.java:237)

08-13 07:44:41.474 32016 32058 E Decompress:  at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:234)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)

08-13 07:44:41.474 32016 32058 E Decompress:  at java.lang.Thread.run(Thread.java:818)

08-13 07:44:41.474 32016 32058 E Decompress: Caused by: android.system.ErrnoException: open failed: ENOENT (No such file or directory)

08-13 07:44:41.474 32016 32058 E Decompress:  at libcore.io.Posix.open(Native Method)

08-13 07:44:41.474 32016 32058 E Decompress:  at libcore.io.BlockGuardOs.open(BlockGuardOs.java:186)

08-13 07:44:41.474 32016 32058 E Decompress:  at libcore.io.IoBridge.open(IoBridge.java:438)

08-13 07:44:41.474 32016 32058 E Decompress:  ... 10 more



shell@flo:/sdcard $ du -sh *
4.0K  Alarms
6.3G  Android
12K DCIM
4.0K  Digital Editions
138M  Download
1.8G  Movies
4.0K  Music
60K Notifications
32M Pictures
4.0K  Podcasts
184K  Ringtones
108K  backups
640K  eBooks
61M prepware_figs
116K  screenshot.png
49M testing


http://alvinalexander.com/android/android-file-transfer-app-cant-access-device-storage-solved-working


1|shell@flo:/ $ df
Filesystem               Size     Used     Free   Blksize
/dev                   903.4M    76.0K   903.3M   4096
/sys/fs/cgroup         903.4M    12.0K   903.4M   4096
/mnt                   903.4M     0.0K   903.4M   4096
/system                827.8M   823.7M     4.1M   4096
/cache                 551.7M    25.2M   526.5M   4096
/data                   11.9G    11.3G   663.9M   4096
/persist                14.5M     4.2M    10.2M   4096
/storage               903.4M     0.0K   903.4M   4096
/mnt/runtime/default/emulated: Permission denied
/storage/emulated       11.9G    11.3G   663.9M   4096
/mnt/runtime/read/emulated: Permission denied
/mnt/runtime/write/emulated: Permission denied

http://stackoverflow.com/questions/2941552/how-can-i-check-how-much-free-space-an-sd-card-mounted-on-an-android-device-has


file size limit incresed to 100MB:
http://android-developers.blogspot.com/2015/09/support-for-100mb-apks-on-google-play.html