Skip to content

Instantly share code, notes, and snippets.

View tomisacat's full-sized avatar
🤯

tomisacat tomisacat

🤯
  • Shanghai, China
View GitHub Profile
@tomisacat
tomisacat / CountDownTimer.swift
Last active November 5, 2021 12:46
A simple count down timer using RxSwift
import RxSwift
func count(from: Int, to: Int, quickStart: Bool) -> Observable<Int> {
return Observable<Int>
.timer(quickStart ? 0 : 1, period: 1, scheduler: MainScheduler.instance)
.take(from - to + 1)
.map { from - $0 }
}
@tomisacat
tomisacat / shadowsocks_setup.sh
Created October 17, 2017 09:30
Convenient script to install and setup shadowsocks with bbr enabled
#!/bin/bash
echo "Usage:"
echo " 1. ./vultr_ss_setup.sh"
echo " 2. ./vultr_ss_setup.sh install"
echo " 3. ./vultr_ss_setup.sh bbr"
if [ $# -lt 1 ]
then
# Start Shadowsocks
@tomisacat
tomisacat / LanDa_New.rb
Last active February 15, 2020 14:27
Process .xls file directly with Ruby. It's a replacement of LanDa.rb
#!/usr/bin/env ruby
require 'csv'
require 'roo'
require 'roo-xls'
Wechat = "微信"
Alipay = "支付宝"
QQpay = "qq钱包"
@tomisacat
tomisacat / LanDa.rb
Created September 4, 2017 06:31
Process .csv file with Ruby
#!/usr/bin/env ruby
require 'csv'
Wechat = "微信"
Alipay = "支付宝"
QQpay = "qq钱包"
# 店铺
class Merchant
@tomisacat
tomisacat / filter_digits.swift
Last active April 6, 2017 14:39
simple illustration of `flatMap` and `reduce` to filter digits from string
let s = "fdsf6fdsf7dsf7s7sdf789sdff9s8fs8df98dfsdsd5fsf"
let r = s.characters.flatMap { Int(String($0)) != nil ? nil : $0 }.reduce("") { $0 + String($1) }
Swift.print(r)
@tomisacat
tomisacat / notify-tm-backup
Created February 10, 2017 08:37 — forked from hazcod/notify-tm-backup
Show a notification when Time Machine backup completes
# Raw command
BACKUP=$(tmutil latestbackup) ; if [ "$(cat ~/.lastbackup 2>/dev/null)" != "$BACKUP" ]; then echo $BACKUP > ~/.lastbackup ; osascript -e "display notification \"$(echo $BACKUP | xargs basename)\" with title \"Backup finished\""; fi
# As cron entry
*/5 * * * * BACKUP=$(tmutil latestbackup 2>/dev/null) ; if [ "$(cat ~/.lastbackup 2>/dev/null)" != "$BACKUP" ]; then echo $BACKUP > ~/.lastbackup ; osascript -e "display notification \"$(echo $BACKUP | xargs basename)\" with title \"Backup finished\""; fi 2>&1 >/dev/null
@tomisacat
tomisacat / .gitconfig
Created December 6, 2016 12:47 — forked from pksunkara/config
Sample of git config file (Example .gitconfig)
[user]
name = Pavan Kumar Sunkara
email = pavan.sss1991@gmail.com
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@tomisacat
tomisacat / bump_build_number_per_build.sh
Created November 23, 2016 10:48
Bump build number of Xcode project automatically
#!/bin/sh
# bump_build_number_per_build.sh
# @desc Automaticvally create build number depend on current time.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
@tomisacat
tomisacat / convert_mp3_to_m4a.rb
Created November 23, 2016 10:30
Convert mp3 to m4a with AAC codec and 128kb/s bitrate.
#!/usr/bin/env ruby
if ARGV.length < 1
puts "Please input file name."
exit
end
mp3_name = ARGV[0] + ""
m4a_name = mp3_name.split(".")[0] + ".m4a"
puts "******************************************"

mach_absolute_time() CACurrentMediaTime() CFAbsoluteTimeGetCurrent()