Skip to content

Instantly share code, notes, and snippets.

@akirahrkw
akirahrkw / gist:ce3c52ae79f3b5de5a01
Created October 31, 2014 17:09
manipulate pixel data by swift
class BaseImageProcessor {
func createARGBBitmapContext(imageRef : CGImageRef) -> CGContextRef! {
var pixelWidth:UInt = CGImageGetWidth(imageRef);
var pixelHeight:UInt = CGImageGetHeight(imageRef);
var bitmapBytesPerRow:UInt = (pixelWidth * 4)
var bitmapByteCount:UInt = (bitmapBytesPerRow * pixelHeight)
var colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
@akirahrkw
akirahrkw / json-api-lib.swift
Last active August 29, 2015 14:17
simple JSON API library by swift using generics
// Playground - noun: a place where people can play
import UIKit
import XCPlayground
//// extension
extension String {
func urlEncode() -> String! {
let str = self.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet())
return (str != nil) ? str : ""
@akirahrkw
akirahrkw / hide_navigationbar_bottom_line.swift
Created February 18, 2016 03:27
How to hide UINavigationBar 1px bottom line in Swift
for subView in navigationController!.navigationBar.subviews where NSStringFromClass(subView.dynamicType) == "_UINavigationBarBackground" {
for imageView in subView.subviews where NSStringFromClass(imageView.dynamicType) == "UIImageView" {
imageView.hidden = true
}
}
@akirahrkw
akirahrkw / polygon.rb
Created January 18, 2017 04:02
to find places using ST_Contains( a point within a polygon)
Place.where("ST_Contains(polygon::geometry, ST_PointFromText('POINT(#{lon} #{lat})' , 4326 ) )")