Skip to content

Instantly share code, notes, and snippets.

View RiansyahTohamba's full-sized avatar
💭
on learning

Riansyah Tohamba RiansyahTohamba

💭
on learning
View GitHub Profile
@RiansyahTohamba
RiansyahTohamba / nodemailer_spy.js
Created May 23, 2023 03:46
Nodemailer testing without actually send Email
const Lab = require("@hapi/lab");
const { expect } = require("chai");
const sinon = require("sinon");
const nodemailer = require("nodemailer");
const { PASS_MAIL, USER_MAIL } = process.env;
const { init } = require("../server_test");
const {
describe, it, beforeEach, afterEach,
pipeline {
agent any
parameters {
booleanParam description: 'Is this a production deployment?', name: 'DEPLOY_PROD_PORTAL'
}
environment {
SSH_HOST = '10.2.xx.yyy'
SSH_USER = 'yaadmin'
@RiansyahTohamba
RiansyahTohamba / nodejs-reminder-cron.js
Last active May 12, 2023 02:01
nodejs set reminder by using cron job
Here's an example of a Node.js script that sets a reminder for a certain date using the node-cron package:
// particular date
const cron = require('node-cron');
const reminderDate = new Date("2022-12-31 23:59:00");
const schedule = cron.schedule(reminderDate, () => {
console.log("Reminder: Do something!");
stages:
- publish
- deploy
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_DRIVER: overlay2
@RiansyahTohamba
RiansyahTohamba / example_promise.js
Created January 17, 2022 11:24
example of promise.js
function getProducts(url){
const promise = new Promise((resolve,reject) => {
const data = getData(url);
if(data.isExist()){
resolve(data.to_json());
}else{
reject("error");
}
})
@RiansyahTohamba
RiansyahTohamba / percent_increase.rb
Last active January 12, 2022 22:54
measure percent of increase in source code
# delta_nom.rb
require 'sqlite3'
class Measurement
def initialize(project)
@db_path = "dch-jcodeodor/#{project}/sqlite-jcodeodor/database"
end
# db_sqlite berisi (before || after)
def get_nom(db_sqlite)
@RiansyahTohamba
RiansyahTohamba / Author.js
Created January 8, 2022 08:21
Object Oriented Javascript
class Author{
constructor(name, year){
this.name = name;
this.year = year;
}
ieeeFormat(){
console.info(`[${this.name},${this.year}]`);
}
@RiansyahTohamba
RiansyahTohamba / ExecuteExternalDialog.java
Last active November 12, 2021 21:55
This code from DrJava
// read makeCommandPane.md
class ExecuteExternalDialog{
private JPanel makeCommandPane() {
JPanel panel = new JPanel(new BorderLayout());
ngapain1();
panel.add(main, BorderLayout.CENTER);
bottom = getBottom();
panel.add(bottom, BorderLayout.SOUTH);
ngapain2();
1.8
# catatan
# file ini dipindahkan di home directory
# jika sudah di home, hapus komentar catatan ini
# isi file hanya versi java
import nltk
# ubah jadi tipe nltk
def convertToText(filename):
# raw/str -> token/list -> convert ke nltk.Text
raw = open(filename).read()
# type(raw) == string
tokens = nltk.word_tokenize(raw)
# type(tokens) == list
# token bisa berupa tanda-baca{?.,etc}, pos = {adverb,adj,}
return nltk.Text(tokens)