Skip to content

Instantly share code, notes, and snippets.

View petershine's full-sized avatar

Peter SHIN petershine

  • United States
View GitHub Profile
@petershine
petershine / DBSeparator_Assembler.java
Created November 27, 2010 11:05
Simple separator / assembler for installing big SQLite file onto Android Virtual Device (not yet tested for actual device)
/*** DBSeparator.java ***/
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class DBSeparator {
public static void main(String[] args) {
@petershine
petershine / personRecordUsingModelObj.m
Created April 29, 2011 16:46
An implementation to return ABPersonRecord as commonly used id object
- (id)personRecordUsingModelObj:(id)modelObj {
ABRecordRef aContact = ABPersonCreate();
CFErrorRef anError = NULL;
NSString *name = [NSString stringWithFormat:@"%@", [modelObj name]];
ABRecordSetValue(aContact, kABPersonOrganizationProperty, name, &anError);
ABMultiValueRef phone = ABMultiValueCreateMutable(kABMultiStringPropertyType);
ABMultiValueAddValueAndLabel(phone, [modelObj phone], kABPersonPhoneMainLabel, NULL);
@petershine
petershine / FXDsampleBufferCompression.m
Created October 29, 2015 06:02
Essential snippet for compressing original CMSampleBufferRef into H.264 sample
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(sampleBuffer);
CMVideoDimensions videoDimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
static VTCompressionSessionRef compressionSession;
if (compressionSession == NULL) {
VTCompressionSessionCreate
@petershine
petershine / FXDsampleBufferDecompressing.m
Created October 29, 2015 06:05
Essential snippet for decompressing sample into CVImageBufferRef
{
CMFormatDescriptionRef formatDescription = CMSampleBufferGetFormatDescription(compressedSample);
static VTDecompressionSessionRef decompressionSession;
if (decompressionSession == NULL) {
VTDecompressionSessionCreate
(NULL,
formatDescription,