Skip to content

Instantly share code, notes, and snippets.

@gwennguihal
gwennguihal / Cubic.easeOutIn ease-tween
Created November 13, 2012 10:17
Cubic.easeOutIn ease-tween
public static function easeOutIn (t:Number):Number
{
if (t < 0.5) return 0.5 * ( (t=t*2-1) * t * t + 1);
return 0.5*(t = t*2-1)*t*t + 0.5;
}
@gwennguihal
gwennguihal / bash @2x
Created January 10, 2014 09:47
Bash code to add suffix @2x to images filename
for f in *.png; do mv "$f" "${f%.png}@2x.png"; done
@gwennguihal
gwennguihal / gist:9545994
Created March 14, 2014 11:25
Replace - by _ in filename
for f in *.png; do mv "$f" "${f//-/_}"; done
@gwennguihal
gwennguihal / KeyboadHandlerIOS
Created April 11, 2014 13:21
KeyBoard Handler IOS
- (void)setupKeyboard
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWasShown:)
name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillBeHidden:)
name:UIKeyboardWillHideNotification object:nil];
@gwennguihal
gwennguihal / IOS_AppIcon_generator
Created May 15, 2014 10:29
IOS AppIcon generator
#!/bin/bash
f=$(pwd)
sips --resampleWidth 40 "${f}/${1}" --out "${f}/Icon-40.png"
sips --resampleWidth 80 "${f}/${1}" --out "${f}/Icon-40@2x.png"
sips --resampleWidth 120 "${f}/${1}" --out "${f}/Icon-60@2x.png"
sips --resampleWidth 29 "${f}/${1}" --out "${f}/Icon-29.png"
sips --resampleWidth 58 "${f}/${1}" --out "${f}/Icon-29@2x.png"
sips --resampleWidth 50 "${f}/${1}" --out "${f}/Icon-Small-50.png"
sips --resampleWidth 76 "${f}/${1}" --out "${f}/Icon-76.png"
import Collor
class ExampleSectionDescriptor: CollectionSectionDescribable {
func sectionInset(_ collectionView:UICollectionView) -> UIEdgeInsets {
return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
}
func minimumLineSpacing(_ collectionView: UICollectionView, layout: UICollectionViewFlowLayout) -> CGFloat {
return 15
}
}
import Collor
final class TitleDescriptor: CollectionCellDescribable {
let identifier: String = "TitleCollectionViewCell"
let className: String = "TitleCollectionViewCell"
var selectable:Bool = true
let adapter: TitleAdapter
init(adapter:TitleAdapter) {
import Collor
struct TitleAdapter: CollectionAdapter {
var title : NSAttributedString
let image: UIImage = UIImage(named: "picto_warning_orange")!
init() {
let paragrapheStyle = NSMutableParagraphStyle()
paragrapheStyle.alignment = .left
extension TitleCollectionViewCell : CollectionCellAdaptable {
func update(with adapter: CollectionAdapter) {
guard let adapter = adapter as? TitleAdapter else {
fatalError("TitleAdapter required")
}
titleLabel.attributedText = adapter.title
}
}
// Adapter Protocol
protocol VSCollectionLabelAdapter: CollectionAdapter {
var label: NSAttributedString { get } // required property
}
// VSLabelCollectionViewCell implements CollectionCellAdaptable
extension VSLabelCollectionViewCell: CollectionCellAdaptable {
func update(with adapter: CollectionAdapter) {
guard let adapter = adapter as? VSCollectionLabelAdapter else {
fatalError("VSCollectionLabelAdapter required")