Skip to content

Instantly share code, notes, and snippets.

Angel Leon gubatron

View GitHub Profile
@gubatron
gubatron / startSSHAgent.sh
Last active Feb 17, 2020
startSSHAgent bash function - checks for SSH_AGENT_PID in env, then for ssh-agent PID (pgrep), if not found, starts new ssh-agent, adds your keys
View startSSHAgent.sh
startSSHAgent() {
if [[ -z "$SSH_AGENT_PID" ]]; then
if [[ $(pgrep ssh-agent) ]]; then
export SSH_AGENT_PID=$(pgrep ssh-agent)
echo "Found existing ssh-agent PID, SSH_AGENT_PID=${SSH_AGENT_PID}"
else
echo "Starting fresh ssh agent"
eval `ssh-agent`
fi
fi
@gubatron
gubatron / kill_old_ssh_agents
Last active Dec 13, 2019
Linux command (script) to kill old ssh-agent processes, (could be parametrized to change the process name)
View kill_old_ssh_agents
#!/usr/bin/env python
# Author: @gubatron
# License: MIT License, Copyright 2019
import os
import sys
if __name__ == '__main__':
cmd_get_process_list = 'ps -ef --sort=start_time | grep ssh-agent | grep -v grep'
output = os.popen(cmd_get_process_list)
lines = output.read().split("\n")
@gubatron
gubatron / lighttpd_server_conf_served_from_url_subdirectory.conf
Last active Nov 14, 2019
Configuration of a wordpress site served from a URL's directory (not the root) on LIGHTTPD
View lighttpd_server_conf_served_from_url_subdirectory.conf
$HTTP["host"] =~ "^gubatron.com$|^www.gubatron.com$" {
server.document-root="/media/ebs/data/websites/gubatron.com/"
$HTTP["url"] =~ "\.git" {
url.access-deny = ("")
}
url.rewrite = (
"^/blog/wp-admin/(.*)" => "$0",
"^/blog/(.*)\.(.+)$" => "$0",
@gubatron
gubatron / nginx_server_conf_served_from_url_subdirectory.conf
Last active Nov 14, 2019
Configuration of a wordpress site served from a URL's directory (not the root) on NGINX
View nginx_server_conf_served_from_url_subdirectory.conf
server {
server_name www.gubatron.com;
listen 80;
listen [::]:80;
root /media/ebs/data/websites/gubatron.com/;
index index.php index.html index.htm;
# wordpress lives at gubatron.com/blog/...
rewrite ^/blog/wp-admin/(.*) /blog/wp-admin/$1;
#search redirect
@gubatron
gubatron / ubuntu_less_source_hightlighting.md
Last active Nov 12, 2019
ubuntu: use source highlighting for`less` output
View ubuntu_less_source_hightlighting.md

How to enable source highlighting when doing less mycodefile.ext

  1. Install source-highlight sudo apt install source-highlight

  2. Configure it on your .bash_profile

lessWithSourceHighlightSetup() {
  # location of the script may vary
@gubatron
gubatron / lighttpd_2_nginx_ssl_config_mappings.md
Last active Nov 11, 2019
lighttpd to nginx SSL config mappings
View lighttpd_2_nginx_ssl_config_mappings.md
lighttpd nginx files,values
ssl.pemfile something combined.pem, STAR_diariobitcoin_com.pem (.key + .crt)
ssl.ca-file ssl_certificate fullchain.pem, diariobitcoin_com.ca-bundle (*.crt)
@gubatron
gubatron / How to resize EBS Volume partition.md
Last active Sep 19, 2019
How to resize EBS Volume Disk partition
View How to resize EBS Volume partition.md

Root disk

  1. sudo growpart /dev/xvda 1
  2. reboot

Secondary Mounted EBS disks

  1. Modify volume size in AWS dashboard
  2. Resize sudo xfs_growfs -d /dev/xvdf
  3. No need to restart
@gubatron
gubatron / contains_item.sh
Last active Sep 6, 2019
bash: contains_item function. Check if an item is in an array
View contains_item.sh
#############################################################################
# contains_item ${needle} ${haystack[@]}
#############################################################################
contains_item() {
set +x
local ITEM=$1
local LIST=${@:2}
for ELEM in ${LIST[@]}
do
@gubatron
gubatron / ndk_archs_toolsets.md
Last active May 11, 2019
NDK architectures, toolsets and toolchains
View ndk_archs_toolsets.md

Android

x86

  • CC=$ANDROID_TOOLCHAIN/bin/i686-linux-android-clang
  • linux-elf
  • toolset=clang-x86

x86_64

  • CC=$ANDROID_TOOLCHAIN/bin/x86_64-linux-android-clang;
  • linux-x86_64
@gubatron
gubatron / jdk-builder.sh
Created Apr 9, 2019
Creating a custom JDK 12
View jdk-builder.sh
# compress = 1 -> shared strings
# compress = 2 -> zip
# if we use shared strings and then do lzma on a tar we go down to 14M .lzma file
jlink --no-header-files --no-man-pages --compress=1 --strip-debug --add-modules java.base,java.compiler,java.desktop,java.instrument,java.management,java.naming,java.prefs,java.scripting,java.sql --output frostwire-jre.nozip
#jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.compiler,java.desktop,java.instrument,java.management,java.naming,java.prefs,java.scripting,java.sql --output frostwire-jre
tar cvf frostwire-jre.nozip.tar frostwire-jre.nozip
lzma -k -z -0 -e --threads=4 -v frostwire-jre.nozip.tar
You can’t perform that action at this time.