Skip to content

Instantly share code, notes, and snippets.

@yudapc
yudapc / REACT BUILD package.json
Created July 10, 2020 07:03
REACT CRA Custom BUILD with adding version ?v=
VERSION By Unix Timestamps
{
"scripts": {
"postbuild": "VERSION=`date +%s` && sed -i -- 's/js\"/js?v='${VERSION}'\"/g' build/index.html && sed -i -- 's/css\"/css?v='${VERSION}'\"/g' build/index.html && npx rimraf build/**/*.map",
"build": "GENERATE_SOURCEMAP=false react-scripts-ts build && npm run postbuild && gzipper --verbose ./build"
}
}
VERSION by latest commit hash
{
@yudapc
yudapc / can not open vi on your terminal, because wrong PATH
Last active June 18, 2019 01:44
Can not open vi on your terminal, because wrong PATH
I have ever can not open vi or vim or my bash does not work.
I remember what I did.
Because I changed PATH on ~/.zshrc :D
So, for restore you can run this command:
`export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin`
console style:
console.log('%c Bhinneka', 'color: red; font-weight: bold; font-size: 40px');
console.log('%c PT. Bhinneka MentariDimensi', 'color: #000; font-size: 18px');
console.log('join us: "http://career.bhinneka.com"');
@yudapc
yudapc / README.md
Last active March 28, 2019 04:27 — forked from pbojinov/README.md
Two way iframe communication- Check out working example here: http://pbojinov.github.io/iframe-communication/

Two way iframe communication

The main difference between the two pages is the method of sending messages. Recieving messages is the same in both.

Parent

Send messages to iframe using iframeEl.contentWindow.postMessage Recieve messages using window.addEventListener('message')

iframe

@yudapc
yudapc / A sailsjs - docker ReadME
Last active March 13, 2019 08:29
sailsjs - docker
Build image:
$ docker build -t yudapc/sailsjs:0.0.1 .
Build container:
$ docker-compose up -d
Stop Container:
$ docker-compose down -v
@yudapc
yudapc / Javascript Format NPWP
Last active November 16, 2023 03:21
Javascript Format NPWP. NPWP is ID tax each people of indonesian. Specificly in frontend need to format NPWP before render to user
//
// Javascript Format NPWP
//
function formatNpwp(value) {
if (typeof value === 'string') {
return value.replace(/(\d{2})(\d{3})(\d{3})(\d{1})(\d{3})(\d{3})/, '$1.$2.$3.$4-$5.$6');
}
}

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@yudapc
yudapc / moment js
Created September 20, 2018 14:55
moment js
Cheat moment:
http://momentjs.com/
http://momentjs.com/timezone/
moment = require('moment-timezone')
get current time AM/PM
moment().format('hh:mm A')
// 09:54 PM
@yudapc
yudapc / LoginController.js
Created July 26, 2018 14:58 — forked from psi-4ward/LoginController.js
Sails.JS JWT Auth
// controllers/LoginController.js
module.exports = {
index: function(req, res) {
var email = req.param('email');
var password = req.param('password');
// delay everthing to prevent bruteforce, dos and timing attacks
setTimeout(function() {
import React, { Component } from 'react';
import { ScrollView, View, Text, Dimensions } from 'react-native';
const widthLeftSide = 0.7; // 70%
const widthDevice = Dimensions.get('window').width * widthLeftSide;
const column = 3;
const padding = 16;
const totalPadding = padding * (column * 2);
const cardBoxWidth = (widthDevice - totalPadding) / column;
const customPaddingRight = 4 * 6.5;