Skip to content

Instantly share code, notes, and snippets.

View eiwaithein's full-sized avatar
:octocat:

Ei Wai eiwaithein

:octocat:
  • United States
View GitHub Profile
@eiwaithein
eiwaithein / aws-certification.md
Created March 6, 2018 10:13 — forked from miglen/aws-certification.md
AWS Certification guide and notes on how to prepare for the aws associate certification architect, sysops and developer exams


AWS Certification notes

Those are my personal notes on AWS Solution Architect certification preparation. Hope you find them usefull.

To pass AWS certification, you should have:

  • Sound knowledge about most of the AWS services ( EC2, VPC, RDS, Cloudfront, S3, Route53 etc,)
  • Hands on experience with AWS services.
@eiwaithein
eiwaithein / errorHandling.js
Created February 18, 2018 07:01
Error Handling NodeJS
// error handling middleware
const env = process.env.NODE_ENV || 'development'
function errorHandler(err, req, res, next) {
res.statusCode = 500;
switch (env) {
case 'development':
console.error('Error');
console.error(err);
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify(err));
@eiwaithein
eiwaithein / notificationObserver.swift
Created February 9, 2017 12:38
SWIFT : Notification observer
// send (Post) notification
NotificationCenter.default.post(name: Notification.Name("NotificationIdentifier"), object: nil)
// receive (get) notification
NotificationCenter.default.addObserver(self, selector: #selector(YourClassName.methodOfReceivedNotification(notification:)), name: Notification.Name("NotificationIdentifier"), object: nil)
// method handler for notification
func methodOfReceivedNotification(notification: Notification){
//Take Action on Notification
}
@eiwaithein
eiwaithein / tableviewUtilities.swift
Last active March 29, 2017 14:56
SWIFT : sample tableview
extension ViewController : UITableViewDelegate {
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: false)
}
func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath? {
if searchResults.count == 0 {
return nil
} else {
@eiwaithein
eiwaithein / SwiftUserLocalNotification.swift
Last active March 29, 2017 14:56
SWIFT : User Local Notification
//1. import and delegate
import UserNotifications
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
//2. asking for permission
let center = UNUserNotificationCenter.current()
center.requestAuthorization(options: [.alert, .sound]) {
granted,error in
if granted {
print("we have permission")
@eiwaithein
eiwaithein / callingSegue.swift
Created February 8, 2017 10:07
SWIFT : Calling Segue to go to next screen and passing parameter for next screen.
// 1. to call segue go to next screen.
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ShowChecklist" {
let controller = segue.destination as! ChecklistViewController
controller.checklist = sender as! Checklist // passing variable for next view via sender.
} else if segue.identifier == "AddChecklist" {
let navigationController = segue.destination as! UINavigationController
@eiwaithein
eiwaithein / userDefault.swift
Created February 8, 2017 09:43
SWIFT : UserDefaults Usage
//1. store in UserDefaults
let defaults = UserDefaults.standard
defaults.set(25, forKey: "age")
defaults.set(true, forKey: "isUsedTouchID")
defaults.setValue("Ei Wai", forKey: "Name")
//2. retrieve from UserDefaults
let age = defaults.integer(forKey: "age")
let useTouchID = defaults.bool(forKey: "isUsedTouchID")
let name = defaults.string(forKey: "Name")
@eiwaithein
eiwaithein / SwiftUtilities1.swift
Created February 8, 2017 08:14
SWIFT : Saving Items in Plist and Loading Data from Plist.
var items : [ChecklistItem] = []
// for saving.
func documentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
return paths[0]
}
func dataFilePath() -> URL {
@eiwaithein
eiwaithein / SwiftUtilities.swift
Last active February 8, 2017 13:11
SWIFT : Load Html Content and Render in UIWebView
func loadWebViewContent(){
if let url = Bundle.main.url(forResource: "fileName", withExtension: "html") {
if let htmlData = try? Data(contentsOf: url) {
let baseURL = URL(fileURLWithPath: Bundle.main.bundlePath)
webView.load(htmlData, mimeType: "text/html", textEncodingName: "UTF-8", baseURL: baseURL)
}
}
@eiwaithein
eiwaithein / pulseanimation
Created November 9, 2015 06:29
Create Pulse With Transform Animation
self.view.backgroundColor = [UIColor redColor];
CABasicAnimation *theAnimation;
theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];
theAnimation.duration=0.7;
theAnimation.repeatCount=HUGE_VALF;
theAnimation.autoreverses=YES;
theAnimation.fromValue=[NSNumber numberWithFloat:1.0];
theAnimation.toValue=[NSNumber numberWithFloat:0.7];
theAnimation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
[self.view.layer addAnimation:theAnimation forKey:@"animateOpacity"];