To test the api and see if you are doing the right thing,
-
method:"POST",
-
type:x-www-form-urlencoded
-
params:
{
import morgan from 'morgan'; | |
import bodyParser from 'body-parser'; | |
import express from 'express'; | |
import debug from 'debug'; | |
import { | |
ifError | |
} from 'assert'; | |
// apps exported from their directories | |
import chichi from '../chichi/main' |
const test = { Item:[ { Name: 'Amount', Value: 5 },{ Name: 'MpesaReceiptNumber', Value: 'LI85581A6Z' },{ Name: 'Balance' }, {Name: 'TransactionDate', Value: '20170908181744' }, { Name: 'PhoneNumber', Value: '254723587767' } ] } | |
const corrected = {} | |
test.Item.map(node=>corrected[node.Name] = node.Value) | |
console.log(corrected) | |
// { Amount: 5, | |
// MpesaReceiptNumber: 'LI85581A6Z', |
To test the api and see if you are doing the right thing,
method:"POST",
type:x-www-form-urlencoded
params:
{
The following code snippet illustrates how to use sabek's graph api in your application, to login to your account and get an authorisation token and log in and request for your data
const async = require("async")
const request = require('request');
var token;
const assert = require("assert")
# run chmod +x ./setup-droplet.sh to make the file executable | |
#install java8 and latest stable cassandra then install latest node | |
#kill the started cassandra process | |
#open the cassandra.yaml file and replace *localhost* with the server's ip address | |
sudo add-apt-repository ppa:webupd8team/java && sudo apt-get update && sudo apt-get install oracle-java8-installer && sudo apt-get install oracle-java8-set-default && echo "deb http://debian.datastax.com/community stable main" | sudo tee -a /etc/apt/sources.list.d/cassandra.sources.list && curl -L http://debian.datastax.com/debian/repo_key | sudo apt-key add - && sudo apt-get update && sudo apt-get install cassandra && curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - && sudo apt-get install -y nodejs && ps -ef | grep cassandra | grep -v grep | awk '{print $2}' | xargs kill && ex -s +%s/localhost/192.241.151.182/ge -cwq /etc/cassandra/cassandra.yaml && ex -s +%s/12.0.0.17/192.241.151.182/ge -cwq /etc/cassandra/cassandra.yaml | |
<html><link href="../../plugins/pace/pace.min.css" rel="stylesheet"><script src="./src/pace.js" type="text/javascript"></script><meta charset="utf-8"><meta content="IE=edge" http-equiv="X-UA-Compatible"><title>AdminLTE 2 | Starter</title><meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"><link href="bootstrap/css/bootstrap.min.css" rel="stylesheet"><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"><link href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/css/ionicons.min.css" rel="stylesheet"><link href="dist/css/AdminLTE.min.css" rel="stylesheet"><meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"><link href="../../bootstrap/css/bootstrap.min.css" rel="stylesheet"><link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"><link href="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2. |
var m = require('mithril'); | |
module.exports = { | |
controller:function (argument) { | |
console.log("called the controller") | |
// fetch the db | |
return { | |
name:"awesomness" | |
} |
# -*- coding: UTF-8 -*- | |
import os | |
import logging | |
import json | |
from pyramid.config import Configurator | |
from pyramid.events import NewRequest | |
from pyramid.events import subscriber | |
from pyramid.events import ApplicationCreated | |
from pyramid.exceptions import NotFound |
var async = { | |
parallel: function(funcs, complete) { | |
console.log("parallel") | |
var counter = 0 | |
var callback = function(argument) { | |
counter = counter + 1 | |
if (counter == funcs.length) { | |
setTimeout(complete, 0); | |
} | |
} |
so i have always watched netflix database backend talks and they talk about cassandra and how awesome it is. Lots of other companies have sang the DSE song and i have wanted to try it. so installing cassadra on the client is a breeze and fun. The i tried to do the same on the server, so naturally i selected the best free Paas things we have out there. so i can get a server that doesnt go out after 30mins(pun heroku) and also one that allows me to store data not flush my space after every restart (trol heroku). So after a LONG time trying to get this to run LOL (a few tried over a month) i finally got this to work well.
so we need cassandra to get running, then make something to talk to it via any of the official drivers DSE provides. for this case ill use the famous node js...
at the time of writing this the latest version are
node - 6.x
cassandra - 3.6
node-cassandra driver - 3.0