Skip to content

Instantly share code, notes, and snippets.

View goFrendiAsgard's full-sized avatar

Go Frendi Gunawan goFrendiAsgard

View GitHub Profile
const request = require('request')
// /////////////////////////////////////////////////////////////////////
// Callback mechanism
// /////////////////////////////////////////////////////////////////////
request('http://localhost:3000/genres', function (error, response, body) {
if (error) {
return console.error(error)
}
const request = require('request')
function add (n1, n2) {
return n1 + n2
}
// /////////////////////////////////////////////////////////////////////
// First Section
// /////////////////////////////////////////////////////////////////////
console.log('before-add') // 1
@goFrendiAsgard
goFrendiAsgard / chimera-framework-profiling.md
Created May 15, 2018 11:01
Profiling chimera-framework
  1. Make sure you have mongodb, gcc, python & nodejs installed
  2. Clone chimera-framework (git clone git@github.com:goFrendiAsgard/chimera-framework.git)
  3. Go to chimera-framework directory (cd chimera-framework)
  4. Perform npm test to make sure everything is working.
  5. Perform node --prof node_modules/mocha/bin/_mocha
  6. A profile log file will be produced. In my case, the name of the file is isolate-0x2652d80-v8.log.
  7. Make a more readable log file by performing node --prof-process isolate-0x2652d80-v8.log > profile.log.
  8. Open up profile.log with your favorite text editor
@goFrendiAsgard
goFrendiAsgard / server.js
Created May 10, 2018 14:17
Node.Js profiling
// filename: server.js
// original source: https://www.codementor.io/codementorteam/nodejs-profiling-build-a-high-performance-app-babjg4jf9
// generate profile: node --prof server.js
// make profile readable: node --prof-process isolate-0x101804a00-v8.log
'use strict'
const crypto = require('crypto')
function hash (password) {
const salt = crypto.randomBytes(128).toString('base64')
const hash = crypto.pbkdf2Sync(password, salt, 10000, 512, 'sha512')

Agile Development

  • Individuals and Interactions over processes and tools
  • Working Software over comprehensive documentation
  • Customer Collaboration over contract negotiation
  • Responding to Change over following a plan

Tools

  • MongoDB

Text User Interface VS Graphical User Interface

Text User Interface

Consistant

Simple

Allows you to run many commands in one line

Sys-admins and developers love it

Graphical User Interface

Easy

Intuitive (hopefully)

Allows you to click buttons instead of typing any command

Naive Bayes

Data

Type        |  Long | Not Long || Sweet | Not Sweet || Yellow |Not Yellow|Total
Banana      |  400  |    100   || 350   |    150    ||  450   |  50      |  500
Orange      |    0  |    300   || 150   |    150    ||  300   |   0      |  300
Other Fruit |  100  |    100   || 150   |     50    ||   50   | 150      |  200
            ____________________________________________________________________
Total       |  500  |    500   || 650   |    350    ||  800   | 200      | 1000
@goFrendiAsgard
goFrendiAsgard / scrap-imdb.php
Created October 27, 2017 03:18
Scrap movie from imdb by using regex
<?php
/*
<td class="titleColumn">
1.
<a href="/title/tt0111161/?pf_rd_m=A2FGELUUNOQJNL&amp;pf_rd_p=2398042102&amp;pf_rd_r=03C6KZNHFW3SPT6H7T55&amp;pf_rd_s=center-1&amp;pf_rd_t=15506&amp;pf_rd_i=top&amp;ref_=chttp_tt_1" title="Frank Darabont (dir.), Tim Robbins, Morgan Freeman">The Shawshank Redemption</a>
<span class="secondaryInfo">(1994)</span>
</td>
*/
$pageSource = file_get_contents('http://www.imdb.com/chart/top');
$matches = array();
package binarytreea;
class Node {
Node parent, left, right;
double data;
public Node(double newData) {
this.data = newData;
}
void setLeft(Node other) {
this.left = other;
@goFrendiAsgard
goFrendiAsgard / BinaryTreeB.java
Created October 24, 2017 02:22
Pemrograman dasar 2 kelas B 2017, Binary Tree
package binarytreeb;
class Node {
double data;
Node parent, left, right;
public Node(double newData) {
this.data = newData;
}
void setLeft(Node other) {
if (other == null) {