Skip to content

Instantly share code, notes, and snippets.

@mishbah
mishbah / .mongoshrc.js
Created September 5, 2024 00:27
Simpan method ini di ~/.mongoshrc.js
function copyCollections(
sourceDbName,
collectionNames = [],
targetDbName = "tenant_operation",
batchSize = 1000
) {
const sourceDb = db.getSiblingDB(sourceDbName);
const targetDb = db.getSiblingDB(targetDbName);
for (const collectionName of collectionNames) {
@mishbah
mishbah / bluetoot.md
Created August 12, 2024 00:50
cara menyambung bluetoot melalui terminal linux

Untuk menyambungkan perangkat Bluetooth di Linux melalui terminal, Anda dapat menggunakan alat bluetoothctl. Berikut adalah langkah-langkahnya:

1. Pastikan Bluetooth Aktif

Buka terminal di sistem Linux Anda. Pastikan layanan Bluetooth berjalan. Anda dapat memeriksa dan memulai layanan Bluetooth dengan perintah berikut:

sudo systemctl start bluetooth
sudo systemctl enable bluetooth
@mishbah
mishbah / contoh_mockall_di_actix_web.md
Last active May 28, 2024 00:13
Contoh `mockall` di actix-web. sumber: Claude 3 Haiku

Berikut adalah contoh penggunaan mockall untuk mocking dependencies pada Actix-Web, beserta unit test:

  1. Buat sebuah service yang akan diuji, misalnya user_service.rs:
use actix_web::{get, web, Responder};
use mockall::predicate::*;
use mockall::MockResult;

#[derive(Debug)]
@mishbah
mishbah / gist:c26ff8d4487357bb5bb201006e0c461b
Created August 11, 2022 02:58
generate random string for secret key using node
# in node repl, type...
require('crypto').randomBytes(64).toString('hex')
@mishbah
mishbah / console.js
Created September 30, 2021 01:29
Facebook's console warning
const fontMerah = 'font-size:50px; font-weight:bold; color:red; -webkit-text-stroke:1px black;';
const fontBiasa = 'font-family:helvetica; font-size:20px;'
console.log('%cStop!', fontMerah);
console.log('%cThis is a browser feature intended for developers. If someone told you to copy and paste something here to enable a Facebook feature or "hack" someone\'s account, it is a scam and will give them access to your Facebook account.', fontBiasa);
console.log('%cSee https://www.facebook.com/selfxss for more information.', fontBiasa);
mysql mongod teamviewerd mssql-server nginx redis-server postgresql
# how to enable, disable, start, stop, and status
sudo systemctl enable <name_of_service>
sudo systemctl start <name_of_service>
sudo systemctl status <name_of_service>
sudo systemctl stop <name_of_service>
sudo systemctl disable <name_of_service>
@mishbah
mishbah / gist:b46673e817848d7fae83e14b6a6b631f
Last active March 14, 2018 11:31 — forked from giannisp/gist:ebaca117ac9e44231421f04e7796d5ca
Upgrade PostgreSQL 9.6.5 to 10.3 using Homebrew (macOS)
After automatically updating Postgres to 10.3 via Homebrew, the pg_ctl start command didn't work.
The error was "The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 10.3."
Database files have to be updated before starting the server, here are the steps that had to be followed:
# if default not linked to version 10.3 run this script,otherwise skip
# need to have both 9.6.x and latest 10.3 installed, and keep 10.3 as default
# brew unlink postgresql
# brew install postgresql@9.6
# brew unlink postgresql@9.6
@mishbah
mishbah / php-gettersetter.sublime-snippet
Created September 1, 2016 06:11
Snippet for php getter and setter for sublimetext (tested at sublimetext v3)
<snippet>
<content><![CDATA[/**
* Getter for ${1:$SELECTION}
*
* @return ${2:mixed}
*/
public function get${1/^(\w)|(?:_(\w))|(?:_)/(?1\u$1:)(?2\u$2:)/g}()
{
return \$this->$1;
}
@mishbah
mishbah / embuh.php
Created August 23, 2016 04:15
Kasus array
$sepatuVarian = [
'KTK001',
'KTK002',
'KTK003',
'KTK004',
'KTK005',
'KTK006'
];
$varians = [
@mishbah
mishbah / .vimrc
Created December 28, 2015 01:35 — forked from JeffreyWay/.vimrc
My .vimrc file
set nocompatible " Disable vi-compatibility
set t_Co=256
colorscheme xoria256
set guifont=menlo\ for\ powerline:h16
set guioptions-=T " Removes top toolbar
set guioptions-=r " Removes right hand scroll bar
set go-=L " Removes left hand scroll bar
set linespace=15