As configured in my dotfiles.
start new:
tmux
start new with session name:
| @interface Box:NSObject | |
| { | |
| //Instance variables | |
| double length; // Length of a box | |
| double breadth; // Breadth of a box | |
| } | |
| @property(nonatomic, readwrite) double height; // Property | |
| @end |
| // This one I use very often | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| // run following code in main queue | |
| // this block will be put in the queue to be executed later | |
| }); | |
| dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ | |
| // do some task in background | |
| dispatch_async(dispatch_get_main_queue(), ^{ | |
| // update some UI |
| @interface Singleton : NSObject | |
| @end | |
| @implementation Singleton | |
| + (instancetype)sharedInstance { | |
| static Singleton *sharedInstance = nil; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| // source: https://stackoverflow.com/a/3207959/1012775 | |
| NSSortDescriptor *highestToLowest = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:NO]; | |
| [mutableArrayOfNumbers sortUsingDescriptors:[NSArray arrayWithObject:highestToLowest]]; |
| - (void) notifyMessage: (NSString*) sender withMessage: (NSString*) message { | |
| // source: http://useyourloaf.com/blog/local-notifications-with-ios-10/ | |
| NSLog(@"BackgroundServerice: Send a notification!"); | |
| message = message?message:@""; | |
| UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; | |
| // Create a content | |
| UNMutableNotificationContent *content = [UNMutableNotificationContent new]; | |
| content.title = sender; | |
| content.body = [ NSString stringWithCString:[ message cStringUsingEncoding:NSUTF8StringEncoding ] |
| /** | |
| * Created by Ishank Gulati on 14/10/16. | |
| * Observer as per Observer design pattern. | |
| */ | |
| public interface RVObserver { | |
| void update(RecyclerViewItemClickListener listener); | |
| } |
| public class ReactiveTextViewHolder<T> extends ReactiveViewHolder<T> { | |
| private TextView label; | |
| private T currentItem; | |
| public ReactiveTextViewHolder(View itemView) { | |
| super(itemView); | |
| label = (TextView) itemView.findViewById(android.R.id.text1); | |
| } |
| public abstract class BaseAdapter<T, VH extends BaseViewHolder<T>> extends RecyclerView.Adapter<VH> { | |
| private List<T> items; | |
| // Missing: setItems(), addItem(), removeItem(), ... | |
| @Override | |
| public final void onBindViewHolder(VH vh, int position) { | |
| T item = items.get(position); | |
| vh.performBind(item, position); |
| public abstract class BaseAdapter<T, VH extends BaseViewHolder<T>> extends RecyclerView.Adapter<VH> { | |
| private List<T> items; | |
| // Missing: setItems(), addItem(), removeItem(), ... | |
| @Override | |
| public final void onBindViewHolder(VH vh, int position) { | |
| T item = items.get(position); | |
| vh.performBind(item, position); |