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
function insertBeforeFirstChinese(string, insertedString) { | |
// cf. https://stackoverflow.com/questions/21109011/javascript-unicode-string-chinese-character-but-no-punctuation | |
const index = string.split("") | |
.findIndex(char => /\p{Script=Han}/u.test(char)) | |
if (index > 0) { | |
string = string.substr(0, index) + insertedString + string.substr(index); | |
} | |
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
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Support\Str; | |
use Illuminate\Http\Request; | |
use Illuminate\Http\Response; | |
// @TIP: Import your CacheService depends on your namespace | |
use App\Service\Cache\CacheService; |
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
<?php | |
namespace App\Service\Cache; | |
use Illuminate\Support\Facades\Cache; | |
final class CacheService | |
{ | |
/** | |
* Is cache has value by given key and tags |
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 SnapKit_Sources | |
import PlaygroundSupport | |
final class TestView: UIView { | |
let labelPrimary: UILabel = { | |
let label = UILabel() | |
label.font = UIFont.systemFont(ofSize: 25) | |
label.textColor = .black |
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
# Ref: https://stackoverflow.com/questions/7787029/how-do-i-rename-all-files-to-lowercase | |
for f in *; do mv "$f" "$f.tmp"; mv "$f.tmp" "`echo $f | tr "[:upper:]" "[:lower:]"`"; done |
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
# Backup | |
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql | |
# Restore | |
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE | |
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
# Remove old one | |
brew cask uninstall sequel-pro | |
# Install new | |
brew cask install homebrew/cask-versions/sequel-pro-nightly |
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
# 進入 mysql container,(我的 container 叫 mysql 也許你的不一樣) | |
docker-compose exec mysql bash | |
# Login into mysql | |
mysql -u root -p | |
# Change encryption of the current user's password | |
ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword'; |
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
protocol CLSPickerViewProtocol { | |
var title: String { get } | |
var id: Int { get } | |
} | |
final class CLSPickerView<T: LLPickerViewProtocol>: UIPickerView, UIPickerViewDelegate, UIPickerViewDataSource { | |
var selectHandler: ((T) -> Void)? | |
var contents: [T] = [] { |
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
//: A UIKit based Playground for presenting user interface | |
import UIKit | |
import PlaygroundSupport | |
/// CLSTableViewConfig for extend, add more tableview properties. | |
struct CLSTableViewConfig { | |
var heightForRow: CGFloat? | |
} |
NewerOlder