Skip to content

Instantly share code, notes, and snippets.

View svetlanama's full-sized avatar

Svitlana Moiseyenko svetlanama

View GitHub Profile
@svetlanama
svetlanama / GrowingSpeed.playground
Last active May 23, 2016 22:04
To define which function works faster log or sqrt is to observe their growing speed
import UIKit
import Foundation
/*
How to define which function works faster log or sqrt
The best way is to caclulate their growing
*/
//Define the growing of function logarithm
func logWithBase(base: Double, n: Double) -> Double {
// Apply mask to credit card number
func applyMask(number: String) -> String {
let mask = "%2A%2A%2A+%2A%2A%2A%2A+%2A%2A%2A%2A+"
let startIndex = number.startIndex
let range = startIndex.advancedBy(1) ..< number.endIndex.advancedBy(-4)
let substring = number.substringWithRange(range)
let replacedWithMask = number.stringByReplacingOccurrencesOfString(substring, withString: mask)
return replacedWithMask
@svetlanama
svetlanama / float_point_values_computation.playground
Last active December 7, 2016 11:06
Float Point Values Computation
import UIKit
let a = 1e+30
let b = -1e+30
let c = 1.0
let sum1 = (a + b) + c
let sum2 = a + (b + c)
//Representation of floating point value according to IEEE 754
@svetlanama
svetlanama / output.xml
Created February 11, 2017 17:45
StanfordCoreNLP ganerated .xml of Annotation
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="CoreNLP-to-HTML.xsl" type="text/xsl"?>
<root>
<document>
<sentences>
<sentence id="1">
<tokens>
<token id="1">
<word>Quantum</word>
<lemma>Quantum</lemma>
@svetlanama
svetlanama / gist:9201b11dfc7ed7df1d2e1ebdb5580667
Created December 10, 2017 16:05
Return completionCallback after completing internal callbacks
private func initView(completionCallback: (() -> ())? = nil) {
var callbacksLeft = 2
func checkCompleted() {
callbacksLeft -= 1
if callbacksLeft == 0 {
completionCallback?()
}
}
import Foundation
import UIKit
class UIAnimatedTitleView: UIView {
private var label = UILabel()
var text: String = "" {
didSet {
label.text = text
label.textColor = UIColor.black
@svetlanama
svetlanama / OperationQueue
Created October 18, 2018 00:02
OperationQueue
var testQueue: OperationQueue = {
var queue = OperationQueue()
queue.name = "Test queue"
queue.maxConcurrentOperationCount = 1
return queue
}()
for i in 0...200 {
@svetlanama
svetlanama / gist:fa09d31df68ab0c4d5fe942954b8f818
Last active April 30, 2019 13:14
Gas relay (tests example)
var tabookey = require('tabookey-gasless');
// step0
const gasPricePercent = 20
relay_client_config = {
txfee: 12,
force_gasPrice: 2000000000, //override requested gas price
force_gasLimit: 4000029, //override requested gas limit.
verbose: process.env.DEBUG
}
var dataCallbacksLeft = data.count
func checkDataCompleted() {
dataCallbacksLeft -= 1
if dataCallbacksLeft == 0 {
// Call major next actions
}
}
asyncFunc() {
// Decode LogNote
// https://github.com/makerdao/dss/blob/6fa55812a5fcfcfa325ad4d9a4d0ca4033c38cab/src/lib.sol
// ethers@4
const logNoteAbi = [
{
inputs: [
{ indexed: true, name: 'sig', type: 'bytes4' },
{ indexed: true, name: 'usr', type: 'address' },
{ indexed: true, name: 'arg1', type: 'bytes32' },