Skip to content

Instantly share code, notes, and snippets.

View BigNerdCoding's full-sized avatar
🎯
Focusing

Jax Wu BigNerdCoding

🎯
Focusing
View GitHub Profile
@BigNerdCoding
BigNerdCoding / clean_old_code_simulators.sh
Created September 15, 2017 03:50 — forked from jonathan-beebe/clean_old_code_simulators.sh
Clean out unused Xcode Simulators
# Close Xcode & the iOS Simulator
# http://stackoverflow.com/a/30940055
# Remove any old runtimes from this directory.
cd /Library/Developer/CoreSimulator/Profiles/Runtimes
# e.g.
sudo rm -rf iOS\ 8.1.simruntime
# http://stackoverflow.com/a/11790983
# Remove the download receipts for simulators you don't need anymore.
@BigNerdCoding
BigNerdCoding / NGINX on Ruby on Rails with Unicorn and GZIP assets
Created July 26, 2017 03:32 — forked from Austio/NGINX on Ruby on Rails with Unicorn and GZIP assets
Configure NGINX for SSL using unicorn and gzip assets optimizations
1. Open a command prompt and navigate to /etc/nginx/ssl
2. Issue "openssl req -new -newkey rsa:2048 -nodes -keyout server.key -out server.csr"
3. Get your certificate issued - Go to your certificate authority and give them the CSR (server.csr)
4. Copy your new crt (that the certificate authority issued) to the /etc/nginx/ssl and give it read priveledges
5. Reconfigure your nginx.conf, here is mine. The first part redirects 80 to 443, the second part listens to 443 and is optimized to return Ruby on Rails application requests using gzip and unicorn.
@BigNerdCoding
BigNerdCoding / ssl_puma.sh
Created July 25, 2017 08:56 — forked from tadast/ssl_puma.sh
localhost SSL with puma
# 1) Create your private key (any password will do, we remove it below)
$ cd ~/.ssh
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@BigNerdCoding
BigNerdCoding / Yarn && npm设置镜像源.md
Last active July 25, 2017 07:48
Yarn && npm设置镜像源
// 任务队列的创建
dispatch_queue_t mySerialDispatchQueue = dispatch_queue_create("com.bignerdcoding.gcd",NULL);
dispatch_queue_t myConcurrentDispatchQueue = dispatch_queue_create("com.bignerdcoding.gcd",DISPATCH_QUEUE_CONCURRENT);
// iOS SDK < 7.0 需要手动持有释放创建的任务队列
dispatch_release(mySerialDispatchQueue);
dispatch_retain(mySerialDispatchQueue);
// 主线程队列、全局队列
@BigNerdCoding
BigNerdCoding / HttpOperation.h
Created April 8, 2017 13:11
Http,AFNetworking
#import <Foundation/Foundation.h>
typedef void (^successBlock)(id responseObject);
typedef void (^failureBlock)(NSError * error);
typedef void (^uploadImages)(id<AFMultipartFormData> formData);
@interface HttpOperation : AFHTTPSessionManager
import Foundation
import UIKit
// Usage Examples
let shadowColor = Color.shadow.value
let shadowColorWithAlpha = Color.shadow.withAlpha(0.5)
let customColorWithAlpha = Color.custom(hexString: "#123edd", alpha: 0.25).value
enum Color {
@BigNerdCoding
BigNerdCoding / Singleton.swift
Created April 8, 2017 13:08
Singleton,Swift
//Swift1.2之后的最佳单例模型
/*这种写法不仅简洁,而且保证了单例的独一无二。在初始化类变量的时候,Apple 将会把这个初始化包装在一次 swift_once_block_invoke 中,以保证它的唯一性。另外,我们在这个类型中加入了一个私有的初始化方法,来覆盖默认的公开初始化方法,这让项目中的其他地方不能够通过 init 来生成自己的 MyManager 实例,也保证了类型单例的唯一性。
*/
class SingletonA {
static let sharedInstance = SingletonA()
init() {
println("AAA");
}
@BigNerdCoding
BigNerdCoding / AttrTextView.swift
Created April 8, 2017 13:06
Swift, Attr, TextView
import UIKit
enum wordType{
case hashtag // #标示文本类型
case mention // @标示文本类型
}
//A custom text view that allows hashtags and @ symbols to be separated from the rest of the text and triggers actions upon selection
//自定义视图用于高亮 # 和 @ 之后的文本(效果类似于微博、twitter),并添加点击事件
class AttrTextView: UITextView {
import UIKit
struct PullToRefreshConst {
static let pullTag = 810
static let pushTag = 811
static let alpha = true
static let height: CGFloat = 80
static let imageName: String = "pulltorefresharrow.png"
static let animationDuration: Double = 0.5
static let fixedTop = true // PullToRefreshView fixed Top