Skip to content

Instantly share code, notes, and snippets.

View mbigatti's full-sized avatar

Massimiliano Bigatti mbigatti

View GitHub Profile
@mbigatti
mbigatti / BMXRubberBanding.h
Last active December 11, 2015 07:08
iOS6 Rubber-banding Formula, as described by Grant Paul (chpwn) (ref. https://twitter.com/chpwn/status/285540192096497664)
//
// BMXRubberBanding.h
// Rubber-banding Formula, as described by Grant Paul (chpwn)
// https://twitter.com/chpwn/status/285540192096497664
//
#ifndef TimerApp_BMXRubberBanding_h
#define TimerApp_BMXRubberBanding_h
#define BMX_RUBBER_BANDING_CONSTANT 0.55
@mbigatti
mbigatti / AddDynamicProperty.h
Last active December 24, 2015 05:29
A macro for dynamic properties in categories
//
// Dynamic properties in categories
//
// @see http://www.davidhamrick.com/2012/05/28/Adding-Properties-to-an-Objective-C-Category-Revisted.html
// @see https://twitter.com/nicklockwood/status/384088702768922625
// @see http://www.tuaw.com/2013/04/10/devjuice-better-objective-c-associated-objects/
// @see http://stackoverflow.com/questions/16020918/avoid-extra-static-variables-for-associated-objects-keys
//
// Remember to add #import <objc/runtime.h> in implementation.
//
@mbigatti
mbigatti / UIView+BMXMotionEffect
Created October 17, 2013 08:17
Add device tilting support to your UIView to get an effect similar to native UIAlertView
#import <UIKit/UIKit.h>
@interface UIView (BMXMotionEffect)
- (void)BMX_addTwoDimensionMotionEffectWithDepth:(CGFloat)depth;
@end
#import "UIView+BMXMotionEffect.h"
import Foundation
enum Theme : Int
{
case LIGHT = 0
case DARK
case AUTOMATIC
}
extension NSUserDefaults
@mbigatti
mbigatti / UIColor+RGB.swift
Last active February 14, 2021 07:22
UIColor extension that add a whole bunch of utility functions.
//
// UIColor+RGB.swift
// Copyright (c) 2014 Massimiliano Bigatti. All rights reserved.
//
import Foundation
import UIKit
/**
UIColor extension that add a whole bunch of utility functions like:
@mbigatti
mbigatti / UIView+FirstResponder.swift
Created July 10, 2014 15:40
A classical first responder finder using Swift.
import UIKit
extension UIView {
func currentFirstResponder() -> UIResponder? {
if self.isFirstResponder() {
return self
}
for view in self.subviews {
if let responder = view.currentFirstResponder() {
@mbigatti
mbigatti / archive_logs.sh
Created December 4, 2014 10:14
Archive and delete multiple log files.
zip $(date +%Y%m%d) *.log*; rm -f *.log*
@mbigatti
mbigatti / find_files.sh
Last active August 29, 2015 14:10
Find all files that contain the parameter
for f in $(find . -type f -exec grep -l "$1" {} \;); do ls -l $f; grep $1 $f; done
@mbigatti
mbigatti / list_today_files.sh
Created December 4, 2014 10:31
List only files modified today
ls -al --time-style=+%D | grep $(date +%D)
@mbigatti
mbigatti / recent_files.sh
Created December 4, 2014 10:32
List most recent 10 files, long format
ls -lrt | tail -n 10