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
@bouchtaoui-dev
bouchtaoui-dev / userSchema.js
Created May 18, 2020 08:29 — forked from jzellis/userSchema.js
Boilerplate for simple Mongoose user schema
/*
I find myself recreating user models for Mongoose every time I start a new project, so I thought I'd create a generic schema for a user model that can be added to or modified as need be.
This is loosely based on the Meteor user model (using a "profile" sub-object for the user's personal information). It also includes an optional geolocation point for the user, and Mongoose timestamps, as well as a pre("save") function to bcrypt the user password and a comparePassword() function.
Just save this file wherever you store your models and do something like const Users = include('./models/userSchema.js') and you can just use it as a standard Mongoose user model.
The username/email address definitions were copied from this tutorial: https://thinkster.io/tutorials/node-json-api/creating-the-user-model

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@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);
}
@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 / 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 / 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 / Android Studio .gitignore
Created October 9, 2016 10:30 — forked from iainconnor/Android Studio .gitignore
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files
@bouchtaoui-dev
bouchtaoui-dev / styles.xml
Created May 6, 2016 13:29 — forked from jamesmontemagno/styles.xml
Transparent ActionBar
<!-- Application theme. -->
<style name="MyTheme" parent="@android:style/Theme.Holo">
<item name="android:windowActionBarOverlay">true</item>
<item name="android:actionBarStyle">@style/MyTheme.ActionBar</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowBackground">@color/red_background</item>
</style>
<style name="MyTheme.ActionBar" parent="android:Widget.Holo.ActionBar">
<item name="android:background">@android:color/transparent</item>
<item name="android:backgroundStacked">@android:color/transparent</item>
@bouchtaoui-dev
bouchtaoui-dev / SomeFragment.java
Created April 9, 2016 13:52 — forked from joshdholtz/SomeFragment.java
Android Google Maps V2 - MapView in XML
public class SomeFragment extends Fragment {
MapView mapView;
GoogleMap map;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.some_layout, container, false);