Soemarko Ridwan

iOS & Web Developer ⟡ Coffee Addict ⟡ Scuba Diver


Posts filed under Programming


iOS Package Manager: Carthage or CocoaPods
iOS Package Manager: Carthage or CocoaPods

Preamble: I have wrote a lot because I've been tinkering (read: breaking and fixing it back) my 3D printer. And I've just returned from my scuba diving trip to Komodo, which was out of this world. That and I'm also furiously looking into Swift UI without installing any of the beta OS. I never installed any of the beta software unless I have to.

The short answer is neither.

Package manager has been an interesting project in recent years for shippable products. In the beginning it was a brilliant way to get a tool or software installed on your preferred linux distro. For the shippable projects, I believe it was popularized by npm (Node Package Manager) for NodeJS, then others follow suit; Composer for PHP, Gradle for Java etc.

My love and hate for package manager begins and ends with npm. When I was learning NodeJS, I thought how brilliant is this npm thing?! And not too long afterwards, I realized how stupid it was to publish and rely on someone else's code without even looking into it. Glad I didn't have to learn it the hard way. I understand that the codes were open source. But I never personally check on them. And what happens if the dev decides to abandon, or literally pulled it under you? Can you make it yourself to just restore your app back to the original state?

Now back to the question I propose in the title, just so you guys understood the difference; Cocoapods builds the dependencies when you build your project. Including cocoapods means you have to use a workspace with all of your dependencies added as separate projects in the workspace, and anytime you make a clean build (or archive) you have to rebuild them all. Carthage checks out the source code and builds the frameworks independently of your project. You then add them to your project and include a script to copy them in properly. It's a much more desynchronized process.

If I have to pick, I'd pick Carthage, but again, seriously, neither. SPM (Swift Package Manager) is interesting, but very unlikely to be available for the framework or library you'd want to use. I once was offered to inherit an app that won't compile anymore, it had more than 30 "pods" in the project. Nope!


Best of WWDC 2019 for iOS Dev
Best of WWDC 2019 for iOS Dev

… well, for me. the “IMHO” implied.

  1. Sign-in with Apple

This is huge, yuuuuge. I friggin hate accounts. Managing user account is a necessary evil for a long time. On the server side I need to handle a lot of things, this was even before GDPR. Sign-in with Twitter / Facebook kinda alleviate this a tiny bit, but normal implementation still requires the “sign-in with your email”. Sign-in with Apple felt more complete, and definitely more than enough if your app is iOS only app that requires a little bit of server integration.

  1. Project Catalyst

a.k.a Marzipan, honestly, I prefer Marzipan as the name. I’ve posted my thoughts about this. It’ll be an exciting time for Mac Apps ecosystem soon enough.

  1. SwiftUI + Combine framework

I never was a fan of Storyboard, or even _xib_s. But this, this felt like a native RxSwift. There were issues when I was playing around with RxSwift, mainly I was hitting a wall that wasn’t clear whether the problem were coming from RxSwift or Xcode. So back then (about a couple years ago), I decided to just use plain Swift. Which served me well on many jobs / projects that coming my way. I get to mix it up with Obj-C. And many libraries were updated for Swift only implementation.

Those are my top 3. Bonus: WWDC 2019 Art Wallpaper.


The Five Stages of Developing a New App

Source. This is so true.

  1. Curiosity
  2. Excitement
  3. Productivity
  4. Despair
  5. Polish
  6. Ship

Despair is the worst. I've abandon many apps during that stage.

Sidebar: I listen to many podcasts. I have a few that I have to actively listen to, like ATP, and Hello Internet. I use a different app on iPad for mostly NPR podcasts, these are just for getting me to sleep. Under the Radar is one of those that I subscribe to, but I don't really listen unless I have nothing else to listen to. But I'm glad that I listened to this one.


re: A Conspiracy To Kill IE6
re: A Conspiracy To Kill IE6

source

The plan was very simple. We would put a small banner above the video player that would only show up for IE6 users. It would read “We will be phasing out support for your browser soon. Please upgrade to one of these more modern browsers.” Next to the text would be links to the current versions of the major browsers, including Chrome, Firefox, IE8 and eventually, Opera.

Well technically, it’s just a conspiracy to deprecate IE6 within YouTube. Although, to be fair, back in 2009, when I was also a full time web developer, IE6 was the bane of my existence. No sane web programmers liked IE6.

The whole thing was a fun read though. It’s like a mini heist done by a bunch of programmers, to jump over a bunch of red tapes within their corporation. Ultimately they just lucked out that the narratives surrounding it was in support of dropping IE6. Otherwise, they’d just be told to kill the banner, one or more of them got fired, and continue supporting IE6.


Marzipan
Marzipan

I responded in a thread in Bludit’s forum where there’s someone planning on making an Android app for Bludit. In that I too have plan to make an app, but since I’m more of an iOS dev than Mac, and since marzipan just around the corner, I’d wait a bit. Also, one stone — three birds.

And then there’s Marzipanify. I think I’ve mentioned this in passing before. The screenshot above was done by Steve Troughton-Smith with Marzipanify, and more importantly, without access to source code. I’m now super excited for this WWDC.


Three Ways to Migrate MySQL Database

1. phpMyAdmin:

  1. Export your database: Go in phpMyAdmin, select your database and go to Export tab. You should see a set of options, by default both data and structure should be checked so your export will contain the database structure and the actual data in the database, for transferring the database you should use the SQL format. At the bottom of the page there should be a for that will let you specify the file name, and compression. If you select “none” the export will be dumped in your browser, this is not recommended because you would have to copy that sql and then paste it in phpMyAdmin on the new server and if the dump is large it may not work.
  2. Import the database on the new server: Click on the SQL button in the left sidebar in phpMyAdmin. In the pop up window that just showed up go to “Import files” tab. In there you will be able to import the sql file you get from your first server. The problem with the phpMyAdmin approach is that most web server configurations limit the maximum size of files you upload or the maximum execution time of a php script or the maximum memory that a PHP script can use. So unless you have small dumps (under 10 MB) this method is not recommended.

2. Command line mysql client tools: if you have shell access to any of the servers ( ssh or telnet ) you can use the command line mysql client to either export (dump ) or import a mysql database . To dump the database use mysqldump:

mysqldump -u "your_username" -p —lock-tables \\
"your_database" > your_database_dump.sql

I added —lock-tables there so that it puts a read lock on all tables while running the dump process to make sure that no one can modify the databases and create inconsistencies in the dump. If you have more then one database that needs to be exported you can use the —databases option like this:

mysqldump -u "your_username" -p —lock-tables \\
—databases DB1 **[**DB2 DB3…**]** > your_database_dump.sql

If you want to export all of your databases you can just replace —databases DB1 [DB2 DB3…] with —all-databases

To import the databases on the new server you can try the phpMyAdmin method or if you have shell access (preferable ) you can use the mysql client. If you’re going to use the mysql client you will have to transfer the dump file to the server ( use ftp or sftp/scp ).You might want to compress the file before transferring it

    bzip2 your_database_dump.sql
    scp your_database_dump.sql.bz2 user@newserver:~

and after the transfer finished, run this on the new server: mysql -u “your username” -p "your_database" < database_dump.sql

Or if your dump includes a “CREATE DATABASE” statement ( usually when a file contains the dump of more then one database or if you exported you databases using —all-databases or —databases options ) then you can just do: mysql -u “your_username” -p < your_database_dump.sql

This method works with very large databases.

3. File transfer: The MySQL server stores database structure and data in regular files on disk. This means that if you can login on the server with privileges to access the folder where the databases are stored ( usually /var/lib/mysql) then you can just copy or transfer then to another server via ftp, scp, sftp, or rsync.

Before doing so, you have to make sure no one is writing to the databases that you want to transfer so you should put a read lock on them.

FLUSH TABLES WITH READ LOCK

Leave the mysql client running and then copy or transfer transfer the files. After the transfer finished, exit the mysql client or type:

    UNLOCK TABLES

To release the read lock.

This method also works with large databases, and it is faster than the previous method in this case MySQL server does not have to parse and process queries or recreate indexes because the whole data including indexes is transferred from the old server.


Code Monkey

No, it's not about that Jonathan Coulton's song, though it's somewhat related. It's about Chinese developers that are burning out before 30 years old;

He is so focused on keeping his start-up alive that he can't sleep at night. She was asked in an interview if she would be willing to break up with her boyfriend for the job. A young couple want their own family but have no energy for sex after work.

...

Tech firms in China typically expect their employees to work long hours to prove their dedication. That means a so-called 996 schedule: 9am to 9pm, six days a week.

...

There are many derogatory slang words for software developers in China, such as manong (码农), which literally means “coding farmers”, and chengxuyuan (程序猿), a play on words that translates to “programming apes.”

That last part, "programming apes," it's basically code monkey, the song was released in 2006. It's nothing new. But other than that, everything else is pretty fucked up. The thing is these situations aren't that far off here in Indonesia, especially if you're a lower ranked developer. The code monkey. The companies here won't force you to do the 996 schedule, but they just won't pay you enough so you'll need to pick up some side gigs to cover basic living costs.


Softaculous + Bludit
Softaculous + Bludit

Awhile ago I’ve posted about automating Bludit’s backup, but you know what guys? My cheap ass shared hosting has a better way to do it. Turns out the bug I mentioned in that post it was my own doing. When I wanted to test Grav as my blog, I installed it through Softaculous and I turned on auto update. That’s why my Bludit installation kept being overwritten by Grav.

So I fix that, and upon further investigation, I found Bludit on Softaculous, which I can import my current installation into it. And through Softaculous, I can set up periodic back-up. Then, this is what’s blowing my mind, I can create a staging copy of it. It basically just making copy to another directory, but it’ll change my current workflow. I do all the needed changes on the staging site, then hit the “Push to Live” button. After a quick test, it’ll spit out an error, but it still works.

The only downside I’ve seen is that the analytics on live site is overwritten by the one on the Staging site. I don’t really care about that. If I want to be creepy and track everyone that come to this site I just use Google’s analytics, but I really don’t care about analytics at this point.