Skip to content

Instantly share code, notes, and snippets.

@YounesRahimi
YounesRahimi / Dockerfile
Last active February 24, 2026 20:01
Build & Publish a Docker Image with OpenJDK 17 + 7-Zip
# Base image
FROM openjdk:17.0.2-jdk-slim
# Metadata
LABEL maintainer="yooresh"
LABEL description="OpenJDK 17 with 7-Zip installed"
# Install 7-Zip
# openjdk:17.0.2-jdk-slim is Debian-based, so we use apt
RUN apt-get update && \
@YounesRahimi
YounesRahimi / to_jalali.sh
Last active February 23, 2026 12:14
to_jalali.sh — Bash script to convert Gregorian datetime (with timezone offset) to Jalali (Shamsi/Persian) calendar. Pure Python stdlib, no external dependencies. Supports microseconds and any UTC offset (e.g. +03:30). Usage: to_jalali.sh "2025-05-20 23:51:32.961770 +03:30"
#!/usr/bin/env bash
# ─────────────────────────────────────────────────────────────────────────────
# to_jalali.sh — Convert Gregorian datetime to Jalali (Shamsi/Persian)
#
# Supported input formats:
# "2025-05-20 23:51:32.961770 +03:30" explicit offset
# "2025-05-20T23:51:32.961770Z" UTC (Z suffix)
# "2025-05-20T23:51:32Z" UTC, no microseconds
# "2025-05-20 23:51:32.961770" no tz → implied Tehran (+03:30)
# "2025-05-20" date only → implied Tehran, 00:00:00
@YounesRahimi
YounesRahimi / CurlLoggingInterceptor.java
Created January 2, 2026 20:05
Spring Boot RestTemplate interceptor that logs outgoing HTTP requests as cURL commands for debugging. Masks sensitive headers (authorization, cookie, proxy-authorization) when enabled and limits body logging to 10KB to avoid leaking large payloads. Use maskSensitiveHeaders constructor flag to toggle masking.
package com.github.younesrahimi.utils;
import org.jspecify.annotations.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpRequest;
import org.springframework.http.client.ClientHttpRequestExecution;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.http.client.ClientHttpResponse;
@YounesRahimi
YounesRahimi / tun2socks_proxy_foo.bash
Created November 21, 2023 00:10 — forked from rsanden/tun2socks_proxy_foo.bash
tun2socks TCP+UDP user-wide proxy through shadowsocks and udpgw
#--- Build tun2socks and udpgw (as the user who will use the proxy) ---
mkdir -p $HOME/src
cd $HOME/src
git clone "https://github.com/ambrop72/badvpn"
cd badvpn
mkdir -p build
cd build
export OUTDIR=$PWD
export SRCDIR=$(dirname $PWD)
### The original Author of this package had enabled CloudFlare JS verification. As a result, this automated script will not work.
### Therefore you have to download each package and install it manually.
## Change Directory
cd /tmp/
## Update opkg
opkg update
## If wget not installed already
package reports
import com.github.mfathi91.time.PersianDate
import java.time.ZoneId
val TEHRAN_ZONE_ID = ZoneId.of("Asia/Tehran")
fun Int.format(paddingZeroCount: Int): String = String.format("%0${paddingZeroCount}d", this)
val months = listOf(
package com.github.util
import java.security.SecureRandom
import java.util.*
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
import org.slf4j.LoggerFactory
/**
@YounesRahimi
YounesRahimi / knapsack.go
Last active September 22, 2019 11:35
A sequential implementation of knapsack problem
package main
import (
"fmt"
"log"
"math/rand"
"time"
)
type Matrix [][]int
@YounesRahimi
YounesRahimi / describe.groovy
Created September 1, 2018 08:12 — forked from robertdale/describe.groovy
JanusGraph Schema Describe Command
// This can be imported via ./bin/gremlin.sh -i describe.groovy
// A variable 'graph' must be defined with a JanusGraph graph
// Run it as a plugin command ':schema'
// :schema describe
//
import org.janusgraph.graphdb.database.management.MgmtLogType
import org.codehaus.groovy.tools.shell.Groovysh
import org.codehaus.groovy.tools.shell.CommandSupport
@YounesRahimi
YounesRahimi / docker.md
Created August 16, 2018 07:17 — forked from developerinlondon/docker.md
Docker saving and loading images

Here's how to save and load docker images:

Example scenario: To save a docker image from a docker repository and save it as a tar file locally.

  1. Save the image as a tarball

docker save repositoryname:tag > repotag.tar

  1. Zip the image