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 / 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
@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 / 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 / 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 / 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 / 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 / ProxyTest.java
Created December 19, 2016 00:21
Selenium Driver take screenshot
driver.manage().window().setSize(new Dimension(1920,1080));
driver.get("http://adultimages.org");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("./screenshot.png"));
driver.close();
@kasimok
kasimok / Util.java
Created December 14, 2016 02:27
Method to verify if a string is legal base64 encoded
/**
* Check if valid BASE64 String.
* @param value
* @return
*/
public static boolean checkIfValidBase64(String value){
return value.matches("^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{4}|[A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)$");
}
@kasimok
kasimok / pom.xml
Created December 9, 2016 07:45
Maven make runnable Jar and copy depencies
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
@kasimok
kasimok / .gitignore
Created June 24, 2016 07:07
The gitignore file for intellij projects.
# Created by .ignore support plugin (hsz.mobi)
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
## All items under idea folder
.idea/
# User-specific stuff:
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries