Skip to content

Instantly share code, notes, and snippets.

View nguyentruongky's full-sized avatar
💻
Code for life.

Ky Nguyen nguyentruongky

💻
Code for life.
View GitHub Profile
struct ogeSystemCalendar {
let eventStore = EKEventStore()
func addEvent(title: String, startDate: Date,
endDate: Date, notes: String?) {
eventStore.requestAccess(to: .event) { (granted, error) in
if granted == false {
DispatchQueue.main.async {
self.tellNoPermission() }
return
let userName = "myUsername"
let password = "myPassword"
let authString = userName + ":" + password
let credentialData = authString.dataUsingEncoding(NSUTF8StringEncoding)!
let base64Credentials = credentialData.base64EncodedStringWithOptions([])
let headers = ["Authorization": "Basic " + base64Credentials]
let url = URL(string: api)!
Alamofire.request(url, method: .post,
parameters: params,
@nguyentruongky
nguyentruongky / UITableViewController_static.md
Created April 13, 2017 05:48
Use UITableViewController static UITableView to solve long long long screen

Use UITableViewController to solve very long screen

Do you have any solutions for long long screen like this? I'm sure have. This kind of screen is very popular in item detail (e-commercial app), room view (booking app)... I have to implement this screen in my class detail from an education app. This is how I did that.

My problem

  • The screen is too long, and too many controls are in every section.
  • Some sections can be missing, for instance, promotion code section is only available for specially class.
  • Some sections contain very complex controls, for instance, UICollectionView the editor's picks in the above photo.
@nguyentruongky
nguyentruongky / tab_controller_fading.swift
Created November 14, 2017 10:56
Fade animation in tab bar controller
func tabBarController(_ tabBarController: UITabBarController, shouldSelect viewController: UIViewController) -> Bool {
animateFading(fromController: selectedViewController, toController: viewController)
return true
}
func animateFading(fromController: UIViewController?, toController: UIViewController?) {
if fromController == nil || toController == fromController { return }
guard let selectView = (selectedViewController as? UINavigationController)?.viewControllers.first?.view,
let newView = (toController as? UINavigationController)?.viewControllers.first?.view else { return }
@nguyentruongky
nguyentruongky / use_most_of_24_hours.md
Last active April 24, 2017 03:52
Tips to save your time and make your code quality become better. This talk is presented in Swift Battle.

Make the Most of Your 24 Hours

Bitter Experience

I started iOS as a 2-year-experience .NET developer. The salary range for a junior iOS dev is a little bit lower than the amount for a 2-year-experience develop get. I wanted to make myself stronger, earn more experience. I had a misconception of working and learning. I thought, freelance projects will help me strengthen my knowledge and experience. So I tried to get as more as possible freelance projects. And my nightmare started from here.

I had no time to spend with my family, no time to work on personal improvement, no time to go out with friends, no time at all. All of my time was used up on my freelance work from coding new features, fixing bugs and much more. I was killing myself working odd hours and missing out on quality time with my family and friends.

I made a mess, uncountable technical debts, bugs, with the project. I was angry with everyone and myself. And the company project was affected. I brought more bugs there, dozens of stupid bug

@nguyentruongky
nguyentruongky / gcd.md
Created April 13, 2017 03:36
A small note about GCD

How can concurrency programming help me?

This post isn't a tutorial, it's only a note. What do I have to remember and understand about concurrency programming. The demo project can be found here

Without concurrency, all tasks run in the main thread, and the app will be freezed when a heavy task is(Eg: downloading, uploading, image processing...) running. So, concurrency can give the users a better experience. The heavy tasks are running in background and they can do anything they want on the UI as usual.

There are 2 concurrency concepts: dispatch queues and NSOperationQueues

GCD - Grand Central Dispatch

GCD conform with the FIFO order. GCD will run tasks in separate queues, not the main queue so that your app won't be freezed. There are 2 dispatch queues: serial queuese and concurrency queues.

Serial Queues

@nguyentruongky
nguyentruongky / Load_controller_dynamically.md
Last active April 13, 2017 03:15
A sample to load controller dynamically into view

Load dynamic view controller into other one

I saw a question on stackoverflow. He ran into a problem when use ContainerView to embed other view controller. I'll share what I did.

  • Create new project.
  • Design what you want. I add a label, a segmented control and a container view to embed child controller.

  • Select all controls and choose menu Editor\Embed In\View. Name it: Content View.
@nguyentruongky
nguyentruongky / Top_skills_iOS_developers_need.md
Created April 12, 2017 21:36
Top Skills iOS Developers Need Today

Top Skills iOS Developers Need Today

We all know that iOS development never stops. There are hundred of skills you need to become a skilled iOS developer in the tech industry today. We got in touch with Ky Nguyen, a skilled iOS developer and technical leader at Fixir. He’s got the inside scoop on what skills are expected of iOS developers today in this ever changing and fast-paced industry.

1. Swift

Swift is a great place to start for all iOS developers. I started learning iOS from C#, and I found out that it was a smooth transition for me. It took me just a short amount of time to work on my first iOS application with my company.

Swift grows quickly and some of the biggest technology companies have migrated to Swift. Most of the iOS developer job descriptions out there require Swift as a top skill.

@nguyentruongky
nguyentruongky / How_to_become_global_it_freelancer.md
Last active April 12, 2017 21:32
4 Tips on How to Become a Global IT Freelancer

4 Tips on How to Become a Global IT Freelancer

Personally, working eight hours a day, five days a week in an office is boring. I love having the freedom to work anytime and anywhere. I have learned many things by having these so-called ‘free days.’ And it all comes with working as an IT freelancer.

Working a nine to five in various positions in application development, such as .NET, iOS, Nodejs, and more was great experience for me but my dream of becoming a full time freelancer never stopped growing. In Vietnam, becoming an IT freelancer is not necessarily the best choice for developers. Due to company’s low budgets for domestic projects these is all too low for the actual cost of living in the country. This is why I decided to become a global IT freelancer. You may wonder what is the difference between an IT freelancer and a global IT freelancer. Well, you guessed it. My work extends far beyond the bo