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 / 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 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 / 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 / basic_redis.js
Last active December 16, 2015 12:17
Using Redis
var express = require('express'),
redis = require('redis'),
logger = require('morgan'),
bodyParser = require('body-parser');
var client = redis.createClient(),//CREATE REDIS CLIENT
app = express();
app.use(logger("tiny"));
app.use(bodyParser.urlencoded({ extended: false }))
@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 / pendaftarSummary.R
Last active August 29, 2015 14:03
Membaca statistik dari data pendaftar PPDB (http://www.ppdbkotabandung.web.id/) SMA Kota Bandung 2014-2015.
pendaftarSummary <- function(highschool) {
filename <- paste(highschool,".csv", sep="")
tmp <- read.csv(filename)
S <- summary(tmp$Jumlah.UN)
L <- length(tmp$No)
list(S = S, L = L)
}
@arisetyo
arisetyo / app.js
Created March 16, 2014 13:15
MEAN tutorial, Part 2
var meanApp = angular.module('meanApp', ['ngRoute', 'meanControllers']);
meanApp.config(['$routeProvider', function($routeProvider) {
$routeProvider
.when('/', {
controller:'ListCtrl',
templateUrl:'mod_list.html'
})
.when('/detail/:userId', {
controller:'DetailCtrl',
@arisetyo
arisetyo / db.js
Last active August 29, 2015 13:57
MEAN tutorial, Part 1
var mongoose = require('mongoose');
var Schema = mongoose.Schema,
ObjectId = Schema.ObjectId;
// SCHEMAS
var User = new Schema({
fullname: {type: String, required: true},
email: {type: String, required: true},
password: {type: String, required: true}
});
@arisetyo
arisetyo / server.js
Last active August 29, 2015 13:56
Node and Express 101
var express = require('express');
var app = express();
//configuration
app.configure(function () {
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(app.router);
});