Skip to content

Instantly share code, notes, and snippets.

View benlodotcom's full-sized avatar

Benjamin Loulier benlodotcom

  • Facebook
  • San Francisco
View GitHub Profile
@benlodotcom
benlodotcom / MyAVController.h
Last active February 3, 2016 17:45
A little demo snippet that you can use to access directly the camera video in IOS4
#import <UIKit/UIKit.h>
#import <AVFoundation/AVFoundation.h>
#import <CoreGraphics/CoreGraphics.h>
#import <CoreVideo/CoreVideo.h>
#import <CoreMedia/CoreMedia.h>
/*!
@class AVController
@author Benjamin Loulier
@interface MyClass : NSObject {
iVar *aProtectedIVar;
@public
iVar *aPublicIVar;
iVar *aSecondPublicIVar;
@protected
iVar *aSecondProtectedIVar;
@private
iVar *aPrivateIVAr;
}
def highlight_gists(text)
#We set up the regexp we want to find in the string and replace it by the highlighted code
#This regular expression detects the code used to emebed a gist and extract the id of the gist,
#the file (for a multifile gist) and the language (the language attribute has to be added to the
#embed code)
regex = /<script src=\"(http|https):\/\/gist.github.com\/(\d+).js(\?file=(\S+))?\"(\s*lang=\"(.+)\")?>\s*<\/script>/
text.gsub(regex) do
if $6
highlight_gist($2,$4,$6)
@benlodotcom
benlodotcom / heroku
Created November 16, 2011 20:07
GmailRssifier - Install
$ cd PATH/TO/MY_APP
$ heroku create myapp
$ git commit -a
$ git push heroku master
@benlodotcom
benlodotcom / test
Created August 27, 2012 08:07
Test gist for gist_retriever
int main(int argc, char **argv) {printf("Hello you :-)"; return 0;}
@benlodotcom
benlodotcom / ClearApplicationCache.m
Last active April 13, 2017 09:41
Methods to flush the HTML5 Application Cache on iOS. In a UIWebView Webkit uses an sqlite database to store the resources associated to a cache manifest, as there is no API yet to flush the Application Cache you can use this method which delete entries directly from the database. However, this approach could break anytime if the implementation o…
static NSString *cacheDatabaseName = @"ApplicationCache.db";
static NSString *cacheGroupTable = @"CacheGroups";
static NSString *cacheGroupTableManifestURLColums = @"manifestURL";
static NSString *cacheTable = @"Caches";
static NSString *cacheTableCacheGroupId = @"cacheGroup";
/**
Clears the cached resources associated to a cache group.
@param manifestURLs An array of `NSString` containing the URLs of the cache manifests for which you want to clear the resources.