Skip to content

Instantly share code, notes, and snippets.

View fahmifan's full-sized avatar

fahmi irfan fahmifan

View GitHub Profile
@fahmifan
fahmifan / git_command.sh
Last active January 5, 2026 11:07
git command to pull rebase that accept all remote changes
# this will pull rebase and accept all remote changes
# bascially override all local changes
git pull --rebase=interactive -s recursive -X theirs
# then, git pull
git pull origin "$(git_current_branch)"
@fahmifan
fahmifan / script.sh
Created November 21, 2024 06:21
ffmpeg increase tempo/speed like youtube did
ffmpeg -i input.mkv -filter_complex "[0:v]setpts=<1/x>*PTS[v];[0:a]atempo=<x>[a]" -map "[v]" -map "[a]" output.mkv
# example increase tempo to 1.25
# ffmpeg -i Coba1.mp4 -filter_complex "[0:v]setpts=0.8*PTS[v];[0:a]atempo=1.25[a]" -map "[v]" -map "[a]" Coba1.1.mp4
@fahmifan
fahmifan / main.go
Created October 27, 2024 15:57
Videostore from Martin Fowler Refactoring in Go
package main
import (
"fmt"
"refactoring/videostore"
)
func main() {
movieA := videostore.Movie{
Title: "Wiro Sableng",
@fahmifan
fahmifan / handle.md
Created May 20, 2024 08:26
handle error missing lib ssl1 when running mongodb memory server for testing

set version to 6.0.13

export MONGOMS_VERSION=6.0.13
@fahmifan
fahmifan / sql_gorm.go
Created March 16, 2024 22:24
Get SQL Tx from Gorm
type DBTX interface {
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
PrepareContext(context.Context, string) (*sql.Stmt, error)
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}
func DBTxFromGorm(tx *gorm.DB) (DBTX, bool) {
dbtx, ok := tx.Statement.ConnPool.(*sql.Tx)
return dbtx, ok
@fahmifan
fahmifan / debug-slow-prisma-query.ts
Last active August 25, 2023 04:14
How to log slow prisma query, tested on Prisma 3
const prismaClient = new PrismaClient({
log: ['query'] // must enable this to log
});
// Log slow query with all parameters in place,
// so you can copy pasted it and do EXPLAIN query
prismaClient.$on('query' as any, (e: any) => {
const dur = Number.parseInt(e?.duration);
const maxQueryTime = 100; // in ms
if (dur <= maxQueryTime) return;
@fahmifan
fahmifan / setup.sh
Last active June 26, 2022 00:34
Setup for Accessing Go Private Repository
# add your ssh public key to github & gitlab
# set GOPRIVATE, for github & gitlab
GOPRIVATE="gitlab.com/<your-private-group>,github.com/<your-private-group>"
# if you use a private hosted gitlab
GOPRIVATE="gitlab.yoursite.com"
# set github to use ssh
git config --global url."git@github.com:".insteadOf "https://github.com/"
@fahmifan
fahmifan / aes.go
Last active June 24, 2022 03:44
simple AES encryption using cfb in Golang
package cryptor
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/hex"
"fmt"
"io"
)
@fahmifan
fahmifan / copy-to-clipboard.js
Created March 9, 2022 10:11
Copy To Clipboard Browser Bookmarklet
javascript:(function() {function copyToClipboard(text) { if (window.clipboardData && window.clipboardData.setData) { /*IE specific code path to prevent textarea being shown while dialog is visible.*/ return clipboardData.setData("Text", text); } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) { var textarea = document.createElement("textarea"); textarea.textContent = text; textarea.style.position = "fixed"; /* Prevent scrolling to bottom of page in MS Edge.*/ document.body.appendChild(textarea); textarea.select(); try { return document.execCommand("copy"); /* Security exception may be thrown by some browsers.*/ } catch (ex) { console.warn("Copy to clipboard failed.", ex); return false; } finally { document.body.removeChild(textarea); } }}var markdown = '[' + document.title + '](' + window.location.href + ')';var selection = window.getSelection(
@fahmifan
fahmifan / Dockerfile
Last active November 26, 2019 03:34
Deploy React using Docker + NGINX
FROM nginx:alpine
COPY ./build /usr/share/nginx/html
COPY nginx.conf /etc/nginx/conf.d/default.conf
EXPOSE 80
CMD ["nginx", "-g", "daemon off;"]