Skip to content

Instantly share code, notes, and snippets.

View sugarmo's full-sized avatar
🏠
Working from home

Steven Mok sugarmo

🏠
Working from home
View GitHub Profile
@eahrold
eahrold / HelperTool_CodeSign_RunScript.py
Created February 24, 2014 22:45
Automatically get the proper Values in a PriviledgedHelperTool's Info.plist / LaunchD
#!/usr/bin/python
''' Place this script at the root of the project directory
and enter this for a Run Script during build phase of the helper app
${PROJECT_DIR}"/HelperTool_CodeSign_RunScript.py
put the run script right after Target Dependencies
What this script does is write the SMPrivilegedExecutables dictionary
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active June 26, 2019 16:41
Objective-C Uncrustify Config
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment
@zadr
zadr / CV.m
Created March 8, 2017 19:08
UIImage from CMSampleBuffer
#import <CoreMedia/CoreMedia.h>
#import <CoreVideo/CoreVideo.h>
#import <UIKit/UIKit.h>
// https://developer.apple.com/library/content/qa/qa1702/_index.html
+ (UIImage * _Nullable)imageWithSampleBuffer:(CMSampleBufferRef _Nonnull)sampleBuffer {
UIImage *returnValue = nil;
CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
CVPixelBufferLockBaseAddress(imageBuffer, 0); {
@SaitoWu
SaitoWu / gollum.md
Created August 9, 2012 02:46
self host a gollum wiki.

nginx configuration:

user root admin;

worker_processes  1;

# pid of nginx master process
pid /var/run/nginx.pid;
@Nyx0uf
Nyx0uf / gist:217d97f81f4889f4445a
Last active November 15, 2020 22:31
UIImage scale using vImage
-(UIImage*)mmg_imageScaledToFitSize:(CGSize)fitSize
{
// Create a vImage_Buffer from the CGImage
CGImageRef sourceRef = self.CGImage;
vImage_Buffer srcBuffer;
vImage_CGImageFormat format = {
.bitsPerComponent = 8,
.bitsPerPixel = 32,
.colorSpace = NULL,
.bitmapInfo = (CGBitmapInfo)kCGImageAlphaFirst,
@valkjsaaa
valkjsaaa / CVImageBuffer_deepcopy.swift
Created May 19, 2016 09:58
deep copy of a CVImageBuffer
extension CVPixelBuffer {
func deepcopy() -> CVPixelBuffer? {
let width = CVPixelBufferGetWidth(self)
let height = CVPixelBufferGetHeight(self)
let format = CVPixelBufferGetPixelFormatType(self)
var pixelBufferCopyOptional:CVPixelBuffer?
CVPixelBufferCreate(nil, width, height, format, nil, &pixelBufferCopyOptional)
if let pixelBufferCopy = pixelBufferCopyOptional {
CVPixelBufferLockBaseAddress(self, kCVPixelBufferLock_ReadOnly)
CVPixelBufferLockBaseAddress(pixelBufferCopy, 0)
extension UIImage {
public func imageRotatedByDegrees(degrees: CGFloat) -> UIImage {
let radiansToDegrees: (CGFloat) -> CGFloat = {
return $0 * (180.0 / CGFloat(M_PI))
}
let degreesToRadians: (CGFloat) -> CGFloat = {
return $0 / (180.0 * CGFloat(M_PI))
}
// calculate the size of the rotated view's containing box for our drawing space
@implementation UILabel (SwizzlingExamples)
+ (void)load
{
SwizzleSelectorWithBlock_Begin(self, @selector(initWithFrame:))
^(UILabel *self, CGRect frame) {
if ((self = ((id (*)(id, SEL, CGRect))_imp)(self, _cmd, frame))) {
// ...
}
return self;
@Weptun
Weptun / floatsign.sh
Last active January 1, 2022 21:23 — forked from mediabounds/floatsign.sh
Now fix when no entitlements are present.
# !/bin/bash
# Copyright (c) 2011 Float Mobile Learning
# http://www.floatlearning.com/
# Extension Copyright (c) 2013 Weptun Gmbh
# http://www.weptun.de
#
# Extended by Ronan O Ciosoig January 2012
#
# Extended by Patrick Blitz, April 2013
@humblehacker
humblehacker / CVPixelBufferDeepCopy.swift
Last active February 13, 2022 20:35
Creates a deep copy of a CVPixelBuffer. Compatible with Swift 2.3.
extension CVPixelBuffer
{
/// Deep copy a CVPixelBuffer:
/// http://stackoverflow.com/questions/38335365/pulling-data-from-a-cmsamplebuffer-in-order-to-create-a-deep-copy
func copy() -> CVPixelBuffer
{
precondition(CFGetTypeID(self) == CVPixelBufferGetTypeID(), "copy() cannot be called on a non-CVPixelBuffer")
var _copy: CVPixelBuffer?