Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am shaneqi on github.
* I am shaneqi (https://keybase.io/shaneqi) on keybase.
* I have a public key whose fingerprint is B475 5105 CD5D 9A51 670D 4986 6C74 57BA 133E 4636
To claim this, I am signing this object:
var date1 = new Date()
var date2 = new Date(2016, 10, 6); // Date(2016, 10, 6) is Nov. 6, 2016
var data1_ms = date1.getTime();
var data2_ms = date2.getTime();
// Then, calculate the milliseconds difference between the two dates.
var difference_ms = date2_ms - date1_ms;
// Finally, convert the difference back to days in which we should
// divide the milliseconds by one day’s milliseconds:
if which swiftlint >/dev/null; then
swiftlint
else
echo "warning: SwiftLint not installed, download from https://github.com/realm/SwiftLint"
fi
@ShaneQi
ShaneQi / add_swap.sh
Last active June 19, 2017 04:17
add swap for ubuntu 1604
free -h
sudo fallocate -l 1G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
free -h
mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim
echo "execute pathogen#infect()" >> ~/.vimrc
cd ~/.vim/bundle
git clone https://github.com/scrooloose/nerdtree.git
echo "au VimEnter * NERDTree" >> ~/.vimrc
docker run -it --name certbot_certonly -p 80:80 -p 443:443 -v /etc/letsencrypt:/etc/letsencrypt certbot/certbot certonly
docker start -ia certbot_certonly
docker run --name cerbot_renew -p 80:80 -p 443:443 -v /etc/letsencrypt:/etc/letsencrypt certbot/certbot renew
docker start -ia cerbot_renew
class LocalDatabase {
private let pathUrl: URL
let persistentStoreCoordinator: NSPersistentStoreCoordinator
private init(fileName: String) {
pathUrl = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!
.appendingPathComponent(fileName + ".sqlite")
guard let model = NSManagedObjectModel.mergedModel(from: [Bundle.main])
else { fatalError() }
func (rootViewControllesetr newRootViewController: UIViewController, withTransition transition: CATransition?) {
let previousViewController = ingredient.rootViewController
if let transition = transition {
// Add the transition
ingredient.layer.add(transition, forKey: kCATransition)
}
ingredient.rootViewController = newRootViewController
set tabstop=2

tabstop

The width of a hard tabstop measured in "spaces" -- effectively the (maximum) width of an actual tab character.

shiftwidth

@ShaneQi
ShaneQi / pip.js
Created September 29, 2017 05:53
javascript:document.querySelector("video").webkitSetPresentationMode("picture-in-picture");