Skip to content

Instantly share code, notes, and snippets.

View mhdatie's full-sized avatar
:shipit:

Mo Atie mhdatie

:shipit:
View GitHub Profile
const express = require('express');
const router = express.Router();
const mainController = require('../controllers');
const pj = require('../package.json');
/* GET home page. */
router.get('/', (req, res) => {
res.status(200).json({ name: pj.name, version: pj.version});
});
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const CounterSchema = new Schema({
_id: { type: String, required: true },
count: { type: Number, default: 0 }
}, {
timestamps: true,
collection: 'counters'
});
const LinkSchema = require('../models/link');
const isUrl = require('../node_modules/validator/lib/isURL');
const alphabets = '23456789bcdfghjkmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ-_',
base = alphabets.length;
/**
* Saves the link to the database and returns a shortened one
*
* @param req URL to save and shorten
@mhdatie
mhdatie / AccountAuthenticator.java
Created February 22, 2016 15:00 — forked from burgalon/AccountAuthenticator.java
Implementing OAuth2 with AccountManager, Retrofit and Dagger
public class AccountAuthenticator extends AbstractAccountAuthenticator {
private final Context context;
@Inject @ClientId String clientId;
@Inject @ClientSecret String clientSecret;
@Inject ApiService apiService;
public AccountAuthenticator(Context context) {
super(context);
@mhdatie
mhdatie / PreferenceManager.java
Created September 20, 2015 21:38
Shared preference manager
package com.matie.redgram.data.managers.preferences.main;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by matie on 20/09/15.
*
* Singleton manager
*/
@mhdatie
mhdatie / MainClass.java
Created January 8, 2015 14:45
Connectivity Problem
public class MainClass {
public static void main(String args[]){
String sampleData = "1-2,2-3,3-4,9-0,0-9,2-4,5-6,9-0,8-9,9-8,1-9,1-3,1-10,10-13,11-12,12-15,15-19,19-22,20-22,21-20,18-20,1-20,1-19,1-9,20-21,21-22,22-0,1-22,9-20,9-23,19-8,2-18,7-21,2-21,21-3";
// String sampleData2 = "3-4,4-9,8-0,2-3,5-6,2-9,5-9,7-3,4-8,5-6,0-2,6-1,6-1,0-2,5-6,4-8,7-3,5-9,2-9,5-6,2-3,8-0,4-9,3-4";
// String sampleData3 = "3-4,4-9,8-0,2-3,5-6,2-9,5-9,7-3,4-8,5-6,0-2,6-1,3-4,4-9,8-0,2-3,5-6,0-2,5-9,7-3,4-8,5-6,2-9,6-1,3-4,4-9,8-0,2-3,5-6,2-9,5-9,7-3,4-8,5-6,0-2,6-1";
ProblemMatrix matrix = new ProblemMatrix(new boolean[50][50]);
matrix.setUpMatrix();
@mhdatie
mhdatie / index.html
Last active August 29, 2015 14:10
BarChart
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'>
<script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script>
<script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script>
<script src='//nvd3.org/assets/lib/fisheye.js' type='text/javascript'></script>