Skip to content

Instantly share code, notes, and snippets.

View paulobunga's full-sized avatar
🏠
Available for work

Paul Obunga paulobunga

🏠
Available for work
View GitHub Profile
@paulobunga
paulobunga / product_model.js
Last active December 18, 2019 00:47
Product Model
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ProductSchema = new Schema({
name: { type: String, required: 'Name is required' },
sale_price: { type: Number, required: 'Sale price is required' },
cost_price: { type: Number, required: 'Cost price is required '},
quantity: { type: Number, default: 0 }
}, {
timestamps: true
@paulobunga
paulobunga / config.yml
Created December 17, 2019 20:36
Circle CI configuration script
version: 2
jobs:
build:
docker:
- image: circleci/php:7.3-apache-node-browsers
working_directory: ~/ci_deploy
steps:
- checkout
@paulobunga
paulobunga / Test.php
Created December 13, 2019 00:08
Our test controller
<?php defined('BASEPATH') OR exit('No direct script access allowed');
use \Firebase\JWT\JWT;
Class Test extends CI_Controller
{
public function index()
{
$key = "example_key";
$token = array(
"iss" => "http://example.org",
@paulobunga
paulobunga / package.json
Created December 11, 2019 20:00
Modify our package.json file
{
"name": "product_manager_api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"dev": "nodemon index.js"
},
"keywords": [],
@paulobunga
paulobunga / index.js
Created December 11, 2019 19:52
Main script
const express = require('express');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const app = express();
const PORT = process.env.PORT || 3000;
const productCtrl = require('./product_controller');
@paulobunga
paulobunga / product_controller.js
Last active December 11, 2019 19:50
Product controller
const Product = require('./product_model');
module.exports = {
getProducts: async (req, res, next) => {
Product.find({}).exec((error, result) => {
if (error) {
return next(error);
}
if (result) {
@paulobunga
paulobunga / product_model.js
Created December 9, 2019 16:01
Product model
const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ProductSchema = new Schema({
name: { type: String, required: true },
qty: { type: Number },
cost_price: { type: Number },
sale_price: { type: Number }
}, {
timestamps: true
[
{
'$match': {
'createdAt': {
'$gte': new Date('Fri, 01 Nov 2019 00:00:00 GMT'),
'$lte': new Date('Sun, 01 Dec 2019 00:00:00 GMT')
}
}
}, {
'$group': {
Sub Create()
'Updateby Extendoffice 20160704
Dim I As Long
Dim xNumber As Integer
Dim xName As String
Dim xActiveSheet As Worksheet
On Error Resume Next
Application.ScreenUpdating = False
Set xActiveSheet = ActiveSheet
xNumber = InputBox("Enter number of times to copy the current sheet")
@paulobunga
paulobunga / RecyclerItemClickListener.java
Created July 17, 2019 09:27 — forked from chetangani/RecyclerItemClickListener.java
Recycler View implementing OnItemTouchListener
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
private OnItemClickListener mListener;
public interface OnItemClickListener {