#Blog

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.

CSS Hex Code Colors With Alpha Values

by

I use hex codes for color values - most of the part in my css than rgb or color name. We have limited named colors in css hence less color palette to work with so I generally don’t use them much frequently.

In rgb we have colors made of Red Green Blue channels. Values of each channel range from 0 to 255. In hex code, each digit contain values ranging from 0 - 9 and A - F - total 16 values. To represent each color channel we have two digit per channel that can provides us 256 combination of values.

Example:
FF is 240(15 * 161) + 15(15 * 160) = 255 (White)

Now we have #RRGGBB - two digit hex for each color channels.

CONTINUE READING


How to add social icons in Shopify programmatically?

by

We will add social media icons or buttons programmatically in html code of theme in Shopify. We are using free Debut theme. Our Debut theme does come with built-in most of the social icons. We will not be adding or uploading icon image files of our own. We will play with basic code and templating in Shopify.

The built-in social icons are all svg. We are glad they are svg. They are vector so works fluidly when adapting to any size we want it to be. It is very easy to customise the tint color by css or code. We don’t need separate image files for different colors or such. It is widely supported by all modern browsers.

All major files we work with are liquid files. Our whole theme customisation structure is built around Shopify’s liquid templating language that lets us work with all variables and objects to re-use without any heavy lifting work. Our built-in social media icons are in liquid files, which we will shortly see.

CONTINUE READING


MFMessageComposeViewController shows blank white screen issue

by

We use an MFMessageComposeViewController object to display the standard message composition interface in order to send text messages in our app. Properties of MFMessageComposeViewController lets us populate pre-defined recipients and body message before presenting the interface.

Simple code to create and present MFMessageComposeViewController is:

            
if([MFMessageComposeViewController canSendText]){
    MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
    picker.messageComposeDelegate = self;
    picker.recipients =@[“1234”];
    picker.body = @“pre-defined message”;
    [self presentViewController:picker animated:YES completion:nil];
}
else{
    NSLog(@“Cannot send text”);
}
            
            
            
if MFMessageComposeViewController.canSendText() {
    let picker = MFMessageComposeViewController()
    picker.messageComposeDelegate = self;
    picker.recipients =[“1234”];
    picker.body = “pre-defined message”;
    self.present(picker, animated: true, completion: nil)
}
else{
    print(“Cannot send text”);
}
            
            

Not so distant, I had stumbled upon a very silly mistake that caused an MFMessageComposeViewController to show blank after presenting.

CONTINUE READING


How to add social links programmatically from theme settings in Shopify

by

In visual editor of our basic free theme called Debut, we have feature to edit the information of social links that we want to use. This feature is in the social media settings inside theme settings of customisation.

When you save it. The value gets saved inside themes built-in settings liquid object. In our example here we are referring to Instagram link. Now for example if we are using Instagram url in our website in multiple places and with some custom layouts. Instead of copy pasting Instagram url into places, it would be much better if it was accessible from single liquid object. If in future Instagram link changes in one global place then it automatically updates throughout the website. This is just an example case scenario here and this can be used in many other situations.


CONTINUE READING


Nepal - Winter hiking and cooking in hail storm.

by

January mostly is the coldest month in Nepal. This year we received heavy and lasting snowfall in mountains. The hills where snowfall is not frequent and rare were covered under white blanket. I planned a winter hike and outdoor cooking trip in Arghakhanchi district - to a small village Darakateri. There is an observation point surrounded by forest at the peak which was our destination.

I made a stop at my cousin’s place who lives in beautiful village Amlabas in Palpa district. Amlabas is some 30 KM away from Arghakhanchi district. Rain started pouring in noon. Generally it is a good indication for the weather next morning because it could become clear of haze and we have a perfect view of Mt Dhaulagiri. By evening rain had stopped and our decision to ride in motorcycle to Darakateri village was confirmed. We would stay a night in Darakateri and early morning we would start our hike to the peak. Late evening when sun did set half an hour ago we reached Darakateri village. It was freezing cold. We sat around wood fire and enjoyed the basking in heat to warm our bodies. After dinner we tucked in our bed early for our next morning.

CONTINUE READING


Trekking Swargadwari in lesser Himalayas of Nepal.

by

I see the sleeping giants wrapped under red tint of blanket that covered the skyline. Birds with their beautiful chirps tries to awake them from night’s slumber. At home I never feel such peace running through my body. I kept watching at the horizon until red blanket spread by sun melted away into sparking cool blue hue.

At 2100 meters elevation above Swargadwari is located in Pyuthan District of Nepal. Swargadwari in English literally means “Door to Heaven”. In epic Mahabharata, Pandavas supposedly worshipped here before departing to heaven. This is a holy site in Hinduism and Hindu pilgrims from local and India frequently comes here every year.

CONTINUE READING


Ghandruk Trek 2 Days: A Short Beautiful Hiking Trail in Nepal

by

Ghandruk Trek. A short beautiful hiking trail in Kaski district of Nepal that we completed in 2 days. We hiked a loop starting at Syaulibazar then Ghandruk to Australian Camp through Landruk. Last week I had an opportunity to visit Kaski District and made a plan to do a short hiking of Ghandruk during my short leave. I had total 4 days and had to be back home on the 4th day. That left me with 2 days of hiking. I made a plan to hike small section of Ghandruk loop trail that starts from Syaulibazar and ends in Kande after Australian camp. Ghandruk loop trek is very short beautiful trail in Nepal on foothills of Annapurna range. My cousin tagged along.

Here we go.

  • How tough is the Ghandruk Trek?
  • What should I carry on Ghandruk Trek?
  • How is food quality at tea houses on Ghandruk Trek trail?
  • How is Hygiene and Sanitation on Ghandruk Trek?
  • Do I need a guide for Ghandruk Trek?
  • Can I get altitude sickness at Ghandruk Trek?

CONTINUE READING


Show search button on safari keyboard in html

by

While working with search input in html form I came across steps of information that helped me manipulate iOS keypad. What do I mean by manipulating iOS keypad? It doesn’t mean changing anything about core physical appearance or device capability of software keyboard or device.

I have three requirements for when keypad is up when html input element is active:
  • Search should be the text over return/action button
  • When I press Search on keypad then action should take place or some event should fire off without redirecting or refreshing the page.
  • Lastly when I press ‘Search’ then keypad should also go down or dismissed.

CONTINUE READING


AVAudioPlayer not playing any sound

by

The most common culprit causing AVAudioPlayer not playing sound is ARC. When my audio player's scope is just within a function ARC deallocates the memory before playing sound after function is called. Here is an example code:


func playSoundEffect(assetName: string?) {
    if let sound = assetName{
        if let asset = NSDataAsset(name:sound){
            
            do {
                // Use NSDataAsset's data property to access the audio file stored in Sound.
                let soundEffect = try AVAudioPlayer(data:asset.data, fileTypeHint:"wav")
                // Play the above sound file.
                soundEffect?.play()
            } catch let error as NSError {
                print(error.localizedDescription)
            }
        }
    }
}

CONTINUE READING


Use AVAudioPlayer to play sound effects

by

Right now I am at the stage where I am writing foundation to manage my sound effects and background music for my upcoming game. I found two most popular way to play sound effects in SpriteKit:

  • SKAction
  • AVAudioPlayer

After using both I found myself more flexible and comfortable with AVAudioPlayer for following reasons that I am grabbing from Apple’s documentation but it helds true:

Using an audio player you can:
  • Play sounds of any duration
  • Play sounds from files or memory buffers
  • Loop sounds
  • Play multiple sounds simultaneously, one sound per audio player, with precise synchronization
  • Control relative playback level, stereo positioning, and playback rate for each sound you are playing
  • Seek to a particular point in a sound file, which supports such application features as fast forward and rewind
  • Obtain data you can use for playback-level metering
CONTINUE READING


Recommended posts