Skip to content

Instantly share code, notes, and snippets.

View argiad's full-sized avatar

Artem Mkrtchyan argiad

  • Houston, TX
View GitHub Profile
@argiad
argiad / LuhnAlgorithm.swift
Created November 16, 2023 21:45 — forked from lakpa/LuhnAlgorithm.swift
Luhn algorithm in Swift. Check valid credit card numbers
func isValidCreditCardNumber(number: String) -> Bool {
guard !number.isEmpty else { return false }
let revesedString = String(number.characters.reverse())
var oddNumberSum = 0
var evenNumberSum = 0
for index in 0..<revesedString.characters.count {
let digit = Int(String(revesedString[revesedString.startIndex.advancedBy(index)]))!
let pos = index + 1
if pos % 2 == 0 {
@argiad
argiad / Hashable.kt
Created January 17, 2020 00:02
MyHashMap / no subscription
class MyHashMap<T,K>() {
var array: ArrayList<Item<T,K>> = ArrayList()
fun addItem(item: Item<T,K>) {
array.add(item)
}
fun addItem(key: T, value: K) {
array.add(Item<T,K>(key, value))
}
@argiad
argiad / gist:d17707ec0eb9b748e7610ec27f4e6a12
Last active January 17, 2020 00:00
Generic/ Bindable / MVVM Swift
import Foundation
class Bindable<Value> : NSObject {
private var observations = [(Value) -> Bool]()
private var lastValue: Value?
init(_ value: Value? = nil) {
lastValue = value
}
@argiad
argiad / EBLE.kt
Created September 18, 2018 23:48
BLE android kotlin RSA
enum class EBLE {
EBLE_ZERO, // Zero element
EBLE_FLAGS, //«Flags» Bluetooth Core Specification:
EBLE_16BitUUIDInc, //«Incomplete List of 16-bit Service Class UUIDs» Bluetooth Core Specification:
EBLE_16BitUUIDCom, //«Complete List of 16-bit Service Class UUIDs» Bluetooth Core Specification:
EBLE_32BitUUIDInc,//«Incomplete List of 32-bit Service Class UUIDs» Bluetooth Core Specification:
EBLE_32BitUUIDCom,//«Complete List of 32-bit Service Class UUIDs» Bluetooth Core Specification:
EBLE_128BitUUIDInc,//«Incomplete List of 128-bit Service Class UUIDs» Bluetooth Core Specification:
EBLE_128BitUUIDCom,//«Complete List of 128-bit Service Class UUIDs» Bluetooth Core Specification: