Skip to content

Instantly share code, notes, and snippets.

View ArchieR7's full-sized avatar
👨‍💻

Archie Chang ArchieR7

👨‍💻
View GitHub Profile
@ArchieR7
ArchieR7 / APIRequest.swift
Last active March 30, 2020 20:05
Alamofire singleton example
//
// APIRequest.swift
//
// Created by 家齊 on 2016/12/27.
// Copyright © 2016年 Archie Chang. All rights reserved.
//
import Alamofire
class APIRequest {
@ArchieR7
ArchieR7 / Backup.html
Last active January 25, 2017 06:46
For super tree
<!doctype html><html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Web Security in CTF</title><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0/css/reveal.min.css"><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0/css/theme/black.min.css">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.3.0/lib/css/zenburn.min.css">
<!-- Custom settings -->
<link rel="stylesheet" href="css/custom.css">
<!-- Printing and PDF exports -->
<script>
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
@ArchieR7
ArchieR7 / apns.py
Created April 26, 2017 06:27
python apple push notification server by auth key
# -*- coding: utf8 -*-
import jwt
import time
import json
import os
from hyper import HTTPConnection
class ApnsPusher:
def __init__(self, apns_key_id = '', apns_key_name = '.p8', team_id = '', bundle_id = ''):
@ArchieR7
ArchieR7 / SingletonDemo.swift
Last active May 4, 2017 06:09
singleton by swift
class SingletonDemo {
static let shared = SingletonDemo()
}
@ArchieR7
ArchieR7 / SingletonDemo.h
Last active May 4, 2017 06:23
Singleton by Objective-C
#import <UIKit/UIKit.h>
@interface SingletonDemo : NSObject
+ (instancetype)shared;
@end
#import "SingletonDemo.h"
@implementation SingletonDemo
+ (instancetype)shared {
static ArchieSingleton *instance = nil;
static dispatch_once_t once_token;
dispatch_once(&once_token, ^{
instance = [[ArchieSingleton alloc] init];
});
@ArchieR7
ArchieR7 / nginx.conf
Created May 4, 2017 12:39
nginx 調整 buffer 以避免 502 bad gateway
http {
proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 128k;
...
@ArchieR7
ArchieR7 / swap.sh
Created May 4, 2017 12:44
swap disk to ram
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
# swapoff /var/swap.img
@ArchieR7
ArchieR7 / Optional.h
Created May 23, 2017 14:29
NS_ASSUME_NONNULL_BEGIN and NS_ASSUME_NONNULL_END
NS_ASSUME_NONNULL_BEGIN
@interface DemoObject : NSObject
@property (nonatomic) NSString *name;
@property (nonatomic, nullable) NSString *address;
@property (nonatomic, readonly) NSString *phoneNumber;
@end
@ArchieR7
ArchieR7 / FBKVOController.h
Created June 6, 2017 01:57
KVOController observe method
- (void)observe:(nullable id)object keyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options block:(FBKVONotificationBlock)block;