Skip to content

Instantly share code, notes, and snippets.

@admk
admk / autossh
Last active April 14, 2024 09:59
autossh service (/etc/init.d/autossh)
#! /bin/sh
# source: https://gist.github.com/suma/8134207
# source: http://stackoverflow.com/questions/34094792/autossh-pid-is-not-equal-to-the-one-in-pidfile-when-using-start-stop-daemon
### BEGIN INIT INFO
# Provides: autossh
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
@admk
admk / ssh_check
Last active December 26, 2023 10:18
Check if SSH connection is working, useful for crontab
#!/bin/bash
HOST="$1"
PORT="$2"
BARK_KEY="$3"
USER="$(whoami)"
IP="$(dig +short $HOST)"
KEY_PATH="$HOME/.ssh/id_ed25519"
LOG_FILE="$HOME/logs/connection_check.log"
@admk
admk / sash
Last active December 28, 2023 00:25
Reverse SSH tunneling to SLURM node using AutoSSH
#!/usr/bin/env python3
import os
import shutil
import socket
import getpass
import datetime
import argparse
import subprocess
import tempfile
@admk
admk / arxiv.sty
Created October 28, 2019 03:20
ArXiv latex style file
\NeedsTeXFormat{LaTeX2e}
\ProcessOptions\relax
% fonts
\renewcommand{\rmdefault}{ptm}
\renewcommand{\sfdefault}{phv}
% set page geometry
\usepackage[verbose=true,letterpaper]{geometry}

Keybase proof

I hereby claim:

  • I am admk on github.
  • I am admk (https://keybase.io/admk) on keybase.
  • I have a public key ASA4vW8BMNOPb0l1HIu-flyfUUZS_2OFAebKz6X7JE40Pwo

To claim this, I am signing this object:

---
dataset:
background_class: {has: true, use: true}
channel_means: [0.485019607843137, 0.4579607843, 0.407607843137255]
name: imagenet
num_classes: 1001
num_examples_per_epoch: {train: 1281167, validate: 50000}
path: {train: imagenet/train-*, validate: imagenet/validation-*}
shape: {channels: 3, height: 224, width: 224}
depth_multiplier: 1
@admk
admk / qvod_sentinel
Created November 3, 2013 17:52
Mac OS X 下在快播或其插件不运行的时候停止QvodTerminal在后台运行。Terminate QvodTerminal on Mac OS X when no qvod plug-ins or application is running.
#!/usr/bin/env python
# encoding: UTF-8
"""
Usage: nohup sudo ./qvod_sentinel
"""
import os
import time
import signal
from subprocess import Popen, PIPE
from datetime import datetime
@admk
admk / relaxation_labelling.py
Created December 4, 2011 04:05
Relaxation Labelling
import numpy as np
import copy
def label_wise_vector(mat, y, x):
"""
From a list of matrices of the image constructs a vector containing
values at the index (y, x) of the matrices
"""
prob_vec = []
@admk
admk / gist:1029517
Created June 16, 2011 15:37
MACE Report reflog
4f777e5 HEAD@{0}: rebase -i (pick): Added crossOver behaviour
871c9a3 HEAD@{1}: rebase -i (pick): Added mutate behaviour
bd8941f HEAD@{2}: rebase -i (pick): Updated randomize behaviour
aa4a17d HEAD@{3}: rebase -i (pick): Added generateParameters
f6becc9 HEAD@{4}: rebase -i (pick): Added known value parameters
77ee2b9 HEAD@{5}: rebase -i (pick): Fixed a typo
a433636 HEAD@{6}: checkout: moving from neuralnets to a433636617fe4b6777ce2cff4f
c22f1a5 HEAD@{7}: commit: Added crossOver behaviour
52f08b9 HEAD@{8}: commit: Added mutate behaviour
0422e6e HEAD@{9}: commit: Updated randomize behaviour