Skip to content

Instantly share code, notes, and snippets.

MPRemoteCommandCenter.shared().nextTrackCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
print("next song")
return .success
}
MPRemoteCommandCenter.shared().pauseCommand.addTarget { (event) -> MPRemoteCommandHandlerStatus in
print("pause")
return .success
}
// Authorize the usage
CMHeadphoneMotionManager.authorizationStatus()
//Initialize the manager and set the delegate
let motionManager = CMHeadphoneMotionManager()
motionManager.delegate = self
//Start tracking (simplified)
//Implement the device motion handler callback to receive motion data
if !motionManager.isDeviceMotionActive {
jspb.BinaryWriter.prototype.writeString=function(a,b){
if(null!=b){
this.rawWriteFieldHeader_(a,jspb.BinaryConstants.WireType.DELIMITED);
for(var c=[],d=0; d < b.length; d++) {
var e = b.codePointAt(d);
if (e < 128) {
jspb.BinaryWriter.prototype.writeString=function(a,b){
if(null!=b){
this.rawWriteFieldHeader_(a,jspb.BinaryConstants.WireType.DELIMITED);
for(var c=[],d=0; d < b.length; d++) {
var e = b.charCodeAt(d);
if (e < 128) {
// Emoji fix
// Replace the function in protobuf/js/binary/encoder.js (at the bottom)
jspb.BinaryEncoder.prototype.writeString = function(value) {
var oldLength = this.buffer_.length;
// UTF16 to UTF8 conversion loop swiped from goog.crypt.stringToUtf8ByteArray.
for (var i = 0; i < value.length; i++) {
var c = value.charCodeAt(i);
if (c < 128) {
@tetek
tetek / card.hs
Last active November 2, 2015 20:50
credit card validation
toDigits :: Integer -> [Integer]
toDigits 0 = []
toDigits a = (toDigits c) ++ [b] where (c,b) = divMod a 10
toDigitsRev = reverse . toDigits
doubleEveryOther :: [Integer] -> [Integer]
doubleEveryOther (x:y:xs) = x*2 : y : (doubleEveryOther xs)
doubleEveryOther a = a
The best skate videos right in your pocket.
VIDEO HIGHLIGHTS
Long press on a video to view highlights. This is super cool.
BANGERS
Double tap a video to mark it as BANGER. Watch it anytime on a BANGER list.
All your favourite skate videos in one list, just one tap away. Ready to watch before skateboarding.
@tetek
tetek / suggestionsList.m
Created June 6, 2012 10:54
SuggestionList - how to
//In your ViewController define a property with SuggestionsList instance
//in .h
@property(retain)SuggestionsList *suggList;
//in .m
@synthesize suggList = _suggList;
//initialize it with array of strings that contains suggestions you want to present
NSArray *array = [NSArray arrayWithObjects:@"Berlin",@"Warsaw",@"Wroclaw",@"Barcelona",nil];
self.suggList = [[[SuggestionsList alloc] initWithArray:array] autorelease];
@tetek
tetek / BNRTimeBlock.h
Created June 5, 2012 09:30 — forked from bignerdranch/BNRTimeBlock.h
Timing Utility Post 20120308
CGFloat BNRTimeBlock (void (^block)(void));
@tetek
tetek / gist:1225709
Created September 18, 2011 23:29
SuggestionMenu
//I've made sugMenu instance variable and initialized it.
sugMenu = [[SuggestionMenu alloc] initWithSortedArray:array];
//make sure you are implementing UITextFieldDelegate protocol
-(void)textFieldDidBeginEditing:(UITextField *)textField{
[sugMenu suggestForText:@"" inField:textField];
}
//easy as that...
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{