Blog articles on programming and problems focused on iOS and some web. I also write stories on my travel and hiking pursuits outside my work.

Adding two numbers in macOS x86-64 Assembly - Part 2


This is the second part as continuation of series “My first x86-64 assembly in macOS”. Please read first part to view assembly language programming from the perspective of total beginner. I thought simple addition of two numbers in assembly could be the next simple step in progress to learn assembly language programming, covering declaration of variable(kinda), accessing them, adding them and printing them. Hoping to give some more insights on assembly language programming adventure. This post follows same spirit of exploring the findings and observation through perspective of total beginner. If any information provided seems wrong please email me with explanation so I could understand and rectify. Most of the concepts we did explored in first part of the series but I will try to do very short brief here too.

I am using Intel based Mac running Catalina. In future when arm based Mac comes out, then this series may need to be interpreted separately. I am using AT&T syntax throughout the series.

Important Note:

Following assembly code may not be optimised. This assembly code to calculate the sum of numbers is for simple learning of following concepts:
  • Declare and Initialise variables in assembly.
  • Access variables in assembly.
  • Perform addition on variables in assembly.
  • Print the sum of variables in assembly.

Let’s start


English Names of Nepali Fruits


List of Fruits name in nepali and english


How To Recover Password in Raspberry Pi


It has been 2 years since I worked on my raspberry pi. I was making an attempt to connect my raspberry pi from macbook via SSH.

ssh pi@192.168.x.x

It asked for password to connect and well…I don’t remember Password of raspberry pi anymore.

The default password on Raspberry Pi OS is raspberry. During fresh installation 2 years ago when I was enabling ssh I had changed default to my own password.

Please Note: I am using Jessie. The following instructions may not be valid anymore for newer version.

I tried the pi configuration utility tool. It allows you to change the password. But it also requires you to input current password to continue. It takes me back to start of the problem. After searching through various helpful instructions in forums I stumbled into very easy solution that didn’t require me to eject my SD Card, plug it in different computer and do change in files etc.


How to Send Local Video to iMessage in Swift


This post assumes we have understanding about exporting to mp4 video. The use case example of the discussion exports a video and save it locally inside app’s folder: Document, Cache or Temporary. In my case I am doing some very basic composing of video and saving it to my temporary folder. I want to send this video or share it to my contacts through iMessage or MFMessageComposeViewController. Below is a brief idea on how I am exporting to mp4 video that saves in app’s temporary folder.

let exportURL = URL(fileURLWithPath: NSTemporaryDirectory())
export.outputFileType = .mp4
export.outputURL = exportURL

export.exportAsynchronously {
  DispatchQueue.main.async {
    switch export.status {
    case .completed:
      print("Something went wrong during export.")
      print(export.error ?? "unknown error")

Now, I found 2 easy effective ways to share or attach video to iMessage or MFMessageComposeViewController.


How to get Deprecated keyWindow in Swift


Note: Discussion in this post assumes we are considering single window based scenario.

Sometimes I need to access the main window of my app to add some temporary views to it - making it appear forefront no matter at what depth of user’s navigation-flow I am in.

From old days of single window based app we have been using very convenient property handed to us: keyWindow

This property holds the UIWindow object in the windows array that is most recently sent the makeKeyAndVisible() message.

guard let window = UIApplication.shared.keyWindow else {return}

It has been long time. Now this has been deprecated from iOS 13 onwards.

We have our windows accessible from windows array:

let window = UIApplication.shared.windows[0]

A free assumption would be that first window in array would be the main window of the app - being the root. We want the root window so that any view being added be directly on top for our given purpose here. It worked good until unexpected happened. First object did not give UIWindow but UITextEffectsWindow. I could not add my view on the top anymore - adding to UITextEffectsWindow didn’t work for curiosity.


How to Display Image in SKShapeNode


I have been using SKShapeNode extensively to draw quick graphics by filling them with CGPaths for quick visual debugging and making prototypes. For example I can create procedural mountains quickly with SKShapeNode. In early times of spritekit SKShapeNode didn’t have way to render images on it. We have fillTexture available now that allows texture to fill the shape.

let shapeNode = SKShapeNode()
shapeNode.fillTexture = SKTexture(imageNamed: “testImage")

But, Our SKShapeNode is displaying nothing.

Why is that?


App crashing when saving photos from WKWebView


I stumbled upon a crash in my app. In my app I have a WKWebView that lets user access web. I tried saving image from a website by long pressing - general way we do in our iOS safari - and app crashed. This user experience behaviour of long pressing and saving image is very common.

The crash error is:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app’s Info.plist must contain an NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.


UIImagepicker controller allowsEditing not working


Using native image picker system is easy and solves everyday basic needs of most apps.

A view controller that manages the system interfaces for taking pictures, recording movies, and choosing items from the user’s media library.

Here is an example code that lets user pick images from photo library:

pickerController = UIImagePickerController()
pickerController?.delegate = self
pickerController?.mediaTypes = [“public.image”]
pickerController?.sourceType = .photoLibrary
self.present(pickerController!, animated: true, completion: nil)

We need to implement delegate methods that provides us media info from which we can extract image in our case if available. Here is a code

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
    if let image = info[.originalImage] as? UIImage{

A dictionary containing the original image and the edited image, if an image was picked; or a filesystem URL for the movie, if a movie was picked. The dictionary also contains any relevant editing information. The keys for this dictionary are listed in Editing Information Keys.

Our picked image resides inside the key .originalImage which is optional so if something went wrong then it will be nil.

Now, UIImagePickerController also supports basic crop. To activate crop we set the allowsEditing property to true. By default it is false.


Amanita Caesarea: Hunting Edible Caesar's Mushroom


I went outdoors to forest in hills of Nepal to forage mushrooms and identify them. Monsoon has announced its presence and marks the season for some edible mushrooms from Amanita family to be found in wild. Amanita is tricky family and recommended to avoid by non-experienced mushroom foragers. We were looking for mainly edible Caesar’s Mushrooms or Amanita Caesarea. There are poisonous imposters so be careful and be 100% sure.

I am an inexperienced mushroom forager beginner with no experience in mushroom identification. This marked my first field experience in identifying wild mushrooms. I brought along my mother who has some experience in identifying edible mushrooms - mainly caesar’s mushroom. Right now, Forest is lush green and so fresh like springtime of youth from monsoon rains and making appearances of Amanita mushrooms that is common native to this nearby region during from months of June to August.


How to redirect HTTP to HTTPS in Elastic Beanstalk


I want to configure the web servers on my Elastic Beanstalk environment’s instances to redirect HTTP traffic to HTTPS.

I want to state what my beanstalk environment is:

  • Apache Web Server.
  • PHP 7.3
  • HTTPS listener well configured with certificate

I will use a flexible way to configure my environment using .ebextensions

According to documentation:
You can add AWS Elastic Beanstalk configuration files (.ebextensions) to your web application's source code to configure your environment and customize the AWS resources that it contains. Configuration files are YAML- or JSON-formatted documents with a .config file extension that you place in a folder named .ebextensions and deploy in your application source bundle.

Recommended posts