Skip to content

Instantly share code, notes, and snippets.

View dars's full-sized avatar

Devlin dars

  • code4soul
  • Taiwan,Taipei
View GitHub Profile
@dars
dars / BackgroundTask.swift
Created September 8, 2017 13:01 — forked from phatmann/BackgroundTask.swift
Encapsulate iOS background tasks in a Swift class
class BackgroundTask {
private let application: UIApplication
private var identifier = UIBackgroundTaskInvalid
init(application: UIApplication) {
self.application = application
}
class func run(application: UIApplication, handler: (BackgroundTask) -> ()) {
// NOTE: The handler must call end() when it is done
@dars
dars / fontFamily.swift
Last active September 3, 2017 04:51
show support font family
for family: String in UIFont.familyNames {
print("\(family)")
for names: String in UIFont.fontNames(forFamilyName: family) {
print("== \(names)")
}
}
@dars
dars / if-else-debug.swift
Last active February 2, 2017 07:29
Swift #if #else 判斷
#if DEBUG
print(true)
#else
print(false)
#endif
@dars
dars / demo_spec.rb
Created April 19, 2015 11:24
rspec test demo code
require 'rails_helper'
describe 'The integer should be i' do
i = 1
it 'should be 1' do
expect(i).to be 1
end
it 'should be 2' do
expect(i).not_to be 2
@dars
dars / new_gist_file
Created August 26, 2013 19:31
php curl debug
<?php
$verbose = fopen('php://temp', 'rw+');
$options = array(
CURLOPT_RETURNTRANSFER => 1, // 不直接印出結果
CURLOPT_URL => $target_url,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $query_string, //$data, // 直接給array
CURLOPT_VERBOSE => true,
CURLOPT_STDERR => $verbose