Skip to content

Instantly share code, notes, and snippets.

View WeZZard's full-sized avatar
😄
Coding maniac.

WeZZard WeZZard

😄
Coding maniac.
View GitHub Profile
@WeZZard
WeZZard / racoon.conf
Created October 4, 2014 16:40
A racoon configuration
log info;
path include "/etc/racoon/ip.conf";
path include "/etc/racoon";
path pre_shared_key "/etc/racoon/psk.txt";
listen {
isakmp MY.SERVER.IP.ADDRESS [500]; #IP address on the Internet
isakmp_natt MY.SERVER.IP.ADDRESS [4500]; #IP address on the Internet
}
@WeZZard
WeZZard / Remove Duplicates in ExtensibleCollectionType
Last active August 29, 2015 14:12
Remove duplicate items in a ExtensibleCollectionType conformed collection object
public func removeDuplicates<C: ExtensibleCollectionType where C.Generator.Element : Equatable>(aCollection: C) -> C {
var container = C()
for element in aCollection {
if !contains(container, element) {
container.append(element)
}
}
return container
@WeZZard
WeZZard / CASpringAnimationFactory
Created January 6, 2015 20:01
Create CASpringAnimation instance without accessing undocumented APIs
import UIKit
private let SharedCASpringAnimationFactory = CASpringAnimationFactory()
public class CASpringAnimationFactory {
private var dummyView: UIView
private init() {
dummyView = UIView(frame: CGRect.zeroRect)
}
@WeZZard
WeZZard / binary_search
Created June 11, 2015 01:51
A binary search implementation in Swift 2.0.
@WeZZard
WeZZard / WWDC_2015_downloader.rb
Last active December 29, 2015 14:08
WWDC_2015_downloader.rb
require 'rubygems'
require 'mechanize'
if !((ARGV[0] == 'SD' || ARGV[0] == 'HD' || ARGV[0] == 'ALL') && ARGV.size == 1)
puts %q{Usage: ruby WWDC_2015_downloader.rb SD | HD | ALL}
puts %q{Example: ruby WWDC_2015_downloader.rb SD - to download all SD videos}
puts %q{Example: ruby WWDC_2015_downloader.rb HD - to download all HD videos}
puts %q{Example: ruby WWDC_2015_downloader.rb ALL - to download videos in all resolutions}
exit
end
let string = "XCVBNMDFGHJRTYUERTYUSDFZDFWEDFASDASWE"
string.characters.count
let targetString = "ASWE"
targetString.characters.count
private class Substring {
var range: Range<String.Index>
var content: String
@WeZZard
WeZZard / binary_search_tree.swift
Last active November 17, 2015 20:12
Binary Search Tree in Swift
public indirect enum BinarySearchTree<E: Comparable> {
public typealias Element = E
case Empty
case Node(
left: BinarySearchTree<Element>,
element: Element,
right: BinarySearchTree<Element>)
@WeZZard
WeZZard / main.conf
Last active October 14, 2015 03:48
Surge.conf 使用 114 dns 配合 xuanpg.com 食用
[General]
skip-proxy = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12, localhost, *.local
bypass-tun = 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12
# dns-server = 119.29.29.29, 223.5.5.5, 114.114.114.114
dns-server = 114.114.114.114, 114.114.115.115
loglevel = notify
[Proxy]
Proxy = http,1,2
@WeZZard
WeZZard / UIView+HitTestLiveTracing.h
Last active November 24, 2016 18:12
Lively trace UIView's hit testing
//
// UIView+LiveHitTestTracing.h
// UIViewLiveHitTestTracing
//
// Created by Manfred on 10/28/15.
//
//
@import UIKit;
postfix operator !! { }
public postfix func !! <I: UnsignedIntegerType>(x: I) -> UInt {
#if arch(x86_64) || arch(arm64)
precondition(
x.toUIntMax() < 21,
"Invalid input to compute a factorial(< 21 on 64-bit arch)."
)
#else