Skip to content

Instantly share code, notes, and snippets.

View jkariscodes's full-sized avatar
🎯
Focusing

Joseph Kariuki jkariscodes

🎯
Focusing
View GitHub Profile
#!/bin/bash
# defining pgpassword for interactive logging
export PGPASSWORD=postgres
backup_dir="/mnt/backups/pgbackups/postgisdb/"
mkdir "$backup_dir$(date '+%d-%b-%Y')"
date_dir="$backup_dir$(date '+%d-%b-%Y')"
logfile="$date_dir/pgsql.log"
touch $logfile
# scan through present databases
databases=`psql -h localhost -U postgres -q -c "\l" | sed -n 4,/\eof/p | grep -v rows\) | grep -v template0 | grep -v template1 | awk {'print $1'}`
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
def file_names():
folder = QFileDialog.getExistingDirectory()
files = QDir(folder).entryList(QDir.Files)
for file in files:
print(file)
@jkariscodes
jkariscodes / most_freq.py
Last active July 7, 2020 12:41
Get a repeated number in any given array (assumption that there is one repeated number).
# Get the most repeated number in a given list
def max_freq(some_list):
"""
Gets the most repeated number in a list.
:param some_list: A given list of numbers having one that is most
repeated.
:type some_list: list
:rtype max_item: object
"""
@jkariscodes
jkariscodes / cmis_upload_test.py
Created December 7, 2020 06:03
CMIS upload test script
import cmislib
client = cmislib.CmisClient('http://127.0.0.1:8080/alfresco/api/-default-/public/cmis/versions/1.1/atom', 'Admin', 'alfresco')
repo = client.defaultRepository
root = repo.rootFolder
myFolder = root.createFolder('testFolder')
@jkariscodes
jkariscodes / Completely Uninstall LAMP Ubuntu
Last active February 23, 2021 13:53 — forked from UbuntuEvangelist/Completely Uninstall LAMP Ubuntu
Completely Uninstall LAMP Ubuntu 20.04 LTS
#!/bin/bash
# This will remove Apache
sudo service apache2 stop
sudo apt-get purge apache2 apache2-utils apache2.2-bin
sudo apt remove apache2.*
sudo apt-get autoremove
whereis apache2
sudo rm -rf /etc/apache2
@jkariscodes
jkariscodes / script.md
Last active February 9, 2022 12:20
GeoNode 3.2 Advanced Installation in Ubuntu 18.04

Snippets on GeoNode 3.2 Advanced Installation in Ubuntu 18.04 LTS

Installing GeoNode 3.2.* in clean Ubuntu 18.04 using the official documentation results in some errors due to the following issues:

  • Default Python in the OS is Python version 3.6 while version 3.8 is required for GeoNode 3.2
  • The GDAL version available on the OS is 2.2.3 while version 3.3.2 is required. To confirm the above run the follwing commands:
  1. which python to check the existing python version location. It shows the following output.
python: /usr/bin/python3.6 /usr/bin/python3.6m /usr/lib/python3.6 /usr/lib/python3.7 /usr/lib/python2.7 /etc/python3.6 /etc/python2.7 /usr/local/lib/python3.6 /usr/include/python3.6m /usr/share/python
@jkariscodes
jkariscodes / test_marqo.py
Last active September 20, 2022 13:21
Indexing and searching using marqo
import marqo
mq = marqo.Client(url='http://localhost:8882')
documents = [
{
"Title": "The Gods Must Be Crazy",
"Description": "An African narrative based on a South African native community.",
"ISBN": "9781234567897"
},
import requests
response = requests.get('https://google.com')
print(response.status_code)