Skip to content

Instantly share code, notes, and snippets.

@ridwanbejo
ridwanbejo / vision.js
Created March 13, 2018 03:28
Google Cloud Vision API Sample Code - OCR + Labeling on Image
// Imports the Google Cloud client library
const vision = require('@google-cloud/vision');
// Creates a client
const client = new vision.ImageAnnotatorClient();
client
.labelDetection('https://www.googleapis.com/download/storage/v1/b/staging.serverlessid.appspot.com/o/licensePlate%2Fsample.jpg?generation=1520858044266983&alt=media')
.then(results => {
@ridwanbejo
ridwanbejo / publisher.py
Last active March 29, 2018 02:50
publisher code in zeromq
import zmq
import json
import random
import time
from uuid import uuid4
from datetime import datetime
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--device_id", help="Device ID that must send the weather data",
@ridwanbejo
ridwanbejo / subscriber.py
Created March 29, 2018 02:44
subscriber code in zeromq
import zmq
import time
from elasticsearch import Elasticsearch
from uuid import uuid4
import json
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--device_id", help="Device ID that must send the weather data",
action="store")
@ridwanbejo
ridwanbejo / consumer.js
Last active April 24, 2018 02:23
consumer source code for clickstream tracker using aws sqs
// Load the AWS SDK for Node.js
var AWS = require('aws-sdk');
var dateFormat = require('dateformat');
// Set the region
AWS.config.update({region: 'ap-northeast-1'});
// Create SQS service object
var sqs = new AWS.SQS({apiVersion: '2012-11-05'});
var queueURL = "<url>/clickstreamQueueDev";
@ridwanbejo
ridwanbejo / producer.js
Last active April 24, 2018 02:24
producer for clickstream tracker
var QUEUE_URL = '<url>/clickstreamQueueDev';
var AWS = require('aws-sdk');
var sqs = new AWS.SQS({region : 'ap-northeast-1'});
exports.handler = function(event, context, callback) {
var params = {
MessageBody: event.body,
QueueUrl: QUEUE_URL
};
@ridwanbejo
ridwanbejo / docker-compose.yml
Created May 24, 2018 10:02
Portainer docker compose file
version: '2'
services:
portainer:
image: portainer/portainer
command: -H unix:///var/run/docker.sock
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- portainer_data:/data
ports:
@ridwanbejo
ridwanbejo / stack-adt.py
Created October 23, 2018 05:00
Install dulu python, terus jalankan dengan perintah: python main.py
class StackArray(object):
"""
Perbandingan sintaks Python dan Java
- self = this
- def = function
- None = null
"""
def create_stack(self, panjang):
self.panjang = panjang
@ridwanbejo
ridwanbejo / queue-adt.py
Created October 25, 2018 09:39
jalankan file ini dengan menggunakan "python queue-adt.py" di dalam cmd atau terminal
class QueueArray(object):
def create_queue(self):
self.queue = []
def destroy_queue(self):
self.queue = None
def enqueue(self, nilai):
if type(self.queue) != None:
@ridwanbejo
ridwanbejo / tugas-mandat-pertemuan-4.sql
Created October 26, 2018 06:31
Berisi DDL untuk membangun database perjalanan kereta di P.T. KAI sebagai studi kasus.
CREATE DATABASE kereta_api_indonesia;
use kereta_api_indonesia;
CREATE TABLE country (
id_country INT PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(50) NOT NULL
);
INSERT INTO country (name) VALUES ('Indonesia');
@ridwanbejo
ridwanbejo / tugas-mandat-naive-bayes-non-cv.r
Last active January 15, 2019 09:55
naive bayes classification non cross validation
library(e1071)
library(gmodels)
# 1. Load dataset from CSV
bank_csv <- read.csv("./Downloads/bank-additional/bank-additional-full.csv", header=TRUE, sep=";")
bank_df <- as.data.frame(bank_csv[1:32951,])
summary(bank_df)
# 2. Do the preprocessing