Skip to content

Instantly share code, notes, and snippets.

View bmoliveira's full-sized avatar
🏠

Bruno Oliveira bmoliveira

🏠
View GitHub Profile
@bmoliveira
bmoliveira / ReusableUICollectionViewCell.swift
Last active May 10, 2016 10:29
Reusable UICollectionViewCell
extension ReusableCell where Self: UICollectionViewCell {
static func uiNibFromClass() -> UINib? {
return UINib(nibName: Self.className, bundle: nil)
}
static func reuseIdentifier() -> String? {
return Self.className
}
}
@bmoliveira
bmoliveira / Reusable.swift
Last active May 10, 2016 10:35
Reusable Protocol
protocol ReusableCell: AnyObject {
static func reuseIdentifier() -> String?
static func uiNibFromClass() -> UINib?
}
@bmoliveira
bmoliveira / Hackaroos
Created July 2, 2015 16:36
Hacks to get keyboard and status_bar
static NSString *encodeText(NSString *string, int key)
{
NSMutableString *result = [[NSMutableString alloc] init];
for (int i = 0; i < [string length]; i++)
{
unichar c = [string characterAtIndex:i];
c += key;
[result appendString:[NSString stringWithCharacters:&c length:1]];
}
return result;
@bmoliveira
bmoliveira / Android GCM Token fetcher
Last active August 29, 2015 14:22
Android Helper to get GCM Token from Play services, with fluent api callback registration
import android.content.Context;
import android.content.SharedPreferences;
import android.os.AsyncTask;
import android.support.annotation.Nullable;
import android.util.Log;
import android.util.Pair;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.gcm.GoogleCloudMessaging;