Now it seems obvious, and I feel silly about it, but setting a view's autoresizingMask's before setting its frame or bounds, makes the resizing not work properly.
Build, archive, submit to iTunes Connect, HockeyApp or similar services from the command line. I was skeptical at first, but now I kinda look forward to using it. Took me a while to set it up properly, due to poorly configured openssl, mostly, but otherwise it's pretty straightforward. You can get it here. Felix is an awesome guy too - I had a problem and he managed to reply faster than I came back from lunch 😊.
I don't think this is a likely scenario, but I wanted to cover the case where two posts have the same title, and, most likely, the same URL. Filenames will always be unique, because their format is YYYY-MM-DD-Post title, meaning I can make use of this, when running the sync command:
Oh man, I can't believe it's been almost a year since I've written anything. But it's been an amazing year!
I will start with Polychromatic, an Xcode theme that takes a different approach to syntax coloring: emphasize variables (only local ones for Swift), arguments, macros and statics by only coloring these, with a dynamically picked color.
I was skeptical at first (I quickly uninstalled it the first time I tried it, a couple of months ago) but I feel that my eyes are a bit more rested, due to less color and I can spot important information more easily.
Since creating formatters is very expensive, it's a good idea to have a singleton for them. But what if you have a standard style throughout the app, except a couple of places? Encapsulate it in a Static struct and set the required settings before returning:
struct Utils {
class var numberFormatter: NumberFormatter {
struct Static {
static let formatter = NumberFormatter()
}
Static.formatter.maximumFractionDigits = 2
Static.formatter.alwaysShowsDecimalSeparator = false
return Static.formatter
}
}Then in the places with a different style:
I read this a while ago, and I just love doing this:
view.backgroundColor = .red
view.backgroundColor = .custom
formatter.locale = .autoupdatingCurrent
label.font = .withSize(15)
label.font = .customFont(ofSize: 15)If only the compiler would offer proper autocomplete ... But, hey, at least it's faster and/or easier sometimes.
In a recent change I tried to handle the time zone like this:
def time_from_string(string)
date_matches = string.match(/(\d{4})-(\d{2})-(\d{2})-(\d{4})/)
Time.zone = 'Bucharest'
time_zone = Time.zone.formatted_offset
# A little hack to account for daylight savings of when the post was created
time_zone = '+03:00' if Time.strptime("#{date_matches}", '%Y-%m-%d-%H%M').dst?
time = Date._strptime("#{date_matches[4]} #{time_zone}", '%H%M %:z')
DateTime.new(date_matches[1].to_i, date_matches[2].to_i, date_matches[3].to_i, time[:hour], time[:min], 0, time[:zone]).in_time_zone
endI remembered I have a Hazel rule that syncs the files automatically when a new file is added. So I realised I can improve the future posts even further: instead of excluding files, it's better to exclude posts, based on date:
get '/' do
[...]
all_posts.reject! do |post|
time_from_string(post[:datetime]) == nil || DateTime.now.to_time < time_from_string(post[:datetime])
end
[...]
end
get '/feed' do
[...]
posts.each do |post|
next if time_from_string(post[:datetime]) == nil || DateTime.now.to_time < time_from_string(post[:datetime])
[...]
end
[...]
endSometimes I have an idea to write about, but I don't really want to post it now, since I want to spread the posts out, so I will just prepare it for future posting. The problem is that right now the sync command tries to add all files, so I came up with a way to only parse files with a date in the past:
def time_from_string(string)
date_matches = string.match(/(\d{4})-(\d{2})-(\d{2})-(\d{4})/)
time_zone = Time.now.getlocal.zone
time = Date._strptime("#{date_matches[4]} #{time_zone}", '%H%M %Z')
DateTime.new(date_matches[1].to_i, date_matches[2].to_i, date_matches[3].to_i, time[:hour], time[:min], 0, time[:zone]).to_time
end
get '/sync_command' do
[...]
client_metadata.each do |file|
next if DateTime.now.to_time < time_from_string(datetime)
[...]
endSince I don't want everybody to run this command, although it doesn't really harm in any way, I added a parameter to act as a private key:
get '/cmd.Dropbox.Sync/:key/?:with_delete?' do
redirect_to_404 unless params[:key] == MY_SYNC_KEYThe with_delete parameter lets the sync posts command know if to check for deleted files or not. Why this approach? Because the support for multiple posts with same title implies iterating over all posts and on each iteration to iterate over all file names, to make sure.