Skip to content

Instantly share code, notes, and snippets.

View haidarafif0809's full-sized avatar

Haidar Afif Maulana haidarafif0809

View GitHub Profile
@haidarafif0809
haidarafif0809 / sequelize-index.js
Last active February 21, 2018 10:50
Sequelize Example
const Sequelize = require('sequelize');
const sequelize = new Sequelize('database', 'username', 'password', {
host: 'localhost',
dialect: 'mysql'|'sqlite'|'postgres'|'mssql',
pool: {
max: 5,
min: 0,
acquire: 30000,
idle: 10000
@haidarafif0809
haidarafif0809 / eloquent-example.php
Last active February 21, 2018 11:13
Eloquent Example
//ini sama aja dengan "SELECT * FROM flight"
$flights = App\Flight::all();
//ini sama aja dengan "SELECT * FROM flight WHERE id = 1"
$flight = App\Flight::find(1);
//ini sama aja dengan "SELECT * FROM flight WHERE active = 1 LIMIT 1"
$flight = App\Flight::where('active', 1)->first();
@haidarafif0809
haidarafif0809 / sequelize-select.js
Created February 21, 2018 11:28
orm with sequelize
//ini sama dengan "SELECT * FROM flight WHERE id = 123"
Flight.findById(123).then(project => {
})
//ini sama dengan "SELECT * FROM flight"
Flight.all().then(projects => {
})
@haidarafif0809
haidarafif0809 / index.js
Created March 12, 2018 08:02
Alay Letter Index.js
const alayConverter = function(string) {
let newString = '';
for (var i = 0, len = string.length; i < len; i++) {
if (string[i] == 'a') {
newString += '4';
} else if (string[i] == 's') {
newString += '5';
} else if (string[i] == 'e') {
newString += '3';
} else if (string[i] == 'o') {
@haidarafif0809
haidarafif0809 / test.js
Created March 12, 2018 08:15
Test Alay Letter
const alay = require('./index');
console.log(alay('hello world');
@haidarafif0809
haidarafif0809 / README.md
Created March 12, 2018 08:16
Alay Readme

Alay Letter

Npm Package for convert normal string to alay letter.

How To Use

const alay = require('alay-letter');

console.log(alay('Hello World'));
const car = {
color: 'red',
racingCar: true,
type: 'suv'
engineStart: () => {
console.log('engine start')
}
}
class Car {
constructor(type, color) {
this.type = type
this.color = color
this.engineStatus = 'off'
}
engineStart () {
@haidarafif0809
haidarafif0809 / Car.js
Last active April 4, 2018 07:08
Use Getter and Setter in Classes Javascript
class Car {
constructor() {
this._color = null
}
get color () {
return `Warna Mobilnya adalah ${this._color}`
}
class Car {
constructor(color) {
this.color = color
}
}
const car = new Car('merah')
console.log(car.color)