Skip to content

Instantly share code, notes, and snippets.

View kasimok's full-sized avatar
💭
Moving to AI

kakaiikaka kasimok

💭
Moving to AI
View GitHub Profile
@kasimok
kasimok / IspController.java
Created January 13, 2017 07:51
Spring resttemplate with timeout and accept all certificate(ignore ssl error)
@Autowired
RestTemplate restTemplate;
@Bean
public RestTemplate restTemplate() {
return new RestTemplate(clientHttpRequestFactory());
}
private ClientHttpRequestFactory clientHttpRequestFactory() {
@kasimok
kasimok / human_readables.swift
Created March 7, 2017 08:05
get human readable disk size in swift.
/**
* Get the human readable size String according to total bytes.
*/
func uInt64ToHumanReadable(input: Int64, bBinary: Bool) -> String! {
let unit:Int64 = bBinary ? 1024 : 1000;
if input < unit { return String(describing: input)+" B"; }
let exp:Int = Int(log(Double(input)) / log(Double(unit)));
let units: String = (bBinary ? "KMGTPE": "kMGTPE");
let startIndex = units.index(units.startIndex, offsetBy: exp-1);
let endIndex = units.index(units.startIndex, offsetBy: exp-1);
@kasimok
kasimok / ViewController.Swift
Created September 5, 2017 03:05
Blur effect like iOS's facetime.
class ViewController: UIViewController {
var previewView : UIView!;
var blurView: UIVisualEffectView!;
//Camera Capture requiered properties
var videoDataOutput: AVCaptureVideoDataOutput!
var videoDataOutputQueue: DispatchQueue!
var previewLayer:AVCaptureVideoPreviewLayer!
@kasimok
kasimok / levenshtein.swift
Created January 3, 2018 09:33 — forked from bgreenlee/levenshtein.swift
Levenshtein Distance in Swift
/**
* Levenshtein edit distance calculator
* Usage: levenstein <string> <string>
*
* To compile:
* sudo xcode-select -switch /Applications/Xcode6-Beta.app/Contents/Developer
* xcrun swift -sdk $(xcrun --show-sdk-path --sdk macosx) levenshtein.swift
*/
import Foundation
@kasimok
kasimok / KeychainService.swift
Created November 11, 2020 11:06 — forked from alexbosworth/KeychainService.swift
Swift Keychain Class
import UIKit
import Security
let serviceIdentifier = "com.company"
let accessGroup = "com.company.app"
let kSecClassValue = kSecClass as NSString
let kSecAttrAccountValue = kSecAttrAccount as NSString
let kSecValueDataValue = kSecValueData as NSString
let kSecClassGenericPasswordValue = kSecClassGenericPassword as NSString
@kasimok
kasimok / CalculatorView.swift
Last active March 8, 2022 00:54 — forked from natecook1000/CalculatorView.swift
An IBInspectable Calculator Construction Set
// CalculatorView.swift
// as seen in http://nshipster.com/ibinspectable-ibdesignable/
//
// (c) 2015 Nate Cook, licensed under the MIT license
import UIKit
/// The alignment for drawing an String inside a bounding rectangle.
enum NCStringAlignment {
case LeftTop