Skip to content

Instantly share code, notes, and snippets.

Avatar

Derdus derduskenga

View GitHub Profile
@derduskenga
derduskenga / 20200729005825-create-user.js
Last active Jul 29, 2020
decoded app - setting up node app
View 20200729005825-create-user.js
'use strict';
module.exports = {
up: async (queryInterface, Sequelize) => {
await queryInterface.createTable('Users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
},
View post.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Post extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
View tag.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Tag extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
View posttag.js
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class PostTag extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
View 20200729131649-demo-users.js
'use strict';
const fake = require('faker');
module.exports = {
up: async (queryInterface, Sequelize) => {
let users = [];
for(let i=0; i<=100; i++){
users.push({
name: fake.name.firstName(),
email:fake.internet.email(),
createdAt:new Date(),
View 20200729133702-demo-post.js
'use strict';
const fake = require('faker');
module.exports = {
up: async (queryInterface, Sequelize) => {
let users = await queryInterface.sequelize.query(
`SELECT id from Users;`
);
let posts = [];
for(let i=0; i<=100; i++){
View userRoutes.js
const express = require('express');
const userController = require('../controllers/userController');
const route = express.Router();
route.post('/user', userController.newUser);
module.exports = route;
View index.js
const express = require('express');
const routes = require('./routes/userRoutes');
const Parser = require('body-parser');
const app = express();
app.use(Parser.urlencoded({extended:true}));
app.use(routes);
app.listen(process.env.API_PORT);
@derduskenga
derduskenga / home.js
Created Sep 23, 2020
This is a gist example
View home.js
console.log('Testing something')
@derduskenga
derduskenga / index.php
Last active Jul 27, 2021
Implementing a mobile money USSD menu with branded SMS app
View index.php
<?php
$menu = new Menu();
if($text == "" && $isUserRegistered == true){
//user is registered and string is is empty
echo "CON " . $menu->mainMenuRegistered("<Add a name here>");
}else if($text == "" && $isUserRegistered== false){
//user is unregistered and string is is empty
$menu->mainMenuUnRegistered();
}else if($isUserRegistered== false){
//user is unregistered and string is not empty