Skip to content

Instantly share code, notes, and snippets.

enum ChineseRange {
case notFound, contain, all
}
extension String {
var findChineseCharacters: ChineseRange {
guard let a = self.range(of: "\\p{Han}*\\p{Han}", options: .regularExpression) else {
return .notFound
}
var result: ChineseRange
@williamhqs
williamhqs / FilteredArrayAdapter.java
Created November 15, 2016 06:18 — forked from tobiasschuerg/FilteredArrayAdapter.java
Android Arrayadapter with text filtering for the use with a TextWatcher.
/**
* Arrayadapter (for Android) with text filtering for the use with a TextWatcher.
* Note: the objects in the List need a valid toString() method.
* @author Tobias Schürg
*
*/
public class FilteredArrayAdapter extends ArrayAdapter<ImageObject> {
@williamhqs
williamhqs / SortAlgorithm.playground
Created December 2, 2015 04:07
Normal sort algorithm in Swift
//: Playground - noun: a place where people can play
import UIKit
func swap<T>(inout value1: T, inout value2: T) {
let temporary = value1
value1 = value2
value2 = temporary
}
@williamhqs
williamhqs / 20150110033835_create_student.rb
Last active August 29, 2015 14:13
Sinatra with activerecord transaction warnning.
class CreateStudent < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.integer :age
end
end
end