Skip to content

Instantly share code, notes, and snippets.

@shouro
shouro / tmux-cheatsheet.markdown
Created November 11, 2022 23:09 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@shouro
shouro / fork_and_daemon.go
Created November 10, 2021 05:27 — forked from wrfly/fork_and_daemon.go
golang fork and exec and handle signals
package main
import (
"flag"
"fmt"
"log"
"os"
"os/signal"
"syscall"
)
@shouro
shouro / drf-nested-views.py
Created January 28, 2020 19:55 — forked from dkarchmer/drf-nested-views.py
Example of a Django Rest Framework ViewSet with nested views
# ViewSets define the view behavior.
class FooViewSet(viewsets.ModelViewSet):
lookup_field = 'slug'
queryset = Foo.objects.all()
serializer_class = FooSerializer
def get_queryset(self):
"""
This view should return a list of all records
"""
@shouro
shouro / ssh.md
Created September 29, 2019 15:33 — forked from bradtraversy/ssh.md
SSH & DevOps Crash Course Snippets

SSH Cheat Sheet

This sheet goes along with this SSH YouTube tutorial

Login via SSH with password (LOCAL SERVER)

$ ssh brad@192.168.1.29

Create folder, file, install Apache (Just messing around)

$ mkdir test

$ cd test

@shouro
shouro / ec2.tf
Created May 4, 2018 13:49 — forked from solarce/ec2.tf
terraform.io example template for ec2 instance with tags
# The various ${var.foo} come from variables.tf
# Specify the provider and access details
provider "aws" {
region = "${var.aws_region}"
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
}
@shouro
shouro / INIT_VAULT.md
Created May 4, 2018 13:48 — forked from moertel/INIT_VAULT.md
Try Vault with MySQL storage backend (via Docker)

Initialise (will return keys and a token)

curl -X PUT http://0.0.0.0:8200/v1/sys/init --data '{"secret_shares":1, "secret_threshold":1}'

Use one of the keys to unseal

curl -X PUT http://0.0.0.0:8200/v1/sys/unseal --data '{"key":"a5e665962f544dd16471c120c5500a7906cfbaeb3f18ae0fc6c5c71d444f0a90"}'

Use the root token to store something

@shouro
shouro / nginx.conf
Created April 26, 2017 12:56 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@shouro
shouro / bash.generate.random.alphanumeric.string.sh
Created February 9, 2017 00:53 — forked from earthgecko/bash.generate.random.alphanumeric.string.sh
shell/bash generate random alphanumeric string
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@shouro
shouro / daemon.md
Created January 26, 2016 07:59 — forked from andreif/daemon.md
A simple unix/linux daemon in Python

A simple unix/linux daemon in Python

Source: http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

Access: http://web.archive.org/web/20131025230048/http://www.jejik.com/articles/2007/02/a_simple_unix_linux_daemon_in_python/

by Sander Marechal

I've written a simple Python class for creating daemons on unix/linux systems. It was pieced together for various other examples, mostly corrections to various Python Cookbook articles and a couple of examples posted to the Python mailing lists. It has support for a pidfile to keep track of the process. I hope it's useful to someone.

@shouro
shouro / gist:c8d14c42f085a9a11928
Created January 19, 2016 23:50
Python AES two-way encryption/decryption example
from Crypto.Cipher import AES
import base64
import os
# the block size for the cipher object; must be 16, 24, or 32 for AES
BLOCK_SIZE = 32
# the character used for padding--with a block cipher such as AES, the value
# you encrypt must be a multiple of BLOCK_SIZE in length. This character is
# used to ensure that your value is always a multiple of BLOCK_SIZE