Skip to content

Instantly share code, notes, and snippets.

@estysdesu
estysdesu / bindepend.py
Last active July 21, 2019 05:51
[PyInstaller: enable in virtual environment] patch file for PyInstaller in a venv #pyinstaller #venv #virtual #env #python
# PyInstaller/bindepend.py
#-----------------------------------------------------------------------------
# Copyright (c) 2013-2018, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
@estysdesu
estysdesu / string_comp.py
Last active July 21, 2019 05:51
[Python: falsey strings and string comparison] #strings #falsey #python
#!/usr/bin/env python3
# https://github.com/keystroke3/redpaper/issues/1#event-2480042391
def empty_string_checker(s):
if not s: # this is equivalent to saying `if s == "":`
print("String is empty!")
if s: # this is equivalent to saying `if s != "":`
print("String is not empty -- it contains '{}'".format(s))
g = ""
@estysdesu
estysdesu / autoformat.vim
Last active July 21, 2019 05:52
[Vim: HTML file auto-format] #vim #autoformat #ft #vim
:filetype indent on
:set filetype=html
:set smartindent
gg=G
@estysdesu
estysdesu / win.ps1
Last active July 21, 2019 05:52
[WSL: X-Server for UI] #wsl #x #server #sh #posh
##### WINDOWS #####
$uri = 'https://sourceforge.net/projects/xming/files/Xming/6.9.0.31/Xming-6-9-0-31-setup.exe/download'
curl -L $uri > Xming-setup.exe
@estysdesu
estysdesu / chrome_web_app.sh
Last active July 21, 2019 05:52
[Chrome App: macOS windowed Chrome web app without all the junk] #chrome #app #windowed #web #client #sh
#!/usr/bin/env bash
# https://github.com/estysdesu/dotFiles/blob/master/bash/.bash_profile
# one-liner
alias spotify_web="'`locate "*Google\ Chrome"`' --app="https://play.spotify.com"" # Spotify web client without all the junk
# functional
chrome_app=`locate "*Google\ Chrome"`
web_app () {
"$chrome_app" --app="$1"
@estysdesu
estysdesu / proxy.conf
Last active July 21, 2019 05:54
[Shell/Apt: proxies] #proxy #sh #apt #debian #ubuntu
##### Ubuntu/Debian Apt #####
# /etc/apt/apt.conf.d/proxy.conf
# https://www.serverlab.ca/tutorials/linux/administration-linux/how-to-set-the-proxy-for-apt-for-ubuntu-18-04/
Acquire {
HTTP::proxy "<ip-addr>";
HTTPS::proxy "<ip-addr>";
}
@estysdesu
estysdesu / zipper.sh
Last active July 21, 2019 05:58
[Shell: file compression and archiving] #tar #gzip #sh #bzip #xz #zip
##### tar (ARCHIVING) #####
# -z: gzip
# -j: bzip2
# -J: xz
# if compression method is missing, tar tries to guess compression method (from extension)
# -c: create
# -x: extract
# -v: verbose (list each file)
# -f: archive file name
# -r: append to unzipped archive
@estysdesu
estysdesu / ec2_connect.sh
Last active July 21, 2019 05:58
[AWS: EC2 SSH connect] #ec2 #ssh #sh
# change permissions on the key file (read)
chmod 400 <key.pem>
# ssh into the ec2 container
ssh -i "<key.pem>" uname@<ec2-address/ip-address>
# upgrade & update apt package manager (Debian/Ubuntu)
sudo apt update && apt upgrade
# check & update yum package manager (CentOS/RHEL)
@estysdesu
estysdesu / mov.sh
Last active July 21, 2019 06:00
[Shell: file movement] #cp #mv #rm #ln #sh
##### ln (SYMLINKS) #####
# -n: no dereference (prevents recursion of directories by stopping link following)
# -f: force if already exists by unlinking first
# -s: symbolic
# -d/-F: directory
ln -sf <path/to/source/file> <path/to/dest/file>
ln -sFn <path/to/source/dir> <path/to/dest/dir>
@estysdesu
estysdesu / test_cond.sh
Last active July 21, 2019 06:02
[Shell: test conditionals] #test #conditionals
##### test OR [ -s/-n/-t/(etc...) ] (TEST CONDITIONALS) #####
# https://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html
# numeric and string are different for numbers -- `test 01 -eq 1` is true, but `test "01" == "1"` is obviously not
# -f: file exists
# -s: file exists and has size > 0
# ! <-flag>: negate
# -d: directory exists
# -x: can execute
# <#> -eq <#>: numeric equality; good for exit codes
# <#> -ne <#>: numeric inequality (test if not equal)