Skip to content

Instantly share code, notes, and snippets.

@peiweichen
peiweichen / gist:b23cf1ea699f7199cfdd
Created March 18, 2016 10:17
UIColor Hex Extension in Swift
extension UIColor {
public convenience init(hex: UInt32, alpha: CGFloat = 1) {
let divisor = CGFloat(255)
let red = CGFloat((hex & 0xFF0000) >> 16) / divisor
let green = CGFloat((hex & 0x00FF00) >> 8) / divisor
let blue = CGFloat( hex & 0x0000FF ) / divisor
self.init(red: red, green: green, blue: blue, alpha: alpha)
}
@peiweichen
peiweichen / build-ffmpeg.sh
Created March 1, 2016 06:20 — forked from m1entus/build-ffmpeg.sh
Installing ffmpeg ios libraries armv7, armv7s, i386
#!/bin/bash
###########################################################################
# Choose your ffmpeg version and your currently-installed iOS SDK version:
#
VERSION="2.0.2"
SDKVERSION="7.0"
ARCHS="armv7 armv7s i386"
#
#
@peiweichen
peiweichen / PHAsset+Addition.h
Created January 5, 2016 12:56
Add property to PHAsset using Associated Object and Category
#import <Foundation/Foundation.h>
#import <Photos/PHAsset.h>
@interface PHAsset (Addition)
@property (nonatomic,assign) BOOL selected;
@end
@peiweichen
peiweichen / xv6-setup-yosemite.sh
Created November 26, 2015 06:06 — forked from film42/xv6-setup-yosemite.sh
Get xv6 running with QEMU on OSX Yosemite
#! /usr/bin/env bash
# Get xv6 working with OSX Yosemite
# Most things were here: https://doesnotscale.com/compiling-xv6-on-os-x-10-9/
# You need homebrew installed to make this thing work
brew tap homebrew/versions && brew install gcc48
brew deps qemu | xargs brew install
export PATH=/usr/local/bin:$PATH
export CC=/usr/local/bin/gcc-4.8
brew install wget
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Untitled</title>
</head>
<body>
</body>