Skip to content

Instantly share code, notes, and snippets.

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

Dz darmawan01

🏠
Working from home
  • Indonesia
View GitHub Profile
@darmawan01
darmawan01 / readme.MD
Created September 6, 2021 13:31
Install Postgres
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get install postgresql-13 postgresql-13-postgis-3
@darmawan01
darmawan01 / openssl.MD
Created August 26, 2021 07:20
Generate ssl key & crt with openssl
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout server.key -out server.crt
@darmawan01
darmawan01 / bash.MD
Created August 25, 2021 04:59
Run command/script background Linux

Example

./test.sh > out.log 2>&1 &

Chekc log

tail -f out.log

@darmawan01
darmawan01 / code.MD
Created July 12, 2021 06:00
Serve buffer bytes to file for http
f, err := ioutil.TempFile("", uuid+".*.pdf")
	if err != nil {
		log.Print("ioutil.TempFile(): ", err)
		return
	}

	// Write the body to file
	if _, err = io.Copy(f, buffReader); err != nil {
 log.Print("io.Copy(): ", err)
@darmawan01
darmawan01 / admin.sql
Created July 7, 2021 02:44 — forked from phil-hildebrand/admin.sql
Handy PostgreSQL Monitoring Scripts
-- turn off paging (less/more)
psql> \pset pager off
/*
Pager usage is off.
*/
-- find an object name by id
SELECT OID, relname
@darmawan01
darmawan01 / note.MD
Last active June 25, 2021 07:04
SCP or RSYNC over Jumphost

SCP Over :

scp "ProxyCommand ssh <jumphost> -W %h:%p" <src> <dest>

RSYNC Over :

rsync -azv -P -e 'ssh -o "ProxyCommand ssh -A <jumphost> -W %h:%p"' <src> <dest>
@darmawan01
darmawan01 / date_formats.dart
Created June 23, 2021 12:50
Flutter Date Helpers
import 'package:intl/intl.dart';
/// An utility calss that manages specific formats.
class DateFormats {
/// The [DateFormat] 'yyyy-MM-dd HH:mm:ss'.
static final fullDateFormat = new DateFormat('yyyy-MM-dd HH:mm:ss');
/// The [DateFormat] 'yyyy/MM/dd'.
static final onlyDayDateFormat = new DateFormat('yyyy/MM/dd');
@darmawan01
darmawan01 / CustomImageCache.dart
Last active April 5, 2024 16:07
Custom Image Provider To Cache Image bytes type
import 'dart:ui';
import 'package:flutter/cupertino.dart';
import 'package:flutter/foundation.dart';
class CacheMemoryImageProvider extends ImageProvider<CacheMemoryImageProvider> {
final String tag; //the cache id use to get cache
final Uint8List img; //the bytes of image to cache
CacheMemoryImageProvider(this.tag, this.img);
@darmawan01
darmawan01 / launch.json
Created April 30, 2021 03:03
Launch multiple devices on android debugging
{
"version": "0.2.0",
"configurations": [
{
"name": "appname",
"request": "launch",
"type": "dart"
},
{
"name": "Android",
@darmawan01
darmawan01 / launch.json
Created April 30, 2021 03:02
Launch multi devices on mobile debugging
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
// Use `flutter devices` to get your devices id
"version": "0.2.0",
"configurations": [
{
"name": "appname",