Skip to content

Instantly share code, notes, and snippets.

View toshi0383's full-sized avatar
🏠
Working from home

Toshihiro Suzuki toshi0383

🏠
Working from home
  • Tokyo
View GitHub Profile
package main
import (
"bufio"
"fmt"
"log"
"os"
)
func main() {
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),
]
}
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.
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",
tell application "Xcode" to activate
tell application "System Events"
keystroke "u" using command down
end tell
@toshi0383
toshi0383 / chrome_tabs.osa
Created July 6, 2018 06:24 — forked from samyk/chrome_tabs.osa
applescript to show all url+titles of Chrome tabs along with front window+tab url+title
# 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
@toshi0383
toshi0383 / main.swift
Last active June 26, 2018 23:22
find file sizes in given directory
import Foundation
var fm: FileManager {
return .default
}
/// 指定されたディレクトリ以下のファイルサイズ合計を求める.
/// サブディレクトリ以下も再帰的に調べる.
/// 加算するメタデータ値はtotalFileAllocatedSize.
func findSize(at directoryPath: String) -> Int64? {
@toshi0383
toshi0383 / CodePiece.sh
Created February 1, 2018 21:51
Swiftのコンパイル時間tip。これだけで10倍違う。この書き方のexpectが10個あるだけで1秒かかるってことか。まあ1行で書きたいけどなー。 #CodePiece
// 100ms to compile
expect(userDefaults[.intKey]) == 3
// 5-15ms to compile
let int: Int = userDefaults[.intKey]
expect(int) == 3
//: 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
@toshi0383
toshi0383 / CodePiece.sh
Created August 26, 2017 06:19
懲りずにSwiftで失礼します。。 #CodePiece #シェル芸
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