Skip to content

Instantly share code, notes, and snippets.

View mul14's full-sized avatar
:octocat:
Preparing for big things...

Mulia Nasution mul14

:octocat:
Preparing for big things...
View GitHub Profile
@mul14
mul14 / CPP_test.md
Last active July 9, 2019 11:44
Programming Test

Buatlah objek Person yang memiliki nama, tanggal lahir, jenis kelamin, tingkat kekuatan. Objek tersebut juga dapat berjalan, berlari, dan melompat.

Buatlah objek SuperHero yang mewarisi semua yang dimiliki Person dan memiliki nama julukan super hero. SuperHero dapat melakukan hal-hal yang tidak bisa Person lakukan, seperti terbang, tembus pandang, dan tingkat kekuatan lebih tinggi daripada Person.

Semua property dan kemampuan yang ada di Person tetap dapat dipanggil melalui SuperHero.

@mul14
mul14 / README.md
Last active January 4, 2024 12:34
Replace Laravel String and Array Helpers to Facade with regex
@mul14
mul14 / Form.js
Last active January 15, 2019 10:04
Vue.js Form class
class Form {
constructor (data) {
this._originalData = Object.assign({}, data)
for (let key in data) {
this[key] = data[key]
}
}
@mul14
mul14 / readme.md
Last active October 13, 2020 06:37
JavaScript Upload FormData
<form id="form">
  <input type="name" name="full_name" />
  <input type="file" name="image" />
  <button type="submit">Submit</button>    
</form>
// Fetch
@mul14
mul14 / profile.md
Created October 26, 2018 00:35 — forked from ezekg/profile.md
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b
@mul14
mul14 / vue.config.js
Created October 23, 2018 14:25
Vue Configuration
const PurgecssPlugin = require('purgecss-webpack-plugin')
// const PurifycssPlugin = require('purifycss-webpack')
const glob = require('glob-all')
const path = require('path')
module.exports = {
lintOnSave: false,
configureWebpack: {
@mul14
mul14 / encrypto.js
Created October 15, 2018 17:05
Node.js v10 - crypto.createDecipheriv()
// This is example of using crypto.createCipheriv(), because
// crypto.createCipher() is deprecated since Node.js v10
const crypto = require('crypto')
const encrypto = {
encrypt(text, password) {
const key = password.repeat(32).substr(0, 32)
const iv = password.repeat(16).substr(0, 16)
@mul14
mul14 / index.js
Created July 25, 2018 14:29
JavaScript DocBlock Cheat Sheet
/**
* Description of this function.
*
* @param {string} name
* @param {Date} birthday
* @param {boolean=} isMarried Optional parameter.
* @param {string|null} [bloodType]
* @param {number=} [weight=0] Optional parameter with default value.
* @param {string[]} favoriteFoods Array of String.
*
@mul14
mul14 / async-await.js
Last active July 6, 2018 10:55
Asynchronous in JavaScript
function randomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1) + min)
}
const saveToCloud = () => {
return new Promise((resolve, reject) => {
const delay = randomInt(500, 3000)
setTimeout(() => {
resolve('Save to cloud success in ' + delay + 'ms')
@mul14
mul14 / demo.js
Created June 26, 2018 14:46
Example @ts-check usage
function getTemprature() {
return 20
}
if (getTemprature > 100) {
alert('DANGER!')
} else {
alert("It's ok")
}