Skip to content

Instantly share code, notes, and snippets.

View arisetyo's full-sized avatar
💭
To live is to create. And to create is immortality.

Arie M. Prasetyo arisetyo

💭
To live is to create. And to create is immortality.
View GitHub Profile
@arisetyo
arisetyo / 1-test-mongo.js
Created February 28, 2021 08:11
Introduction to async/await in Node JS
/**
* @author Arie M. Prasetyo
*/
const mongoose = require('mongoose');
const mongoConfig = {useNewUrlParser: true, useUnifiedTopology: true};
// connect to Mongo database
mongoose.connect('mongodb://localhost:27017/test', mongoConfig);
// define the model
@arisetyo
arisetyo / index.html
Created July 4, 2013 16:33
Basic chat using Node, Express, Socket.io, & Knockout.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Galenic">
<script src="js/knockout-2.1.0.js"></script>
<link rel="stylesheet" href="pure-min.css">
<link rel="stylesheet" href="custom.css">
<title>Node Showcase</title>
@arisetyo
arisetyo / gsheet.js
Created March 27, 2022 07:13
Accessing Google Sheet using NodeJS
/**
* Example of a simple data request to a Google Sheet spreadsheet.
* Requirements:
* 1. Make sure the spreadsheet is public
* 2. Get an API key from Google Developer Console
*/
const axios = require('axios');
const apiKey = "YOUR_GOOGLE_DEVELOPER_API_KEY";
@arisetyo
arisetyo / index.html
Created July 12, 2013 16:37
Dynamic Real-time Chart Using Chart.js, Socket.io, and Knockout.js
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Galenic">
<script src="js/jquery-1.9.1.js"></script>
<script src="js/knockout-2.1.0.js"></script>
<script src="js/Chart.js"></script>
<link rel="stylesheet" href="pure-min.css">
@arisetyo
arisetyo / index.html
Created June 5, 2021 12:32
A simple example of using local storage
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Local storage</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
@arisetyo
arisetyo / index.html
Created May 24, 2021 02:47
Beams SDK integration for push notification on the browser
<!DOCTYPE html>
<html lang="en">
<head>
<title>Beams SDK integration</title>
</head>
<body>
<h1>Beams SDK integration</h1>
<!-- Install the SDK -->
<script src="https://js.pusher.com/beams/1.0/push-notifications-cdn.js"></script>
@arisetyo
arisetyo / openpage.js
Last active February 26, 2019 07:36
Webpage Screen Capture Using NodeJS and PhantomJS
var page = require('webpage').create();
var url = 'http://phantomjs.org/quick-start.html';
//SPECIFY VIEWPORT SIZE OF THE SCREENCAPTURE
page.viewportSize = {
width: 1280,
height: 900
};
@arisetyo
arisetyo / index.html
Created July 9, 2013 15:51
Using Chart.js, Knockout.js, and jQuery for a chart with dynamic data
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-1.9.1.js"></script>
<script src="js/knockout-2.1.0.js"></script>
<script src="js/Chart.js"></script>
</head>
<body>
<div>
@arisetyo
arisetyo / get.py
Created January 7, 2014 03:01
Using Python ElasticSearch Client
from elasticsearch import Elasticsearch
es = Elasticsearch()
res = es.get(index="belajar", doc_type='pesan', id=1)
print(res['_source'])
@arisetyo
arisetyo / html_excerpt.html
Created November 16, 2012 13:02
HTML5 Audio Player with Knockout.js Playlist
<audio id="audioplayer" controls="controls" autoplay="autoplay" data-bind="attr:{src: selectedFile}"></audio>
<p>Selected song: <span id="audioplayer" data-bind="text: selectedSong"></span></p>
<img data-bind="attr:{src: selectedCover}" width="200"/>
<tbody data-bind="foreach: availableSongs">
<tr>
<td data-bind="text: artist"></td>
<td><img data-bind="attr:{src: cover}" width="60"/>&nbsp;<span data-bind="text: album"></span></td>
<td data-bind="text: title"></td>
<td><a href="#" data-bind="click: $root.selectSong">PLAY</a></td>