Skip to content

Instantly share code, notes, and snippets.

View susilolab's full-sized avatar

Agus Susilo susilolab

View GitHub Profile
@susilolab
susilolab / rust-connect-to-tcp-server.md
Created February 25, 2023 03:49
Connect to TCP Server in Rust

Connect to TCP Server in Rust

use std::net::{SocketAddr, TcpStream};

fn main() {
    if let Ok(_stream) = TcpStream::connect("google.com:80") {
        println!("Ok");
    } else {
 println!("Error");
@susilolab
susilolab / penggunaan-promisify-nodejs.md
Last active June 26, 2023 11:02
Penggunaan promisify pada nodejs untuk fungsi2 yang masih menerapkan callback

Penggunaan promisify pada nodejs untuk fungsi2 yang masih menerapkan callback agar bisa digunakan dengan keyword await

contoh penggunaan promisify pada module fs untuk membaca folders

// list_folder.mjs
import { promisify } from 'node:util'
import fs from 'fs'

const readdir = promisify(fs.readdir)
@susilolab
susilolab / fix-cors-yii1-or-php.md
Last active February 25, 2023 02:37
Fix masalah cors pada nginx yang default httpnya versi 2.0

Mengatasi error cors pada Yii v1.1 yang menggunakan nginx dengan default http 2.0

cukup taruh ini pada controller base pada fungsi init:

public function init()
{
    header('Access-Control-Allow-Origin: *');
    header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization');
 header("Access-Control-Allow-Credentials: true");
@susilolab
susilolab / otp-distribution-elixir.md
Last active February 22, 2023 13:57
OTP Distribution di Elixir yang berbeda IP Address

OTP Distribution Elixir

Cara menghubungkan 2 node yang berbeda IP Address. misalnya terdapat 2 node yang berbeda 192.168.1.10 dan 192.168.1.20. caranya dengan menggunakan nama --name saat terhubung dengan iex.

contoh dengan asumsi versi erlangnya sama persis.

node 1:

iex --name ali@192.168.1.10 --cookie rahasia

@susilolab
susilolab / detected-filetype.md
Created November 16, 2022 02:22
Cek tipe file yang didetect oleh neovim

Buka file di neovim kemudian pada mode normal ketikan command ini

:set filetype?

maka neovim akan mencetak tipe file saat ini misalnya typescriptreact

@susilolab
susilolab / block-devices-linux.md
Last active October 15, 2022 12:58
Mengetahui block device dari perangkat usb di linux

lsusb

akan didapat seperti ini:

Bus 001 Device 013: ID 1a2c:9df4 China Resource Semico Co., Ltd USB Gaming Keyboard

path devicesnya dari perangkat di atas yaitu:

/dev/bus/usb

@susilolab
susilolab / window_service.rs
Last active October 8, 2022 01:16
Windows service tcp server
use std::ffi::OsString;
use std::env;
use std::sync::{Arc, Mutex, mpsc};
use std::time::Duration;
use tokio::{
net::TcpListener,
io::{
AsyncReadExt, AsyncWriteExt
},
};
@susilolab
susilolab / solusi-mariadb-prepare.md
Last active October 7, 2022 06:51
How to resolve the 1615 MySQL error

How to resolve the 1615 MySQL error

Has a MySQL error been causing trouble recently? This is a general error that seems to be a common problem.

Error code 1615 prepared statement needs to be re-prepared mysql

This error pops up due to a MariaDB bug.

According to our Support Engineers, we can resolve this error by adding the following section of mysqlconf file:

@susilolab
susilolab / error-pkgbuild-archlinux.md
Last active May 11, 2022 13:53
ERROR: PKGBUILD contains CRLF characters and cannot be sourced.

Masalah:

` ~ ❯ yay -S yay 8s :: Checking for conflicts... :: Checking for inner conflicts... [Aur:1] yay-11.1.2-1

1 yay (Installed) (Build Files Exist) ==> Packages to cleanBuild?

@susilolab
susilolab / main.twig
Last active March 9, 2022 16:50
Contoh layout yii2 extend dari default.twig
{{- use('yii/widgets/Pjax') -}}
{{- use('app/components/Utility') -}}
{{- use('app/components/widgets/MenuContent') -}}
{{- use('app/components/widgets/MenuOption') -}}
{{- use('app/components/widgets/Alert') -}}
{{- use('themes/gentelella/components/Sidebars') -}}
{{- use('themes/gentelella/components/MenuTop') -}}
{{- use('themes/gentelella/components/MenuFooter') -}}
{{- void(this.beginContent('@themes/gentelella/layouts/default.php')) -}}
{{- sidebars_widget() -}}