find . -name '*.html' -exec sed -i "" 's/
//g' {} \;
Showing posts with label command line. Show all posts
Showing posts with label command line. Show all posts
Wednesday, November 30, 2016
bulk zap funk from grs content html on the command line
find . -name '*.html' -exec sed -i "" 's/
//g' {} \;
Sunday, November 20, 2016
xcode8 - xcodebuild wank with signing ipa
https://pewpewthespells.com/blog/migrating_code_signing.html#signing-in-xcode-8
error looks like:
None of the valid provisioning profiles allowed the specified entitlements: application-identifier, beta-reports-active, keychain-access-groups
voodoo fix:
after using xcode (instead of the command line) to archive then export an ad-hoc ipa, the command line build issue seemed to resolve itself.
Tuesday, August 16, 2016
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.
Monday, July 25, 2016
archkeyboard-maestro-macros.rb
/Users/smr/bin/archkeyboard-maestro-macros.rb
#!/usr/bin/env ruby require 'aws-sdk-v1' require 'fileutils' now = Time::now now_str = now.strftime("%Y-%m-%d") puts "now_str=#{now_str}" directoryToZip = "/Users/smr/Library/Application Support/Keyboard Maestro/" zip_filename = "km-app-support-#{now_str}.zip" outputFile = "/tmp/#{zip_filename}" system "ditto", "-c", "-k", "-v", "--keepParent", directoryToZip, outputFile # system "open", "/tmp" FileUtils.cd("/tmp") # http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpRuby.html AWS.config( :access_key_id => ENV["ASA_S3_ACCESS_KEY_ID"], :secret_access_key => ENV["ASA_S3_SECRET_ACCESS_KEY"]) bucket_name = "smr.prepware.com" file_name = zip_filename puts "uploading #{zip_filename} to bucket: #{bucket_name}" # get an instance of the S3 interface using the default configuration s3 = AWS::S3.new # get a ref to an existing bucket bucket = s3.buckets[bucket_name] # no request made puts "bucket=#{bucket}" obj = bucket.objects[file_name] # streaming upload a file to S3 obj.write(Pathname.new(file_name)) # obj.acl = :public_read
Thursday, July 7, 2016
ruby script to register prepware desktop with a command line tool; regtimestamp
/Users/smr/bin/register-prepware.rb
#!/usr/bin/env ruby require 'sqlite3' db_path = "/Users/smr/Library/Application Support/Prepware/persistence.db" puts "updating #{db_path}" tablename = "act" now = Time::now timestamp = now.strftime('%Y-%m-%d') puts "setting regtimestamp to #{timestamp}" db = SQLite3::Database.open db_path db.execute( "update #{tablename} set regtimestamp ='#{timestamp}'" ) db.close if db system "open", db_path
Sunday, May 15, 2016
generate release build email or FARAIM iOS using info from git log and plist
#!/usr/bin/env ruby require 'fileutils' require 'nokogiri' require 'git' git_repo_working_dir = '/Users/smr/current_projects/faraim-ios' ################################################## # get sha of last commit from the gir repo ################################################## g = Git.open(git_repo_working_dir) commits = g.log(1) # returns array of last N Git::Commit objects last_commit = commits.first sha_first_7 = last_commit.sha[0..6] ################################################## # get the app version from the plist ################################################## FileUtils.cd("/Users/smr/current_projects/faraim-ios/source/") PLIST_FILENAME = "FARAIMCoreData-Info.plist" f = File.open(PLIST_FILENAME) doc = Nokogiri::XML(f) f.close version = "" doc.xpath('//key[text()="CFBundleVersion"]').each { |key| version = key.next_element().text() } puts "version=#{version}" # name looks like FARAIM-1.39-b08ba16.ipa ipa_filename = "FARAIM-#{version}-#{sha_first_7}.ipa" ################################################## # generate email: mail body includes last 5 commits ################################################## email_subject = "faraim for iOS #{version} (#{sha_first_7})" mail_body = <<EOF a new faraim for iOS build (version #{version}, build #{sha_first_7}) was posted to the asa ftp apps server at: faraim-ios/builds/#{ipa_filename} and is ready for testing. EOF commits = g.log(5) commits.each do |commit| mail_body += " commit #{commit.sha} Author: #{commit.author.name} <#{commit.author.email}> Date: #{commit.date.strftime('%A, %B %d, %Y')} #{commit.message} " end # escape double quotes mail_body.gsub!(/"/, '\"') ################################################## # use osacscript compose an email ################################################## # https://gist.github.com/dinge/6983008 # calling applescript from ruby def osascript(script) system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten end osascript <<EOF set theSender to "stephen rouse <stephenr@asa2fly.com>" set recipientAddressList to ["jackie@asa2fly.com", "sarah@asa2fly.com", "michael@asa2fly.com"] set theSubject to "#{email_subject}" set theContent to "#{mail_body}" set theSignatureName to "asa2fly" tell application "Mail" set msg to make new outgoing message with properties {subject:theSubject, sender:theSender, content:theContent, visible:true} set message signature of msg to signature theSignatureName tell msg repeat with i from 1 to count recipientAddressList make new to recipient at end of to recipients with properties {address:item i of recipientAddressList} end repeat end tell end tell return -- prevents "missing value" being returned by the script EOF
screenshot of km macro that calls the above script:

Friday, February 26, 2016
content_info timestamp for the oeg android apps
/Users/smr/current_projects/oeg-a/work/add-content-info-timestamp.rb
#!/usr/bin/env ruby # add a content_info table with a timestamp column require 'sqlite3' tablename = "content_info" y = 2015 m = 1 d = 29 born_on_date = DateTime.new(y,m,d,17,0,0) ARGV.each do|filename| puts "filename=#{filename}" puts "timestamp date=#{y}-#{m}-#{d}" begin db = SQLite3::Database.open filename version = db.get_first_value 'SELECT SQLITE_VERSION()' puts "sqlite version=#{version}" # android metadata db.execute "DROP TABLE IF EXISTS android_metadata;" db.execute "CREATE TABLE android_metadata (locale TEXT);" db.execute "insert into android_metadata values('en_US')" #content_info (born-on timestamp) timestamp = born_on_date.to_time.to_i db.execute "DROP TABLE IF EXISTS #{tablename};" db.execute "CREATE TABLE #{tablename} (timestamp INT);" db.execute "insert into #{tablename} values(#{timestamp})" puts "timestamp int=#{timestamp}" system "open", filename rescue SQLite3::Exception => e puts "Exception occured" puts e ensure db.close if db end end
Thursday, February 25, 2016
ruby script to list image dimensions
/Users/smr/bin/get-image-dimensions.rb
#!/usr/bin/env ruby #get-image-dimensions.rb *.png require 'dimensions' ARGV.each do |image_file| size = Dimensions.dimensions(image_file) puts "#{image_file}: #{size}" end
Monday, February 15, 2016
archive the yojimbo 4 database to S3 using a command line script
#!/usr/bin/env ruby require 'aws-sdk-v1' require 'fileutils' require 'getoptlong' # command line options copy_zip_to_dropbox = false opts = GetoptLong.new( [ '--dropbox', '-d', GetoptLong::OPTIONAL_ARGUMENT ] ) opts.each do |opt, arg| case opt when '--dropbox' copy_zip_to_dropbox = true end end now = Time::now now_str = now.strftime("%Y-%m-%d") puts "now_str=#{now_str}" directoryToZip = "/Users/smr/Library/Application Support/Yojimbo/" zip_filename = "Yojimbo-#{now_str}.zip" outputFile = "/tmp/#{zip_filename}" system "ditto", "-c", "-k", "-v", "--keepParent", directoryToZip, outputFile # system "open", "/tmp" FileUtils.cd("/tmp") ################################################## # for dropbox ################################################## if copy_zip_to_dropbox FileUtils.cp outputFile, "/Users/smr/Dropbox/Apps/Yojimbo/" end ################################################## # for S3 ################################################## # http://docs.aws.amazon.com/AmazonS3/latest/dev/UploadObjSingleOpRuby.html AWS.config( :access_key_id => ENV["ASA_S3_ACCESS_KEY_ID"], :secret_access_key => ENV["ASA_S3_SECRET_ACCESS_KEY"]) bucket_name = "smr.prepware.com" file_name = zip_filename puts "uploading #{zip_filename} to bucket: #{bucket_name}" # get an instance of the S3 interface using the default configuration s3 = AWS::S3.new # get a ref to an existing bucket bucket = s3.buckets[bucket_name] # no request made puts "bucket=#{bucket}" obj = bucket.objects[file_name] # streaming upload a file to S3 obj.write(Pathname.new(file_name)) # obj.acl = :public_read
Saturday, February 13, 2016
use sips to create thumbnails for pwo fig library tool
- copy figs from /Users/smr/current_projects/prepware-macos/submodules/figs/ to work folder
- e.g. /Users/smr/Desktop/fig_library_tn/
- max 150px w or h
- runs sips once for png, once for jpg files:
-
[smr@smr fig_library_tn]$ time(sips -Z 150 *.png)
- [smr@smr ig_library_tn]$ time(sips -Z 150 *.jpg)
images are altered in place.
Thursday, February 11, 2016
add a subl_wait script for use with crontab -e; use sublime text for cron
https://sublimetext.userecho.com/topics/1411-equivalent-of-mate_wait-for-subl/
/Users/smr/bin/subl_wait
#!/bin/sh subl -w $*
[smr@smr ~]$ subl_wait hello.txt
in .bash_profile:
export VISUAL=~/bin/subl_wait
[smr@smr ~]$ crontab -e
crontab: no crontab for smr - using an empty one
crontab: installing new crontab
[smr@smr ~]$ crontab -e
crontab: installing new crontab
Monday, February 8, 2016
tidyxml filter
/Users/smr/bin/tidyxml
#!/usr/bin/env ruby # coding: utf-8 # usage: # tidyxml *.xml require "nokogiri" ARGV.each do|filename| puts "processing #{filename}" stem = File.basename(filename, ".xml") # tidy5 --input-xml yes --output-xml yes --indent yes --indent-spaces 2 -wrap --show-warnings 0 --output-file tidied.xml TH67_s1.xml system "tidy5", "--input-xml", "yes", "--output-xml", "yes", "--indent", "yes", "--indent-spaces", "2", "-wrap", "--show-warnings", "0", "--output-file", "/tmp/#{stem}.xml", filename system "open", "/tmp/#{stem}.xml" end
tidy an xml file using brew-installed tidy5
[smr@smr xml]$ tidy5 --input-xml yes --output-xml yes --indent yes --indent-spaces 2 -wrap --show-warnings 0 --output-file tidied.xml TH67_s1.xml
Thursday, December 10, 2015
compile bootstrap-3.3.6 using node and less
download source from:
http://getbootstrap.com/getting-started/#download
use homebrew to upgrade node if necessary
[smr@smr bootstrap-3.3.6]$ brew upgrade node
Error: node 5.1.1 already installed
cd bootstrap-3.3.6
npm install
grunt dist
or
grunt
see:
http://getbootstrap.com/getting-started/#grunt-commands
for details of grunt commands.
Thursday, October 29, 2015
extract audio from a video file using vlc on the command line; mp3
/Applications/VLC.app/Contents/MacOS/VLC -I dummy "/Users/smr/Desktop/e-dancing.m4v" --sout='#transcode{acodec=mp3,vcodec=dummyvcodec}:standard{access=file,mux=raw,dst="/Users/smr/Desktop/test2.mp3"}' vlc://quit
Monday, August 24, 2015
Friday, August 21, 2015
create a rails app dir first
mkdir jwptest cd jwptest rvm use ruby-2.2.2@jwptest --ruby-version --create gem install rails rails new .
install tidy5 using homebrew
http://stackoverflow.com/questions/13380012/tidy-html5-on-mac-os-how-to-install
[smr@smr ~]$ tidy5 -indent --indent-spaces 2 --tab-size 2 -wrap /Users/smr/Desktop/student-home.html [smr@smr ~]$ tidy5 -indent --indent-spaces 2 -wrap --show-warnings 0 --output-file tidied.html /Users/smr/Desktop/student-home.html
[smr@smr ~]$ tidy5 -show-config | pbcopy Configuration File Settings: Name Type Current Value =========================== ========= ======================================== accessibility-check enum 0 (Tidy Classic) add-xml-decl Boolean no add-xml-space Boolean no alt-text String anchor-as-name Boolean yes ascii-chars Boolean no assume-xml-procins Boolean no bare Boolean no break-before-br Boolean no char-encoding Encoding utf8 clean Boolean no coerce-endtags Boolean yes css-prefix String decorate-inferred-ul Boolean no doctype DocType auto doctype-mode Integer *2 drop-empty-elements Boolean yes drop-empty-paras Boolean yes drop-font-tags Boolean no drop-proprietary-attributes Boolean no enclose-block-text Boolean no enclose-text Boolean no error-file String escape-cdata Boolean no fix-backslash Boolean yes fix-bad-comments Boolean yes fix-uri Boolean yes force-output Boolean no gdoc Boolean no gnu-emacs Boolean no gnu-emacs-file String hide-comments Boolean no hide-endtags Boolean no indent AutoBool no indent-attributes Boolean no indent-cdata Boolean no indent-spaces Integer 2 indent-with-tabs Boolean no input-encoding Encoding utf8 input-xml Boolean no join-classes Boolean no join-styles Boolean yes keep-time Boolean no language String literal-attributes Boolean no logical-emphasis Boolean no lower-literals Boolean yes markup Boolean yes merge-divs AutoBool auto merge-emphasis Boolean yes merge-spans AutoBool auto ncr Boolean yes new-blocklevel-tags Tag names new-empty-tags Tag names new-inline-tags Tag names new-pre-tags Tag names newline enum LF numeric-entities Boolean no omit-optional-tags Boolean no output-bom AutoBool auto output-encoding Encoding utf8 output-file String output-html Boolean no output-xhtml Boolean no output-xml Boolean no preserve-entities Boolean no punctuation-wrap Boolean no quiet Boolean no quote-ampersand Boolean yes quote-marks Boolean no quote-nbsp Boolean yes repeated-attributes enum keep-last replace-color Boolean no show-body-only AutoBool no show-errors Integer 6 show-info Boolean yes show-warnings Boolean yes slide-style String sort-attributes enum none split Boolean no tab-size Integer 8 tidy-mark Boolean yes uppercase-attributes Boolean no uppercase-tags Boolean no vertical-space Boolean no word-2000 Boolean no wrap Integer 68 wrap-asp Boolean yes wrap-attributes Boolean no wrap-jste Boolean yes wrap-php Boolean yes wrap-script-literals Boolean no wrap-sections Boolean yes write-back Boolean no Values marked with an *asterisk are calculated internally by HTML Tidy
Sunday, August 16, 2015
command line rename utility
http://plasmasturm.org/code/rename/
install with homebrew:
install with homebrew:
[smr@smr ~]$ brew install rename ==> Downloading https://homebrew.bintray.com/bottles/rename-1.600.mavericks.bott ######################################################################## 100.0% ==> Pouring rename-1.600.mavericks.bottle.tar.gz 🍺 /usr/local/Cellar/rename/1.600: 3 files, 48K
examplesrename -N ...01 -X -e '$_ = "File-$N"' *specify 0-padding of a given width:rename --dry-run -N 001 -e '$_ = "$N-$_"' *specify a certain starting number:rename --dry-run -N 007 -e '$_ = "$N-$_"' *prepend:rename --dry-run -A "500"- *rename --dry-run -N 001 -A 'xxxx' *rename to incrementally numbered files:rename -N ...01 -X -e '$_ = "File-$N"' *This will throw away all the existing filenames and simply number the files from 1 through however many files there are – except that it will preserve their extensions.perl-like replacement (delete spaces)rename --dry-run 's/ //g' -c *rename s/jpeg/jpg/ *[smr@macpro e-pix]$ rename s/jpeg/jpg/ *[smr@macpro e-pix]$ lltotal 7688drwxr-xr-x 6 smr staff 204 Sep 18 10:14 .drwxr-xr-x 5 smr staff 170 Sep 18 10:11 ..-rw-r--r--@ 1 smr staff 999424 Sep 18 10:10 IMG_4849.jpg-rw-r--r--@ 1 smr staff 983040 Sep 18 10:10 IMG_5051.jpg-rw-r--r--@ 1 smr staff 974848 Sep 18 10:10 IMG_9503.jpg-rw-r--r--@ 1 smr staff 978944 Sep 18 10:10 IMG_9909.jpg
Thursday, August 13, 2015
set the rvm default, using a gemset
[smr@macbook junkapp]$ rvm use 2.2.2@rails4 --defaulthttp://stackoverflow.com/questions/7788946/rails-keeps-telling-me-that-its-not-currently-installed
Subscribe to:
Comments (Atom)