Skip to content

Instantly share code, notes, and snippets.

View alivx's full-sized avatar
😇
our business is life itself

Ali alivx

😇
our business is life itself
View GitHub Profile
# input a pcap file from standard input
INPUT_PCAP_FILE=$1
HEADER=y
SEPARATOR=,
QUOTE=d
# display standard output
tshark \
-r ${INPUT_PCAP_FILE} \
@alivx
alivx / multiSSH.md
Created October 15, 2020 22:54
Use multiple ssh-keys for different GitHub accounts on the same computer

Create new ssh key

ssh-keygen -t rsa -b 4096 -C "[email protected]"

~/.ssh/config

# Personal GitHub account
@alivx
alivx / nginx.conf
Created November 4, 2020 13:11 — forked from mtigas/nginx.conf
Nginx configuration for securedrop.propublica.org. (Based on Ubuntu 13.10 / Nginx 1.4.1 default config.)
# This configuration file is provided on an "as is" basis,
# with no warranties or representations, and any use of it
# is at the user's own risk.
#
# You will need to edit domain name information, IP addresses for
# redirection (at the bottom), SSL certificate and key paths, and
# the "Public-Key-Pins" header. Search for any instance of "TODO".
user www-data;
worker_processes 4;
@alivx
alivx / jenkins-server-docker-compose.yaml
Created November 22, 2020 20:44
Jenkins Server Docker
version: "3"
services:
jenkins:
build: .
user: root
volumes:
- /jenkins/data:/var/jenkins_home
- /jenkins/artifacts:/var/jenkins_artifacts
- /var/run/docker.sock:/var/run/docker.sock
@alivx
alivx / Mysql uniqe Vowels
Last active January 17, 2024 17:15
Query the list of CITY names starting with vowels (i.e., a, e, i, o, or u) from STATION. Your result cannot contain duplicates.
Start with
select DISTINCT CITY from STATION where CITY rlike '^[a,e,i,o,u]';
End with
select DISTINCT CITY from STATION where CITY rlike '[a,e,i,o,u]$';
Both Start and end
select DISTINCT CITY from STATION where CITY rlike '^[a,e,i,o,u].*[a,e,i,o,u]$';
SELECT DISTINCT CITY from STATION where CITY REGEXP '^[^aeiou].*[^aeiou]$';
@alivx
alivx / alpine-linux-timezone
Created December 2, 2020 16:31
alpine-linux-timezone
Timezone setting is now handled by Setup-alpine#setup-timezone
Note: Only for NON uclibc installs!!!
glibc based installs use different timezone setup.
apk add tzdata
ls /usr/share/zoneinfo
Suppose you want to use Brussels First copy the proper zone to localtime
cp /usr/share/zoneinfo/Europe/Brussels /etc/localtime
@alivx
alivx / Install k8s.md
Created January 1, 2021 20:37
Install k8s

sudo apt update sudo apt -y install curl apt-transport-https curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - echo "deb https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list sudo apt update sudo apt -y install vim git curl wget kubelet kubeadm kubectl sudo apt-mark hold kubelet kubeadm kubectl sudo sed -i '/ swap / s/^(.*)$/#\1/g' /etc/fstab sudo swapoff -a sudo modprobe overlay

@alivx
alivx / Ubuntu passwd, Shadow, group and other files
Created January 10, 2021 22:05
Ubuntu passwd, Shadow, group and other files
The format of the/etc/shadow file is as follows:
Username:password:last_change:min_change:max_change:warm:failed_expire:expiration:reserved.
The contents of the/etc/passwd file are as follows:
Each line consists of a semicolon-delimited string of characters, in the following format:
@alivx
alivx / str_dist_merge.py
Created April 23, 2021 18:58
str_dist_merge
def merge_dict(nested_dist):
"""Convert nested dict to one dist
Args:
nested_dist (str): str nested dist
Returns:
[dist]: merged dist
"""
@alivx
alivx / slack.rb
Created November 11, 2021 20:35
Monit slack ruby script
"ruby -e ""
require 'net/https'
require 'json'
uri = URI.parse('https://hooks.slack.com/services/xx/xx/xx')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})
request.body = { \""channel\"" => \""#general\"", \""username\"" => \""mmonit\"", \""text\"" => \""[#{ENV['MONIT_HOST']}] #{ENV['MONIT_SERVICE']} - #{ENV['MONIT_DESCRIPTION']}\"" }.to_json
response = http.request(request)
puts response.body