Skip to content

Instantly share code, notes, and snippets.

Avatar

Luca Bernardi lukabernardi

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am lukabernardi on github.
  • I am lucabernardi (https://keybase.io/lucabernardi) on keybase.
  • I have a public key ASC34kN73ZCTPYGD_tRxhBz2-D5qAdY8GCRKJcIqEULrpQo

To claim this, I am signing this object:

View Reusable.swift
protocol Reusable{
static var reuseIdentifier: String { get }
}
extension Reusable {
static var reuseIdentifier: String { return String(Self.self) }
}
extension UICollectionViewCell : Reusable {}
View keybase.md

Keybase proof

I hereby claim:

  • I am lukabernardi on github.
  • I am lucabernardi (https://keybase.io/lucabernardi) on keybase.
  • I have a public key whose fingerprint is 36C3 8A7A 02A5 70AC C353 6094 CCA0 CD3A E21B E752

To claim this, I am signing this object:

@lukabernardi
lukabernardi / objc_setProperty_nonatomic_copy
Created Aug 13, 2014
objc_setProperty_nonatomic_copy disassembled
View objc_setProperty_nonatomic_copy
void objc_setProperty_nonatomic_copy(id self, SEL _cmd, id newValue, ptrdiff_t offset)
{
temp = [newValue copyWithZone:NULL];
oldValue = *(self + offset);
*(sef + offset) = temp;
_objc_release(oldValue);
}
View LBRShortcut.py
import lldb
import commands
def __lldb_init_module (debugger, dict):
debugger.HandleCommand('command script add -f LBRShortcut.window_description_command window_description')
debugger.HandleCommand('command script add -f LBRShortcut.json_data_command json_data')
debugger.HandleCommand('command script add -f LBRShortcut.fire_fault_command fire_fault')
def window_description_command(debbuger, command, result, dict):
View CIS194-hw1.hs
-- CIS 194: Homework 1 (http://www.seas.upenn.edu/~cis194/hw/01-intro.pdf)
-- toDigits 1234 == [1,2,3,4]
-- toDigitsRev 1234 == [4,3,2,1]
-- toDigits 0 == []
-- toDigits (-17) == []
toDigitsRev :: Integer -> [Integer]
toDigitsRev x = if x <= 0
View main.m
#import <Foundation/Foundation.h>
@interface LBRObject : NSObject
@end
@implementation LBRObject
- (void)execute
{
@synchronized(self) {
View windowDescription.py
import lldb
import commands
import optparse
import shlex
def __lldb_init_module (debugger, dict):
debugger.HandleCommand('command script add -f windowDescription.window_description_command window_description')
print 'The "window_description" command has been installed'
@lukabernardi
lukabernardi / AVAsset+VideoOrientation.h
Created Feb 23, 2013
Find the video orientation of an AVAsset. (Useful if you need to send the video to a remote server)
View AVAsset+VideoOrientation.h
//
// AVAsset+VideoOrientation.h
//
// Created by Luca Bernardi on 19/09/12.
// Copyright (c) 2012 Luca Bernardi. All rights reserved.
//
#import <AVFoundation/AVFoundation.h>
typedef enum {
LBVideoOrientationUp, //Device starts recording in Portrait
@lukabernardi
lukabernardi / TheEleganceOfBlock.mm
Created Feb 18, 2013
How to use inline block to better organize a block of code
View TheEleganceOfBlock.mm
__weak typeof(self) weakSelf = self;
self.collectionView = (UICollectionView *)^{
UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
UICollectionView *collectionView = [[UICollectionView alloc] initWithFrame:weakSelf.view.bounds
collectionViewLayout:flowLayout];
collectionView.delegate = weakSelf;
collectionView.dataSource = weakSelf;
return collectionView;
You can’t perform that action at this time.