This file contains 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
# OS X temporary files that should never be committed | |
.DS_Store | |
*.swp | |
*.lock | |
profile | |
# Xcode temporary files that should never be committed | |
*~.nib | |
# Xcode build files - |
This file contains 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
NSMutableString *js = [NSMutableString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"individualnotification" ofType:@"js"] encoding:NSUTF8StringEncoding error:nil]; | |
[js appendString:@"getHeightForElementById(\"idNotificationContent\")"]; | |
float height = [[contentWebView stringByEvaluatingJavaScriptFromString:js] floatValue]; | |
function getHeightForElementById(elementID) { | |
var height = 0; | |
var subElements = Array(); | |
var element = document.getElementById(elementID); |
This file contains 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
CATransform3D transform = CATransform3DIdentity; | |
transform.m34 = 1.0/700.0; | |
transform = CATransform3DRotate(transform, M_PI, 0, 1, 0); | |
CATransform3D transform2 = CATransform3DRotate(transform, -M_PI/2, 0, 1, 0); | |
CATransform3D transform3 = CATransform3DRotate(transform2, -M_PI/2, 0, 1, 0); | |
CALayer *layer = self.cardView.layer; | |
CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform"]; | |
rotation.fromValue = [NSValue valueWithCATransform3D:transform]; | |
rotation.toValue = [NSValue valueWithCATransform3D:transform2]; |
This file contains 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 CoreGraphics | |
import ImageIO | |
import MobileCoreServices | |
func createGIF(with images: [UIImage], loopCount: Int = 0, frameDelay: Double, callback: (dataURL: NSURL?, error: NSError?) -> ()) { | |
let fileProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFLoopCount as String: loopCount]] | |
let frameProperties = [kCGImagePropertyGIFDictionary as String: [kCGImagePropertyGIFDelayTime as String: frameDelay]] | |
let documentsDirectory = NSTemporaryDirectory() | |
let url = NSURL(fileURLWithPath: documentsDirectory).URLByAppendingPathComponent("animated.gif") |
This file contains 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
func imageFromSampleBuffer(sampleBuffer:CMSampleBufferRef) -> UIImage? { | |
if let imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer) { | |
CVPixelBufferLockBaseAddress(imageBuffer,0) | |
let baseAddress = CVPixelBufferGetBaseAddress(imageBuffer) | |
let bytesPerRow = CVPixelBufferGetBytesPerRow(imageBuffer) | |
let width = CVPixelBufferGetWidth(imageBuffer) | |
let height = CVPixelBufferGetHeight(imageBuffer) | |
let colorSpace = CGColorSpaceCreateDeviceRGB() | |
let context = CGBitmapContextCreate(baseAddress,width,height,8,bytesPerRow, colorSpace, CGBitmapInfo.ByteOrder32Little.rawValue | CGImageAlphaInfo.PremultipliedFirst.rawValue) |
This file contains 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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
) | |
func main() { | |
str := `{"hello":{"nested":{"world":"!"}}}` | |
fmt.Println("input string : ", str) |
This file contains 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
extension UIImage { | |
func resizeUI(size:CGSize) -> UIImage? { | |
UIGraphicsBeginImageContextWithOptions(size, true, self.scale) | |
self.drawInRect(CGRect(origin: CGPointZero, size: size)) | |
let resizedImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return resizedImage | |
} | |
} |
This file contains 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
extension UIImage { | |
func resizeCG(size:CGSize) -> UIImage? { | |
let bitsPerComponent = CGImageGetBitsPerComponent(self.CGImage) | |
let bytesPerRow = CGImageGetBytesPerRow(self.CGImage) | |
let colorSpace = CGImageGetColorSpace(self.CGImage) | |
let bitmapInfo = CGImageGetBitmapInfo(self.CGImage) | |
let context = CGBitmapContextCreate(nil, Int(size.width), Int(size.height), bitsPerComponent, bytesPerRow, colorSpace, bitmapInfo.rawValue) | |
CGContextSetInterpolationQuality(context, .High) | |
This file contains 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
extension UIImage { | |
func resizeCI(size:CGSize) -> UIImage? { | |
let scale = (Double)(size.width) / (Double)(self.size.width) | |
let image = UIKit.CIImage(CGImage:self.CGImage!) | |
let filter = CIFilter(name: "CILanczosScaleTransform")! | |
filter.setValue(image, forKey: kCIInputImageKey) | |
filter.setValue(NSNumber(double:scale), forKey: kCIInputScaleKey) | |
filter.setValue(1.0, forKey:kCIInputAspectRatioKey) | |
let outputImage = filter.valueForKey(kCIOutputImageKey) as! UIKit.CIImage |
This file contains 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
extension UIImage { | |
func resizeVI(size:CGSize) -> UIImage? { | |
let cgImage = self.CGImage! | |
var format = vImage_CGImageFormat(bitsPerComponent: 8, bitsPerPixel: 32, colorSpace: nil, | |
bitmapInfo: CGBitmapInfo(rawValue: CGImageAlphaInfo.First.rawValue), | |
version: 0, decode: nil, renderingIntent: CGColorRenderingIntent.RenderingIntentDefault) | |
var sourceBuffer = vImage_Buffer() | |
defer { | |
sourceBuffer.data.dealloc(Int(sourceBuffer.height) * Int(sourceBuffer.height) * 4) |
OlderNewer