Time Wasters

Because you can’t be productive all the time


Picking ionic back up

OK, so it’s been a while and you have to pick back up from where you last left off with your ionic app. He’s how to go about that on Mac with Git.

  1. Pull from Git
  2. Run “npm install” to get all the modules
  3. Run “ionic cordova prepare” to install plugins

If you need to redo your signing, you can follow these steps

  1. Select a development team
    https://stackoverflow.com/questions/39524148/requires-a-development-team-select-a-development-team-in-the-project-editor-cod
  2. If you invalid errors, make sure your system clock has the correct date

Hopefully that did the trick and you’re ready to go, I’ll add any errors and fixes I come across to the end of the article, but here’s how to go about testing.

Emulator testing:

  1. Just run “ionic cordova emulate ios” to start it up in the emulator

Ad hoc Device testing:

  1. Open Xcode
  2. Open the iOS project, probably something like “~/Documents/app/platform/ios/App.xcworkspace”
  3. Choose Product->Build For->Testing
  4. Product->Archive
  5. Click the “Export…” button and choose Development and choose where to export the IPA
  6. Upload the IPA to diawi.com, then install on device

 

To fix “‘xcodebuild’ requires Xcode” errors

  • Run Xcode from applications directory
  • xcode-select –install # Install Command Line Tools if you haven’t already.
  • sudo xcode-select –switch /Library/Developer/CommandLineTools # Enable command line tools
  • sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

Permalink » No comments

Transfer files to FTP via Rails console

First require Net::FTP so the functions will be available

1
require 'net/ftp'

Create FTP connection, with a custom port

1
2
3
4
ftp = Net::FTP.new
ftp.connect('url', port) 
ftp.login('username', 'password')
ftp.passive = true

Move to the folder you want to upload the file into

1
ftp.chdir('folder/')

Get URL of paperclip file

1
url = 'public'+paperclip.photo.url.gsub(/\?.*/, '')

Upload to server

1
ftp.putbinaryfile(url)

Close connection

1
ftp.quit()

Permalink » No comments

Fastest way to search an object

Same deal as my previous post, I want to pin down the fastest method to use to search the parameter values of an object in Javascript using https://jsperf.com.  I found 4 different ways to receive the same result, this isn’t an exhaustive list but features some of the most common methods used for searching objects.

Between multiple tests findIndex and find did the best, but find was faster more often then findIndex.

obj_search

 

 

Permalink » No comments

Exporting data to CSV in rails console

I’ve had a similar post to this in the past where I exported an entire table to CSV, but what if you want to export only a subset of that data? Well, that’s what this post is for :)

  1. Start with a query that narrows things down as much as possible
  2. Then loop through those results to apply any additional filtering you need
  3. Finally generate the CSV file with a header
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
date = Date.new(2016,12,15)
l = Table.where("created_at > ? AND column != 'variable'", date)
 
ActiveRecord::Base.logger = nil
results = []
l.each do |i|
 u = User.where(:email => i.email)
 if u.present?
   if Table.where(:email => u[0].email).blank?
     results << {:email=>i.email,:member=>'y'}
   end
 else
   results << {:email=>i.email,:member=>'n'}
 end
end;0
 
 
require 'csv'
 
file = "#{Rails.root}/public/data.csv"
 
CSV.open( file, 'w' ) do |writer|
 writer << results.first.map { |a,v| a }
 results.each do |s|
 writer << s.map { |a,v| v }
 end
end
 
 

Permalink » No comments

simple-zoom

Just finished pushing a very simple zoom app in GitHub, I couldn’t find a nice script that would allow the image to take up the full size of it’s parent element when zoomed in, and would handle updating the image dynamically.  So I wrote one for myself.

Get the files on GitHub.

See a preview:

Permalink » No comments