View URLRequest+MultipartFormData.swift
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
// Public domain - https://gist.github.com/nolanw/dff7cc5d5570b030d6ba385698348b7c | |
import Foundation | |
extension URLRequest { | |
/** | |
Configures the URL request for `multipart/form-data`. The request's `httpBody` is set, and a value is set for the HTTP header field `Content-Type`. | |
- Parameter parameters: The form data to set. |
View doss.sh
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
#!/bin/bash | |
# | |
# This macOS bash script helps you initialize a new Shadowsocks server with doctl in seconds. | |
# Original author: lexrus https://github.com/lexrus | |
# | |
# You can get $100 free credit for create VPS in DigitalOcean with my referral link: | |
# https://m.do.co/c/3eb5cf371fc9 | |
# | |
# Please intall and authorize doctl before running this script. | |
# https://github.com/digitalocean/doctl |
View naive_cam.py
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 picamera | |
from time import sleep | |
import datetime as dt | |
camera = picamera.PiCamera(resolution=(1024, 640), framerate=15) | |
camera.start_preview() | |
sleep(2) | |
camera.annotate_background = picamera.Color('black') | |
camera.annotate_text = dt.datetime.now().strftime('%Y-%m-%d %H:%M:%S') |
View delete_all_imessage_conversations.applescript
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
# System Preferences -> Accessibility -> Display -> Reduce motion | |
tell application "Messages" to activate | |
tell application "Messages" | |
set chatCount to (count of chats) | |
end tell | |
tell application "System Events" | |
tell process "Messages" |
View ForkWeeklyReport.sh
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
cd $path | |
DATE=`date -v-6d +"%Y-%m-%d"` | |
AUTHOR=`git config user.name` | |
LOG=`git log --branches --pretty=format:"\n%ad: %s" --date=short --after=$DATE --author="$AUTHOR"` | |
CHANGES=`git log --branches --date=short --after=$DATE --author="$AUTHOR" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "本周贡献代码: +%s行, -%s行, 总行数: %s\n", add, subs, loc }' -` | |
WEEKSTART=`date -v"monday" +"%-m月%d"` | |
TODAY=`date +"%-m月%d"` | |
REPORT="【周报】$WEEKSTART ~ $TODAY \n\n$CHANGES\n$LOG\n" |
View ToggleHDRCatalina.applescript
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 "System Preferences" | |
activate | |
end tell | |
tell application "System Events" | |
tell process "System Preferences" | |
activate | |
delay 1 | |
click menu item "Displays" of menu "View" of menu bar 1 | |
delay 1 |
View createml.swift
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 Cocoa | |
import CreateML | |
let 双色球神算子 = try MLTextClassifier(trainingData: [ | |
"中奖啦": [ | |
"09 11 14 20 27 30 09", | |
"02 09 14 15 16 23 10", | |
"11 16 19 22 25 30 08", | |
"02 05 06 13 16 19 03", | |
"04 09 15 16 19 27 10", |
View CandleChart.swift
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 UIKit | |
import PlaygroundSupport | |
let chartData: [Double] = [1, 2, 4, 0, 0, 2, 6, 0, 4, 8, 12, 14, 1, 2, 2, 0, 0, 1, 6, 0, 4, 0, 3, 0] | |
class TimelineCandleChart: UIView { | |
var data: [Double] = [] { | |
didSet { setNeedsDisplay() } | |
} |
View RxTextFieldDelegateProxy.swift
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
// | |
// RxTextFieldDelegateProxy.swift | |
// | |
// Created by Lex Tang on 2/14/18. | |
// Copyright © 2018 Krunoslav Zaher. All rights reserved. | |
// | |
import RxSwift | |
import RxCocoa |
View update_settings_version.sh
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
#!/bin/bash | |
PLISTBUDDY="/usr/libexec/PlistBuddy" | |
INFO_PLIST="$CODESIGNING_FOLDER_PATH/Info.plist" | |
SETTINGS_PLIST="$CODESIGNING_FOLDER_PATH/Settings.bundle/Root.plist" | |
VERSION_NUMBER="`$PLISTBUDDY -c \"Print CFBundleShortVersionString\" \"$INFO_PLIST\"`" | |
BUILD_NUMBER="`$PLISTBUDDY -c \"Print CFBundleVersion\" \"$INFO_PLIST\"`" | |
VERSION="Version $VERSION_NUMBER ($BUILD_NUMBER)" | |
GROUP_INDEX="`xmllint --xpath \"count(//array/dict)-1\" \"$SETTINGS_PLIST\"`" | |
$PLISTBUDDY -c "Set :PreferenceSpecifiers:$GROUP_INDEX:Title '$VERSION'" "$SETTINGS_PLIST" |
NewerOlder