Skip to content

Instantly share code, notes, and snippets.

View TheNavigat's full-sized avatar

Amjad Mashaal TheNavigat

View GitHub Profile
@TheNavigat
TheNavigat / compare_tables.sh
Created October 17, 2020 18:01
A bash script that compares the number of rows between source and target tables. Used for basic validation.
SOURCE_TABLES=$(mysql -s -N -h SOURCE_HOST --user="SOURCE_USER" --password="SOURCE_PASSWORD" --database="DATABASE_NAME" --execute="SHOW TABLES;" 2> /dev/null)
TARGET_TABLES=$(mysql -s -N -h TARGET_HOST --user="TARGET_USER" --password="TARGET_PASSWORD" --database="DATABASE_NAME" --execute="SHOW TABLES;" 2> /dev/null)
for TABLE in $SOURCE_TABLES
do
SOURCE_COUNT=$(mysql -s -N -h SOURCE_HOST --user="SOURCE_USER" --password="SOURCE_PASSWORD" --database="DATABASE_NAME" --execute="SELECT COUNT(*) FROM $TABLE;" 2> /dev/null)
TARGET_COUNT=$(mysql -s -N -h TARGET_HOST --user="TARGET_USER" --password="TARGET_PASSWORD" --database="DATABASE_NAME" --execute="SELECT COUNT(*) FROM $TABLE;" 2> /dev/null)

Please note that this file is super rough. Lots of code copied from stackoverflow, lots of global variables, and so on. It was not made to be pretty, or clean.

Otherwise, have fun.

The bot works by retrieving files from a Google drive folder that we have created. It picks a random meme and posts it. The script is run using CRON:

0 */2 * * * python3 /home/user/memebot/memebot.py > /home/user/memebot/logs 2>&1

The Google drive is updated with new memes manually.

2d1
< ./findnoset
24a24
> ./findset
52,157d51
< ./lib64/python2.7/site-packages/zope.interface-4.1.3-py2.7-nspkg.pth
< ./lib64/python2.7/site-packages/zope
< ./lib64/python2.7/site-packages/zope/interface
< ./lib64/python2.7/site-packages/zope/interface/__init__.pyc
< ./lib64/python2.7/site-packages/zope/interface/registry.pyc
@TheNavigat
TheNavigat / gist:7485706f7d84bb1e2a132c3b0f24f6f9
Created November 16, 2017 12:24
Directory structure of virtual environment with PYTHON_INSTALL_LAYOUT set to amzn
.
./bin
./bin/easy_install
./bin/python2
./bin/activate_this.py
./bin/python
./bin/easy_install-2.7
./bin/pip2
./bin/activate
./bin/pip
@TheNavigat
TheNavigat / gist:865685c729e3428c027cacf8a02be6b2
Created November 16, 2017 12:23
Directory structure of virtual environment with PYTHON_INSTALL_LAYOUT not set
.
./findnoset
./bin
./bin/easy_install
./bin/python2
./bin/activate_this.py
./bin/python
./bin/easy_install-2.7
./bin/pip2
./bin/activate
@TheNavigat
TheNavigat / default
Created November 13, 2016 22:25
nginx config
server {
listen 80;
server_name build.patientportal.us;
root /usr/share/nginx/html/ALEX/;
location ~* ^/(assets|uploads|robots\.txt|humans\.txt) {
try_files $uri =404;
}
<?php
/* Example 1 */
class A extends CI_Controller
{
public function __construct()
{
parent::__construct();