Skip to content

Instantly share code, notes, and snippets.

Avatar
🤗
2333

Shawn Wang iShawnWang

🤗
2333
View GitHub Profile
@rbaulin
rbaulin / UIImage+ImageEffects.h
Last active Jan 9, 2017
UIImage+ImageEffects.m presented on WWDC 2013
View UIImage+ImageEffects.h
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Copyright (C) 2013 Apple Inc. All Rights Reserved.
*/
@import UIKit;
@daehn
daehn / vibration.m
Created Apr 3, 2015
Custom iOS vibration pattern with 100ms duration using private API
View vibration.m
NSMutableDictionary *vibrationParameters = [[NSMutableDictionary alloc] init];
vibrationParameters[@"VibePattern"] = @[@YES, @100];
vibrationParameters[@"Intensity"] = @1;
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wimplicit-function-declaration"
AudioServicesStopSystemSound(kSystemSoundID_Vibrate);
AudioServicesPlaySystemSoundWithVibration(kSystemSoundID_Vibrate, nil, vibrationParameters);
#pragma clang diagnostic pop
@dimroc
dimroc / DDLogHelper.swift
Last active Jul 28, 2017
Wrapper around the Objective C DDLog found in CocoaLumberjack 2.x
View DDLogHelper.swift
import Foundation
public let defaultDebugLevel = DDLogLevel.Debug
public let defaultTag = NSString(format: "ManhattanForum")
class DDLogHelper {
class func SwiftLogMacro(async: Bool, level: DDLogLevel, flag flg: DDLogFlag, context: Int = 0, file: String = __FILE__, function: String = __FUNCTION__, line: UWord = __LINE__, tag: AnyObject? = defaultTag, format: String, args: CVaListPointer) {
let string = NSString(format: format, arguments: args) as String
SwiftLogMacro(async, level: level, flag: flg, context: context, file: file, function: function, line: line, tag: tag, string: string)
}
@webfrogs
webfrogs / shell.sh
Created Mar 30, 2017
Output swift function information whose compile time is large than 100ms
View shell.sh
xcodebuild -workspace XXX.xcworkspace -scheme XXX clean build OTHER_SWIFT_FLAGS="-Xfrontend -debug-time-function-bodies" | grep '^\d\{3,\}[.]\{1\}'
@wudi
wudi / new_gist_file_0
Created Oct 11, 2014
iOS程序字体与ps设计字体换算
View new_gist_file_0
一,ps和pt转换px:相对长度单位。像素(Pixel)。(PS字体)
pt:绝对长度单位。点(Point)。(iOS字体)公式如下:pt=(px/96)*72。二,字体间转换1in = 2.54cm = 25.4 mm = 72pt = 6pc
具体换算是:
Points Pixels Ems Percent
6pt 8px 0.5em 50%
7pt 9px 0.55em 55%
7.5pt 10px 0.625em 62.5%
8pt 11px 0.7em 70%
9pt 12px 0.75em 75%
10pt 13px 0.8em 80%
@lvdaqian
lvdaqian / jenkins-email-ext-clangScanReport-template.jelly
Created Apr 10, 2014
a jelly script template for jenkins email-ext plugin. in this template we can publish the report of clangScanBuild plugin by using email template.
View jenkins-email-ext-clangScanReport-template.jelly
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define">
<html>
<head>
<title>${project.name}</title>
<style>
body table, td, th, p, h1, h2 {
margin:0;
font:normal normal
100% Georgia, Serif;
background-color: #ffffff;
View json_parser.js
// This is a coding exercise of implementing a parser. Some minor parsing capabilities are not implemented.
// The algorithm are mainly from Douglas Crockford's 'https://github.com/douglascrockford/JSON-js/blob/master/json_parse.js'
function json_parse(str) {
var i = 0
var ch = str[i]
// core function that recursively called to move forward scanning pointers and accept tokens
function next(c) {
if (c) {
View 3-reason-to-use-jest-to-test-your-javascript.md

Javascript 的测试, 不管在用 jasmine 还是 mocha, 都是很头疼的事情. 但是自从有了 jest, 一口气写7个测试, 腰也不疼了, 头也不疼了.

只需要 3 个理由

在说用 jest 测为什么好之前,我们先来看我们要测的一个例子.

View Web 中文字体应用指南.md

Web 中文字体应用指南

在 Web 上应用字体是一项基本技术,同时也是一门艺术。对于英文字体来说可选择的范围实在是太广泛了,合理的使用它们将会为你的网站增色不少。关于英文字体的使用和搭配技巧,在这里不做赘述,只推荐一套非常好的视频:Fundamentals of Design by CodeSchool

而真正的挑战在于中文字体,由于中文字体组成的特殊性导致其体积过于庞大,除了操作系统内置的字体之外,我们很难在网站上应用其他的字体。在可选性很差的前提之下,如何正确的使用中文字体呢?

首先,以下的字体声明都是很糟糕的,切忌使用:

font-family: "宋体";
@armcknight
armcknight / install_xcode.sh
Last active May 4, 2019
Install Xcode via command line
View install_xcode.sh
#!/bin/sh
#
# install_xcode.sh
#
# Created by Andrew McKnight on 9/24/15
#
# takes a downloaded .dmg containing Xcode and installs it to a specified location/name, or defaults to /Applications and the DMG's filename
#
You can’t perform that action at this time.