Skip to content

Instantly share code, notes, and snippets.

View bouchtaoui-dev's full-sized avatar

Nordin-010 bouchtaoui-dev

  • Netherlands, Rotterdam
View GitHub Profile
// Found this snippet at: https://gist.github.com/creationix/707146
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
@bouchtaoui-dev
bouchtaoui-dev / Communicator.h
Created January 27, 2017 13:34 — forked from rjungemann/Communicator.h
How to open a TCP socket in Objective-C
#import <Foundation/Foundation.h>
@interface Communicator : NSObject <NSStreamDelegate> {
@public
NSString *host;
int port;
}
- (void)setup;
@bouchtaoui-dev
bouchtaoui-dev / BaseAdapter.java
Created March 7, 2017 14:36 — forked from mannodermaus/BaseAdapter.java
RecyclerView.ViewHolder and Adapter demonstration
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);
@bouchtaoui-dev
bouchtaoui-dev / BaseAdapter.java
Created March 7, 2017 14:36 — forked from mannodermaus/BaseAdapter.java
RecyclerView.ViewHolder and Adapter demonstration
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);
@bouchtaoui-dev
bouchtaoui-dev / Example.java
Created March 7, 2017 14:53 — forked from nightscape/Example.java
Simple RxJava-based adapter for an Android RecyclerView
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);
}
@bouchtaoui-dev
bouchtaoui-dev / RVObserver.java
Created March 8, 2017 14:11 — forked from IshankGulati/RVObserver.java
Base Adapter and RecyclerView.ViewHolder implementation for delegating clicks to Fragment to which adapter is attached. This gist is inspired from https://gist.github.com/aurae/ebf8ec212e4296aebb24 .
/**
* Created by Ishank Gulati on 14/10/16.
* Observer as per Observer design pattern.
*/
public interface RVObserver {
void update(RecyclerViewItemClickListener listener);
}
- (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 ]
@bouchtaoui-dev
bouchtaoui-dev / SimpleSortArray.m
Created September 22, 2017 09:44
Ordering NSMutableArray by NSNumber
// source: https://stackoverflow.com/a/3207959/1012775
NSSortDescriptor *highestToLowest = [NSSortDescriptor sortDescriptorWithKey:@"self" ascending:NO];
[mutableArrayOfNumbers sortUsingDescriptors:[NSArray arrayWithObject:highestToLowest]];

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@interface Singleton : NSObject
@end
@implementation Singleton
+ (instancetype)sharedInstance {
static Singleton *sharedInstance = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{