Skip to content

Instantly share code, notes, and snippets.

View bagaskarawg's full-sized avatar
🏠
Working from home

Bagaskara Wisnu Gunawan bagaskarawg

🏠
Working from home
View GitHub Profile
@bagaskarawg
bagaskarawg / ContactIndexResponse.php
Created May 16, 2018 05:09 — forked from timacdonald/ContactIndexResponse.php
Easily respond to content types and url extensions
<?php
namespace App\Http\Responses;
use App\Models\ContactType;
use App\Factories\CsvFactory;
class ContactIndexResponse extends Response
{
public function __construct($contacts)
@bagaskarawg
bagaskarawg / scan-barcode.js
Created December 12, 2018 08:16
Listen for barcode scanning
var chars, pressed;
pressed = false;
chars = [];
$(window).on('keypress', function(e) {
if (e.which !== 13) {
chars.push(String.fromCharCode(e.which));
}

Installing SSHPASS

SSHPass is a tiny utility, which allows you to provide the ssh password without using the prompt. This will very helpful for scripting. SSHPass is not good to use in multi-user environment. If you use SSHPass on your development machine, it don't do anything evil.

Installing on Ubuntu

apt-get install sshpass

Installing on OS X

IRR(values, guess) {
let irrResult = function(values, dates, rate) {
let r = rate + 1;
let result = values[0];
for (let i = 1; i < values.length; i++) {
result += values[i] / Math.pow(r, (dates[i] - dates[0]) / 365);
}
return result;
};