Skip to content

Instantly share code, notes, and snippets.

View hanrw's full-sized avatar
🎯
Focusing

itshan hanrw

🎯
Focusing
View GitHub Profile
@hanrw
hanrw / hg stats.txt
Created December 28, 2017 09:35 — forked from aras-p/hg and git snippets and stats.md
hg churn and log cheat sheet
Graph of total commits by month, over last year:
hg churn -f "%Y-%m" -s -c -d "-365"
List of my commits over last year:
hg log -k aras -d "2013-01-01 to 2013-12-31" --template "{short(node)} {user(author)} {firstline(desc)}\n" >mycommits.txt
My lines changed count over last year (takes ages):
@hanrw
hanrw / curl-cloud-config-props.sh
Created May 20, 2018 09:29 — forked from jeffjohnson9046/curl-cloud-config-props.sh
use curl to check out a Spring Boot applicaion's configuration properties from a Spring Cloud Configuration service
# Occasionally I want to see the application properties that are pulled down from the Spring Cloud Config service that provides
# content to our Spring Boot apps. Since I seem to have to re-discover this every time, I figured I'd write it down to help me
# remember.
#
# Additional docs can be found here: https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html
# To see the output in YML format
curl -u {the user name}:{the user password} http://{the domain:port}/{the application name}-{the spring profile name}.yml
# For example:
@hanrw
hanrw / docker-cleanup-resources.md
Created February 14, 2019 07:49 — forked from bastman/docker-cleanup-resources.md
docker cleanup guide: containers, images, volumes, networks

Docker - How to cleanup (unused) resources

Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...

delete volumes

// see: https://github.com/chadoe/docker-cleanup-volumes

$ docker volume rm $(docker volume ls -qf dangling=true)

$ docker volume ls -qf dangling=true | xargs -r docker volume rm

@hanrw
hanrw / Dockerfile
Created April 7, 2019 09:05 — forked from TooMuchFun/Dockerfile
DeepFaceLab GPU-enabled Dockerfile [Ubuntu 16.04 w/ CUDA v9, CUDNN v7]
# NOTE: nvidia-docker must be enabled on the Docker host
FROM nvidia/cuda:9.0-base-ubuntu16.04
ENV LANG C.UTF-8
# adapted from the official tensorflow docker builds [https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/dockerfiles/dockerfiles/devel-gpu.Dockerfile]
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
cuda-command-line-tools-9-0 \
cuda-cublas-9-0 \
@hanrw
hanrw / .htaccess
Created August 8, 2019 10:14
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@hanrw
hanrw / CreateJob.sh
Created September 20, 2019 07:41 — forked from stuart-warren/CreateJob.sh
Create a job in Jenkins (or folder) using the HTTP API
# check if job exists
curl -XGET 'http://jenkins/checkJobName?value=yourJobFolderName' --user user.name:YourAPIToken
# with folder plugin
curl -s -XPOST 'http://jenkins/job/FolderName/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# without folder plugin
curl -s -XPOST 'http://jenkins/createItem?name=yourJobName' --data-binary @config.xml -H "Content-Type:text/xml" --user user.name:YourAPIToken
# create folder
@hanrw
hanrw / .bash_profile
Last active March 17, 2022 03:49 — forked from donchesworth/.bash_profile
switch between java versions
# Simple way ============================
function setjdk() {
if [ $# -ne 0 ]; then
if [ -n "${JAVA_HOME+x}" ]; then
removeFromPath "$JAVA_HOME/bin"
fi
export JAVA_HOME=`/usr/libexec/java_home -v $@`
export PATH=$JAVA_HOME/bin:$PATH
fi

Mastering Programming - by Kent Beck

From years of watching master programmers, I have observed certain common patterns in their workflows. From years of coaching skilled journeyman programmers, I have observed the absence of those patterns. I have seen what a difference introducing the patterns can make. Here are ways effective programmers get the most out of their precious 3e9 seconds on the planet. The theme here is scaling your brain. The journeyman learns to solve bigger problems by solving more problems at once. The master learns to solve even bigger problems than that by solving fewer problems at once. Part of the wisdom is subdividing so that integrating the separate solutions will be a smaller problem than just solving them together.

Time

Slicing - Take a big project, cut it into thin slices, and rearrange the slices to suit your context. I can always slice projects finer and I can always find new permutations of the slices that meet different needs

@hanrw
hanrw / ECDSA-secp256k1-example.java
Created May 1, 2022 13:27 — forked from nakov/ECDSA-secp256k1-example.java
ECDSA with secp256k1 in Java: generate ECC keys, sign, verify
import org.bouncycastle.util.encoders.Hex;
import org.web3j.crypto.*;
import java.math.BigInteger;
public class ECCExample {
public static String compressPubKey(BigInteger pubKey) {
String pubKeyYPrefix = pubKey.testBit(0) ? "03" : "02";
String pubKeyHex = pubKey.toString(16);
String pubKeyX = pubKeyHex.substring(0, 64);
@hanrw
hanrw / README.md
Created July 28, 2022 03:41 — forked from noamtamim/README.md
Markdown with PlantUML

How to use PlantUML with Markdown

PlantUML is a really awesome way to create diagrams by writing code instead of drawing and dragging visual elements. Markdown is a really nice documentation tool.

Here's how I combine the two, to create docs with embedded diagrams.

Step 0: Setup

Get the command-line PlantUML from the download page or your relevant package manager.