Skip to content

Instantly share code, notes, and snippets.

@yudapc
yudapc / .command-t
Last active July 30, 2021 09:27
Oh my zsh
if your vim pluggin `command-t` does not work with message:
```
command-t.vim could not load the C extension
```
or with `difference version ruby`
you can try:
```
cd ~/.vim/plugged/command-t/ruby/command-t/ext/command-t
@yudapc
yudapc / chat-frontend.js
Created March 13, 2018 01:05 — forked from martinsik/chat-frontend.js
Node.js chat frontend and server
$(function () {
"use strict";
// for better performance - to avoid searching in DOM
var content = $('#content');
var input = $('#input');
var status = $('#status');
// my color assigned by the server
var myColor = false;
@yudapc
yudapc / sum.rb
Created April 9, 2018 00:38 — forked from ProfAvery/sum.rb
15 ways to sum an array in Ruby
#!/usr/bin/env ruby
require 'test/unit'
class TestSums < Test::Unit::TestCase
def setup
@a = [2, 5, 18, 27]
@sum = 0
end

STEPS

  • Click on Help menu

  • Select Enter License

  • Then paste given KEY given at bottom

  • Finally click on Use License

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;
@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() {
@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

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@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');
}
}
@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