Skip to content

Instantly share code, notes, and snippets.

View bydeath's full-sized avatar
💭
I may be slow to respond.

bydeath bydeath

💭
I may be slow to respond.
View GitHub Profile
# Originally from here : https://gist.github.com/ngaffa/15d46c98dd82620c8120ddf7398d6dbd
#cloud-config
package_update: true
package_upgrade: true
packages:
# Update the apt package index and install packages needed to use the Docker and Kubernetes apt repositories over HTTPS
- apt-transport-https
- ca-certificates
- curl
systemctl stop kubelet docker
cd /etc/
mv kubernetes kubernetes-backup
mv /var/lib/kubelet /var/lib/kubelet-backup
mkdir -p kubernetes
cp -r kubernetes-backup/pki kubernetes
rm kubernetes/pki/{apiserver.*,etcd/peer.*}
systemctl start docker
kubeadm init --ignore-preflight-errors=DirAvailable--var-lib-etcd --kubernetes-version "1.15.12"
cp kubernetes/admin.conf ~/.kube/config
name: "VGG_ILSVRC_16_layers"
input: "data"
input_shape {
dim: 1
dim: 3
dim: 224
dim: 224
}
@bydeath
bydeath / request_context_task_celery_flask.py
Created December 19, 2018 08:35 — forked from aviaryan/request_context_task_celery_flask.py
request context task celery flask
"""
Celery task wrapper to set request context vars and global
vars when a task is executed
Based on http://xion.io/post/code/celery-include-flask-request-context.html
"""
from celery import Task
from flask import has_request_context, make_response, request, g
from app import app # the flask app
@bydeath
bydeath / srpt.sh
Created September 4, 2018 11:14
parse sshd log secure
#!/bin/sh
echo "### Security Report (SSH) (grep \"Failed password\" /var/log/secure > secure.txt) ###"
echo "From: `head -1 secure.txt | sed -e "s/.localhost.*//"`"
echo "To: `tail -1 secure.txt | sed -e "s/.localhost.*//"`"
echo ""
grep -v "invalid user" secure.txt | awk '{print $11}' > v_ip.txt
grep "invalid user" secure.txt | awk '{print $13}' > i_ip.txt
cat i_ip.txt v_ip.txt | sort > f_ip.txt
@bydeath
bydeath / mounted var_run full solution
Last active June 12, 2018 06:23
when execute yum install redis, error is no space left, but there are 50% of disk are avaliable on /run. The problem is inodes is full. every file will own a inode, if there are thounds of tiny files, inodes will full
lsof -nP +L1 /run
this is a simaple script from https://stackoverflow.com/questions/653096/how-to-free-inode-usage
#!/bin/bash
# count_em - count files in all subdirectories under current directory.
echo 'echo $(ls -a "$1" | wc -l) $1' >/tmp/count_em_$$
chmod 700 /tmp/count_em_$$
find . -mount -type d -print0 | xargs -0 -n1 /tmp/count_em_$$ | sort -n
rm -f /tmp/count_em_$$
@bydeath
bydeath / docker-cleanup-resources.md
Created June 4, 2018 04:07 — 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

@bydeath
bydeath / ssh-hostname-unhash.sh
Created May 22, 2018 08:41 — forked from xxorax/ssh-hostname-unhash.sh
Unhash the hostnames hashed in your known_hosts file by passing their names.
#!/bin/bash
# based on http://unix.stackexchange.com/questions/175071/how-to-decrypt-hostnames-of-a-crypted-ssh-known-hosts-with-a-list-of-the-hostna/175199#175199
function replace {
host="$1"
found=$(ssh-keygen -F "$host" 2>/dev/null | grep -v '^#' | sed "s/^[^ ]*/$host/")
if [ -n "$found" ]; then
ssh-keygen -R "$host" &>/dev/null
echo "$found" >>~/.ssh/known_hosts
echo "Found and replaced: $host"
@bydeath
bydeath / 0_reuse_code.js
Created August 30, 2017 18:01
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@bydeath
bydeath / dp.py
Created April 5, 2016 15:18
动态规划代码
import numpy as np
def read_in_file(file_name):
W_V_pair = []
with open(file_name, 'r') as f:
for line in f:
w , v = (line.strip().split(' '))
W_V_pair.append((int(w), int(v)))
print(W_V_pair)