Skip to content

Instantly share code, notes, and snippets.

View macfanr's full-sized avatar
🙂
I may be slow to respond.

Danny macfanr

🙂
I may be slow to respond.
View GitHub Profile
@dceddia
dceddia / symbolicate.rb
Created June 26, 2021 18:58
Symbolicate a macOS crash report from Sentry
#!/usr/bin/env ruby
# colorization without needing a gem
class String
def colorize(color_code)
"\e[#{color_code}m#{self}\e[0m"
end
def red
colorize(31)
@andreabreu-me
andreabreu-me / ffmpeg_mov2webm_alpha.sh
Created May 26, 2019 16:50
Convert mov videos with alpha to webm, also with alpha channel
ffmpeg -i confettis1.mov -vf unpremultiply=inplace=1 -c:v libvpx-vp9 -b:v 0 -crf 31 -s 924x1008 confettis.webm
@caojianhua
caojianhua / OpenGLToCVPixelBuffer.m
Created January 27, 2016 09:29
Create CVPixelBufferRef from OpenGL
@interface SREAGLContext : NSObject
+ (EAGLContext*)sharedContext;
+ (EAGLContext*)newContext: (EAGLRenderingAPI) api;
@end
@implementation SREAGLContext
@lg
lg / build_tvvlckit.sh
Last active April 5, 2020 15:48
Building MobileVLCKit for AppleTV: TVVLCKit
# note these instructions are as of Dec 28, 2015
# the vlc and vlckit repos are super complex and have thousands of dependencies from everywhere on the internet.
# so, you'll need to mess with things a bit
git clone http://code.videolan.org/videolan/VLCKit.git
cd VLCKit
./buildMobileVLCKit.sh -t
@hisui
hisui / .mm
Created May 22, 2015 00:19
Checking if a given frame is a key frame.
static BOOL isKeyFrame(CMSampleBufferRef sample)
{
auto a = CMSampleBufferGetSampleAttachmentsArray(sample, 0);
if (CFArrayGetCount(a) > 0) {
CFBooleanRef value;
auto b = CFDictionaryGetValueIfPresent
((CFDictionaryRef) CFArrayGetValueAtIndex(a, 0)
, kCMSampleAttachmentKey_NotSync
, reinterpret_cast<const void **>(&value))
;
@rcolinray
rcolinray / gl_ffmpeg.cpp
Created November 19, 2013 20:54
OpenGL-FFMpeg integration
// Use OpenGL 3.0+, but don't use GLU
#define GLFW_INCLUDE_GL3
#define GLFW_NO_GLU
#include <GL/glfw.h>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
extern "C" {
@coreh
coreh / ScreenCapture.m
Last active April 20, 2023 16:37
Screen capture in Cocoa (Grabs the screen contents and puts it into a NSImage)
NSImage *CaptureScreen() {
// Get the Screen Rect
NSRect screenRect = [[NSScreen mainScreen] frame];
// Create a CGImage with the screen contents
CGImageRef cgImage = CGWindowListCreateImage(screenRect, kCGWindowListOptionOnScreenOnly, kCGNullWindowID, kCGWindowImageDefault);
// Convert the CGImage into a NSBitmapImageRep
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage];
@trevordevore
trevordevore / gist:3498531
Created August 28, 2012 14:33
Security Scoped Bookmark URLs
/*
To use:
1) Get path to file/folder using file selection dialog.
2) Pass path to secscopGetBookmarkFromURL in order to get bookmark data for it.
3) Store this bookmark data somehow.
4) Tell the OS you want access to the file using secscopInitializeURLFromBookmarkData(). Store security-scoped url returned for later.
5) When you are done using the file call secscopStopUsingURL.
You will need to do steps 4 and 5 every time you want to open a file across sessions. For example, if you have a recent files menu or a folder that a user selects once and you write data to across sessions.
*/
@acwright
acwright / gist:2707798
Created May 16, 2012 05:41
NSColor+Hex
#import <Cocoa/Cocoa.h>
@interface NSColor (Hex)
- (NSString *)hexadecimalValue;
+ (NSColor *)colorFromHexadecimalValue:(NSString *)hex;
@end
#import "NSColor+Hex.h"
@henrik
henrik / ocr.markdown
Created March 3, 2012 17:07
OCR on OS X with tesseract

Install ImageMagick for image conversion:

brew install imagemagick

Install tesseract for OCR:

brew install tesseract --all-languages

Or install without --all-languages and install them manually as needed.