Skip to content

Instantly share code, notes, and snippets.

@JaniKibichi
JaniKibichi / app.js
Created October 2, 2016 10:34
Sample code about uploading pictures to cloudinary using multer - NodeJs ExpressJS Framework
'use strict';
var express = require("express");
var multer = require('multer');
var app = express();
var options = require('./config/config')
var mongoose = require('mongoose');
/* photo manenos */
var cloudinary = require('cloudinary');
@JaniKibichi
JaniKibichi / nginxproxy.md
Created October 8, 2016 12:16 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@JaniKibichi
JaniKibichi / nginx.conf
Created November 29, 2016 05:58
Configuring Nginx for HTTPS - Ubuntu 16.04 LTS
#Start of server blocks
# HTTP - redirect all requests to HTTPS:
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name www.another.com another.com;
return 301 https://$server_name$request_uri;
}
@JaniKibichi
JaniKibichi / dbconnect.php
Created November 29, 2016 09:40
How to connect a USSD to a MYSQL DB
<?php
//Declare the Connection Credentials
$servername = 'localhost'; //or IP address for DB hosted elsewhere
$username = 'root';
$password = "";
$database = "ussd";
$dbport = 3306;
// Create connection
$db = new mysqli($servername, $username, $password, $database, $dbport);
// Check connection, if there is an error end the USSD connection
@JaniKibichi
JaniKibichi / nginxforvar.conf
Created January 5, 2017 15:07
https for var/www sites
#Start of server blocks
# HTTP - redirect all requests to HTTPS:
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name hey.another.com;
return 301 https://$server_name$request_uri;
}
@JaniKibichi
JaniKibichi / nginx-hhvm.conf
Created January 7, 2017 09:53
Nginx Config with HHVM
#Start of server blocks
# HTTP - redirect all requests to HTTPS:
server {
listen 80;
#listen [::]:80 default_server ipv6only=on;
server_name another.com;
return 301 https://$server_name$request_uri;
}
@JaniKibichi
JaniKibichi / atgateway1.php
Created January 8, 2017 07:53
Africastalking Gateway 1
<?php
/*
# COPYRIGHT (C) 2014 AFRICASTALKING LTD <www.africastalking.com>
AFRICAStALKING SMS GATEWAY CLASS IS A FREE SOFTWARE IE. CAN BE MODIFIED AND/OR REDISTRIBUTED
UNDER THE TERMS OF GNU GENERAL PUBLIC LICENCES AS PUBLISHED BY THE
FREE SOFTWARE FOUNDATION VERSION 3 OR ANY LATER VERSION
@JaniKibichi
JaniKibichi / atgateway2.php
Created January 8, 2017 07:55
Africastalking Gateway with Payments
<?php
/*
# COPYRIGHT (C) 2014 AFRICASTALKING LTD <www.africastalking.com>
AFRICAStALKING SMS GATEWAY CLASS IS A FREE SOFTWARE IE. CAN BE MODIFIED AND/OR REDISTRIBUTED
UNDER THE TERMS OF GNU GENERAL PUBLIC LICENCES AS PUBLISHED BY THE
FREE SOFTWARE FOUNDATION VERSION 3 OR ANY LATER VERSION
@JaniKibichi
JaniKibichi / SMSCallback.php
Last active January 27, 2022 10:54
What you have on the callback.
<?php
$Sender = $_POST['from'];
$to = $_POST['to'];
$text = $_POST['text'];
$date = $_POST['date'];
$id = $_POST['id'];
$linkId = $_POST['linkId']; //This works for onDemand subscription products
//Sending Messages using sender id/short code
@JaniKibichi
JaniKibichi / MTSMSCallback.php
Created January 31, 2017 08:15
A callback code for Handling MT Shortcodes
<?php
require_once(‘DBConn.php’); //this is your Database connection information, where you also abstract $apiUsername, $apikey
require_once(‘AfricasTalkingGateway.php’);
//next we receive notification from API
//and read in post params to our variables
$apiUsername =’XXXXX’;