Skip to content

Instantly share code, notes, and snippets.

View haidarafif0809's full-sized avatar

Haidar Afif Maulana haidarafif0809

View GitHub Profile
@haidarafif0809
haidarafif0809 / redis.js
Last active October 18, 2022 19:19
Redis Middleware using in nodejs express js.
const redis = require("redis");
const redis_url = process.env.REDIS_URL || null;
const client = redis.createClient(redis_url);
module.exports = {
getCached: (req, res, next) => {
const { redis_key } = req.headers
client.get(redis_key, function(err, reply) {
if (err) {
@haidarafif0809
haidarafif0809 / app.yaml
Created April 17, 2018 11:54
App yaml to deploy to google app engine
runtime: nodejs
env: flex
@haidarafif0809
haidarafif0809 / package.json
Created April 17, 2018 11:45
Package.json travis
{
"name": "travis-ci",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"test": "mocha --exit"
},
"dependencies": {
"body-parser": "~1.18.2",
@haidarafif0809
haidarafif0809 / index.test.js
Created April 17, 2018 11:43
Test Express Mocha Chai Chai-http
const chai = require('chai');
const chaiHttp = require('chai-http');
const app = require('../app')
const expect = chai.expect
chai.use(chaiHttp)
describe('App', () => {
it('should run without any problem', () => {
@haidarafif0809
haidarafif0809 / main.js
Created April 7, 2018 12:20
Main js of Hujan Duren The Game
// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
Vue.config.productionTip = false
Vue.use(require('vue-shortkey'))
/* eslint-disable no-new */
@haidarafif0809
haidarafif0809 / Home.vue
Last active April 7, 2018 12:24
Game Board of Hujan Duren The Game
<template>
<div class="container">
<div class="playboard">
<div class="duren" :style="{ 'margin-left': marginLeftDuren + '%', 'top': 'calc(' + marginTopDuren + '% - 20px)' }"></div>
</div>
<div class="controller">
<div class="bucket" :style="{ 'margin-left': marginLeft + '%', 'margin-top': marginTopBucket + '%'}">
</div>
<button v-shortkey="['arrowleft']" @shortkey="moveLeft" @click="moveLeft"class="button">Kiri</button>
<button v-shortkey="['arrowright']" @shortkey="moveRight" @click="moveRight " class="button">Kanan</button>
@haidarafif0809
haidarafif0809 / store.js
Last active April 4, 2018 10:56
Create Store Redux
import { createStore } from 'redux'
import reducer from './reducer'
const store = createStore(reducer)
export default store
class Car {
constructor(color) {
this.color = color
}
}
const car = new Car('merah')
console.log(car.color)
@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(type, color) {
this.type = type
this.color = color
this.engineStatus = 'off'
}
engineStart () {