Skip to content

Instantly share code, notes, and snippets.

View kittisak-phetrungnapha's full-sized avatar
:octocat:

Kittisak Phetrungnapha kittisak-phetrungnapha

:octocat:
View GitHub Profile
@DejanEnspyra
DejanEnspyra / Obfuscator.swift
Created May 31, 2017 17:51
Obfuscation of hard-coded security-sensitive strings.
//
// Obfuscator.swift
//
// Created by Dejan Atanasov on 2017-05-31.
//
import Foundation
class Obfuscator: AnyObject {
@stinger
stinger / Swift3Dates.swift
Last active May 21, 2018 02:04
Swift 3: Working with dates
//: # Swift 3: Working with dates
import Foundation
let date = Date()
let myLocale = Locale(identifier: "bg_BG")
//: ### Setting an application-wide `TimeZone`
//: Notice how we use if-let in case the abbreviation is wrong. It will fallback to the default timezone in that case.
if let myTimezone = TimeZone(abbreviation: "EEST") {
print("\(myTimezone.identifier)")
@kittisak-phetrungnapha
kittisak-phetrungnapha / DeviceUID.m
Last active April 7, 2016 03:32 — forked from miguelcma/DeviceUID.m
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m
@Thunderbird7
Thunderbird7 / RegExHelper.Swift
Created March 8, 2016 03:45
Regular Expression helper in Swift 2 / match, replace with your pattern!
//
// Regex.swift
// Jitta
//
// Created by Yuttana Kungwon on 3/6/2559 BE.
// Copyright © 2559 Jitta Company. All rights reserved.
//
import Foundation
@Thunderbird7
Thunderbird7 / TestURLConnection.m
Last active November 24, 2015 17:43
Test case example to test response of an asynchronous networking request with XCTestExpectation APIs
- (void)testAsynchronousURLConnection {
// Create request
NSURL *URL = [NSURL URLWithString:@"http://httpbin.org/get"];
NSString *description = [NSString stringWithFormat:@"GET %@", URL];
XCTestExpectation *expectation = [self expectationWithDescription:description];
NSURLSession *session = [NSURLSession sharedSession];
@mchirico
mchirico / twotableviewsInOneView.swift
Last active June 5, 2023 08:47
Creating multiple tableViews in one ViewController...this just starts out as a view controller
//
// ViewController.swift
// Delete
//
// Created by Mike Chirico on 10/21/15.
// Copyright © 2015 Mike Chirico. All rights reserved.
//
import UIKit
@Thunderbird7
Thunderbird7 / AbbreviateNumber.swift
Last active December 27, 2018 15:54
[Swift] Abbreviate number class, such as number of 1500 convert to 1.5k
func abbreviateNumber(num: NSNumber) -> String {
// less than 1000, no abbreviation
if num < 1000 {
return "\(num)"
}
// less than 1 million, abbreviate to thousands
if num < 1000000 {
var n = Double(num);
n = Double( floor(n/100)/10 )
@miguelcma
miguelcma / DeviceUID.m
Created May 25, 2015 15:09
iOS Unique Device ID that persists between app reinstalls
/* DeviceUID.h
#import <Foundation/Foundation.h>
@interface DeviceUID : NSObject
+ (NSString *)uid;
@end
*/
// Device.m
@alexfu
alexfu / DividerItemDecoration.java
Last active February 9, 2023 05:09
An ItemDecoration that draws dividers between items. Pulled from Android support demos.
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@staltz
staltz / introrx.md
Last active June 18, 2025 06:22
The introduction to Reactive Programming you've been missing