Skip to content

Instantly share code, notes, and snippets.

@thangdc94
thangdc94 / config
Last active May 2, 2023 10:01
ssh with saved pass
Include config.d/*
Host remote-host
HostName 10.10.10.10
User root
Port 22
#PS password-for-remote-host
Host jump-remote-host
HostName target-remote
@thangdc94
thangdc94 / install-cuda-10-bionic.sh
Created April 30, 2020 15:40 — forked from bogdan-kulynych/install-cuda-10-bionic.sh
Install CUDA 10 on Ubuntu 18.04
# WARNING: These steps seem to not work anymore!
#!/bin/bash
# Purge existign CUDA first
sudo apt --purge remove "cublas*" "cuda*"
sudo apt --purge remove "nvidia*"
# Install CUDA Toolkit 10
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.0.130-1_amd64.deb
@thangdc94
thangdc94 / README.md
Last active June 1, 2019 01:29
Rebuild Python/R Environment on a Offline Host

Download all packages with pip download -r requirements.txt and copy them to the offline host.

Install them on the offline host with pip install --no-index --find-links /path/to/some/dir/ -r requirements.txt

If you manage environment with pipenv , create the requirements.txt file from Pipfile with pipenv lock -r

@thangdc94
thangdc94 / crc16_slottable.h
Created February 19, 2019 11:12 — forked from dvirsky/crc16_slottable.h
A table of the shortest possible alphanumeric string that is mapped by redis' crc16 to any given cluster slot. the
#ifndef _CRC16_TABLE_H__
#define _CRC16_TABLE_H__
/* A table of the shortest possible alphanumeric string that is mapped by redis' crc16
* to any given redis cluster slot.
*
* The array indexes are slot numbers, so that given a desired slot, this string is guaranteed
* to make redis cluster route a request to the shard holding this slot
*/
@thangdc94
thangdc94 / bump-version.sh
Created September 27, 2018 02:26 — forked from mareksuscak/bump-version.sh
Bump version shell script.
#!/bin/bash
# Thanks goes to @pete-otaqui for the initial gist:
# https://gist.github.com/pete-otaqui/4188238
#
# Original version modified by Marek Suscak
#
# works with a file called VERSION in the current directory,
# the contents of which should be a semantic version number
# such as "1.2.3" or even "1.2.3-beta+001.ab"
@thangdc94
thangdc94 / daemon.sh
Last active December 3, 2019 02:01
Deploy service
#!/usr/bin/env bash
waitForProcessEnd() {
pidKilled=$1
processedAt=`date +%s`
while kill -0 ${pidKilled} > /dev/null 2>&1;
do
echo -n "."
sleep 1;
if [ $(( `date +%s` - $processedAt )) -gt 60 ]; then
@thangdc94
thangdc94 / SampleImpl.java
Created March 27, 2018 02:48 — forked from patrickseda/SampleImpl.java
Java ShutdownHook registration class for managing controlled shut downs.
/**
* Sample implementation of a Shutdownable object.
*/
public class SampleImpl implements Shutdownable {
public static void main(String[] args) {
SampleImpl sample = new SampleImpl();
// Make the JVM call our shutdown() method upon exit.
ShutdownHook.registerForShutdownHook(sample);
# Define some default values that can be overridden by system properties
app.layout.pattern=%d{ISO8601} [%t] %-5p %c{3}.%M(%F:%L) - %m%n
app.log.dir=logs/
# Define root logger
log4j.rootLogger=DEBUG, CONSOLE, DRFA, ERROR
#
# Define Console appender
#
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=DEBUG
@thangdc94
thangdc94 / wget_crawl.md
Last active December 19, 2017 15:49
Crawl webpage

Simple

wget -E -H -k -K -N -p -P newfolder http://example.com/something

Multiple

  1. A few websites
wget -E -H -k -K -N -p -P newfolder http://example.com/something http://example.com/stuff