This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"log" | |
"os" | |
) | |
func main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import XCTest | |
@testable import RxSmartThrottle | |
final class RxSmartThrottleTests: XCTestCase { | |
static var allTests = [ | |
("test_Throttle__customInterval__ExponentialBackoff", test_Throttle__customInterval__ExponentialBackoff), | |
("test_Throttle__customInterval__latest__false", test_Throttle__customInterval__latest__false), | |
("test_Throttle__customInterval__throttleUntil", test_Throttle__customInterval__throttleUntil), | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
import RxSwift | |
extension ObservableType { | |
/** | |
Returns an Observable that emits the first and the latest item emitted by the source Observable during sequential time windows of a specified duration. | |
This operator makes sure that no two elements are emitted in less then each consulted dueTime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// script to retrieve these file extensions. | |
// | |
// (for i in $(/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -dump | grep ' \.[a-zA-Z][a-zA-Z]*' | sed -n 's/.*: *\(.*\)/\1/p' | sort | uniq | sed "s,[ '],,g" | sed 's/,/ /g'); do echo $i; done) | grep '^\.' | grep -v '^\.\.*$' | sort | uniq | sed 's/\(.*\)/"\1",/' | |
// | |
let allFileExtensions = [ | |
"3gp", | |
"3gpp", | |
"Mac", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tell application "Xcode" to activate | |
tell application "System Events" | |
keystroke "u" using command down | |
end tell |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shows all url+titles of Chrome along with front window+tab url+title | |
set titleString to "" | |
tell application "Google Chrome" | |
set window_list to every window # get the windows | |
repeat with the_window in window_list # for every window | |
set tab_list to every tab in the_window # get the tabs | |
repeat with the_tab in tab_list # for every tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
var fm: FileManager { | |
return .default | |
} | |
/// 指定されたディレクトリ以下のファイルサイズ合計を求める. | |
/// サブディレクトリ以下も再帰的に調べる. | |
/// 加算するメタデータ値はtotalFileAllocatedSize. | |
func findSize(at directoryPath: String) -> Int64? { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 100ms to compile | |
expect(userDefaults[.intKey]) == 3 | |
// 5-15ms to compile | |
let int: Int = userDefaults[.intKey] | |
expect(int) == 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//: Playground - noun: a place where people can play | |
// Vertical and Horizontal alpha view demo | |
// Xcode9 required | |
import UIKit | |
do { | |
let v = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 500)) | |
v.backgroundColor = .clear | |
let horizontalGradientLayer = CAGradientLayer() | |
horizontalGradientLayer.frame = v.frame |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo 'print((0...20).map { Int($0) }.reduce([]) { (acc: [Int], e: Int) -> [Int] in acc.count < 2 ? acc + [e] : acc + [acc.last! + acc[acc.count-2]] }.filter { $0 <= 6765 }.dropLast().dropLast().dropLast().last!)' | swift |