I've moved this gist to https://github.com/phynet/iOS-Schemes please check it there ;)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// swift | |
var image = xxx | |
var rect = NSRect(x: 0, y: 0, width: image.size.width, height: image.size.height) | |
let cgImage = image.CGImageForProposedRect(&rect, context: nil, hints: nil)!.takeUnretainedValue() | |
let bitmapRep = NSBitmapImageRep(CGImage: cgImage) | |
if let imageData = bitmapRep.representationUsingType(NSBitmapImageFileType.NSPNGFileType, properties: [:]) { | |
let len = imageData.length | |
var bytes = [UInt8](count: len, repeatedValue: 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Objective-C | |
UIImage *image = [UIImage imageNamed:<#(NSString *)#>]; | |
NSData *imageData = UIImagePNGRepresentation(image); | |
NSInteger len = imageData.length; | |
Byte *bytes = (Byte *)[imageData bytes]; | |
NSMutableString *result = [NSMutableString stringWithCapacity:len * 5]; | |
[result appendString:@"{"]; | |
for (NSUInteger i = 0; i < len; i++) { | |
if (i) { | |
[result appendString:@","]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Simple HTTP Server With Upload. | |
This module builds on BaseHTTPServer by implementing the standard GET | |
and HEAD requests in a fairly straightforward manner. | |
see: https://gist.github.com/UniIsland/3346170 | |
""" | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
var token: dispatch_once_t = 0 | |
func test() { | |
dispatch_once(&token) { | |
println("This is printed only on the first call to test()") | |
} | |
println("This is printed for each call to test()") | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
301 https://github.com/zxdrive/imouto.host |
Here's an example of how to embed a Gist on GitHub Pages:
{% gist 5555251 %}
All you need to do is copy and paste the Gist's ID from the URL (here 5555251
), and add it to a gist
tag surrounded by {%
and %}
.