Skip to content

Instantly share code, notes, and snippets.

@conscientiousness
conscientiousness / TextSize.swift
Created April 25, 2019 07:02 — forked from gnou/TextSize.swift
Calculate height of some text when width is fixed
public struct TextSize {
fileprivate struct CacheEntry: Hashable {
let text: String
let font: UIFont
let width: CGFloat
let insets: UIEdgeInsets
fileprivate var hashValue: Int {
return text.hashValue ^ Int(width) ^ Int(insets.top) ^ Int(insets.left) ^ Int(insets.bottom) ^ Int(insets.right)
//
// Navigator.swift
// tripani
//
// Created by Jesse Lin on 11/8/17.
// Copyright © 2017 Tripani. All rights reserved.
//
import Foundation
import UIKit
//=====定義Enum=====
enum MyListType: Int, CustomStringConvertible, EnumCaseCountable {
case waitingForReceive
case overseaReceived
case shipmentNotified
case notifyTransferPay
case transferPayChecked
case overseaShipped
case shipmentDone
[program:APP_NAME]
command=vapor run --env=production
directory=/home/USER_NAME/YOUR_APP/ # Put correct path here
autorestart=true
user=USER_NAME # Put username here
stdout_logfile=/var/log/supervisor/%(program_name)-stdout.log
stderr_logfile=/var/log/supervisor/%(program_name)-stderr.log
server {
server_name YOUR_DOMAIN_NAME;
listen 80 default_server;
listen [::]:80 default_server;
root /home/YOUR_VAPOR_FOLDER_PATH/Public;
index index.html;
try_files $uri @proxy;
location @proxy {
@conscientiousness
conscientiousness / gist:a98e1ca3ea2d72fe78186f6371c84f87
Created August 7, 2017 08:41
blog-install-vapor-and-swift-bash
eval "$(curl -sL https://apt.vapor.sh)"
sudo apt-get install swift vapor
sudo apt-get install libpq-devcd
sudo su
apt-get update
apt-get update && apt-get upgrade -y && apt-get dist-upgrade -y && apt-get install htop -y
apt-get install unattended-upgrades -y && dpkg-reconfigure -plow unattended-upgrades
apt-get install ntp -y && ntpq -p && service ntp restart
reboot
desc "Deploy a new version to the App Store"
lane :release do
# 1.Creating Certificates and Provisioning Profiles
cert
sigh(force: true)
# 2.
#ensure_git_status_clean
# 3.Creating the IPA file
@conscientiousness
conscientiousness / gist:2aaec91df4b5be00abecac1fbbd7d6c4
Created September 6, 2016 16:42
Using apple script to open Xcode and do something
tell application "Xcode"
activate
end tell
delay 1
tell application "System Events"
tell process "Xcode"
tell menu bar 1
tell menu bar item 10
tell menu 1
tell menu item 12
@conscientiousness
conscientiousness / gist:95ce3d8c04d82c2169e2bd2ba0e9b7a9
Created August 12, 2016 08:50
Get IndexPath from cell button
CGPoint center= sender.center;
CGPoint rootViewPoint = [sender.superview convertPoint:center toView:self.myTableView];
NSIndexPath *indexPath = [self.myTableView indexPathForRowAtPoint:rootViewPoint];