Skip to content

Instantly share code, notes, and snippets.

View dabit3's full-sized avatar
🎡
probably nothing

Nader Dabit dabit3

🎡
probably nothing
View GitHub Profile
@dabit3
dabit3 / Animated.stagger()
Created August 1, 2016 00:50
React Native Animated.stagger()
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Animated
} from 'react-native'
const arr = []
@dabit3
dabit3 / React Native Easings
Created August 1, 2016 03:38
React Native Easing animations
'use strict';
var React = require('react-native');
var {
AppRegistry,
StyleSheet,
Text,
View,
Easing,
Animated,
@dabit3
dabit3 / services.js
Last active August 17, 2016 13:33
Ionic cordova app
this.doLogin = function(user) {
var deferred = $q.defer(),
nonce_dfd = $q.defer(),
authService = this;
authService.requestNonce("user", "generate_auth_cookie")
.then(function(nonce){
nonce_dfd.resolve(nonce);
});
@dabit3
dabit3 / services.js
Created August 22, 2016 23:16
services.js updated
// initialize
if (typeof PushNotification === "defined") {
// your code here
$cordovaPushV5.initialize(options).then(function() {
// start listening for new notifications
$cordovaPushV5.onNotification();
// start listening for errors
$cordovaPushV5.onError();
// register to get registrationId
@dabit3
dabit3 / Package.json working .32
Created August 28, 2016 01:00
Temporary Package.json working .32
{
"name": "JargonAppV2",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start"
},
"dependencies": {
"axios": "^0.11.1",
"crypto-js": "^3.1.6",
@dabit3
dabit3 / model.js
Created October 20, 2016 05:26
Apollo Tutorial - Model
const Mongoose = require('mongoose');
const PresidentSchema = Mongoose.Schema({
name: String,
party: String,
term: String,
});
const President = Mongoose.model('President', PresidentSchema);
@dabit3
dabit3 / seed.js
Last active October 20, 2016 18:38
Apollo Tutorial - Seed
const request = require('request-promise');
const President = require('./model');
const seed = () => {
request('https://mysafeinfo.com/api/data?list=presidents&format=json')
.then(res => JSON.parse(res))
.then((res) => {
const data = res.map((r) => {
const obj = {};
obj.name = r.nm;
@dabit3
dabit3 / schema.js
Last active October 20, 2016 07:04
Apollo Tutorial - Schema
const typeDefinitions = `
type President {
name: String
party: String
term: String
}
type RootQuery {
president(name: String, party: String, term: String): President
}
schema {
@dabit3
dabit3 / connectors.js
Created October 20, 2016 05:50
Apollo Tutorial - Connector
const PresidentModel = require('./model');
class President {
constructor() {
this.findPresident = (name) => {
const person = PresidentModel.findOne({ name }, (error, data) => {
return data;
});
return person;
};
@dabit3
dabit3 / resolvers.js
Last active October 20, 2016 06:44
Apollo Tutorial - Resolver
const resolveFunctions = {
RootQuery: {
president(_, { name }, ctx) {
const president = new ctx.constructor.President();
return president.findPresident(name);
},
},
};
module.exports = resolveFunctions;