Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Joseph Kariuki jkariukidev

🏠
Working from home
View GitHub Profile
@jkariukidev
jkariukidev / script.md
Last active Feb 9, 2022
GeoNode 3.2 Advanced Installation in Ubuntu 18.04
View script.md

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
View Completely Uninstall LAMP Ubuntu
#!/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
View cmis_upload_test.py
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')
@jkariukidev
jkariukidev / most_freq.py
Last active Jul 7, 2020
Get a repeated number in any given array (assumption that there is one repeated number).
View most_freq.py
# 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
"""
View pyqt_print_file_names.py
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)
View Backup_postgresql_db
#!/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'}`
@jkariukidev
jkariukidev / Update-branch.md
Created Mar 21, 2020 — forked from santisbon/Update-branch.md
Bring your feature branch up to date with master. Deploying from Git branches adds flexibility. Bring your branch up to date with master and deploy it to make sure everything works. If everything looks good the branch can be merged. Otherwise, you can deploy your master branch to return production to its stable state.
View Update-branch.md

Updating a feature branch

First we'll update your local master branch. Go to your local project and check out the branch you want to merge into (your local master branch)

$ git checkout master

Fetch the remote, bringing the branches and their commits from the remote repository. You can use the -p, --prune option to delete any remote-tracking references that no longer exist in the remote. Commits to master will be stored in a local branch, remotes/origin/master

@jkariukidev
jkariukidev / cmis_test.py
Created May 31, 2019
CMIS repository test
View cmis_test.py
from cmislib import CmisClient
# testing cmis by getting repository information
def repository():
client = CmisClient('http://localhost:8081/alfresco/api/-default-/public/cmis/versions/1.1/atom',
'<user>', '<password>')
repo = client.defaultRepository
repo_info = repo.info
View sample_html.py
import sys
from PyQt4.QtCore import QTimer, QVariant, SIGNAL
from PyQt4.QtGui import *
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply
from PyQt4.QtWebKit import QWebView
html = """<html>
<head>
<title>Test page for the download:// scheme</title>
</head>
@jkariukidev
jkariukidev / authenticate.py
Created May 7, 2019 — forked from femmerling/authenticate.py
I have to create user authentication using python-ldap. After googling around and trying out stuffs, this is the final code for you to use. Please remember to adjust the user_dn, and base_dn accordingly to the format used in your LDAP server.
View authenticate.py
# to be able to import ldap run pip install python-ldap
import ldap
if __name__ == "__main__":
ldap_server="x.x.x.x"
username = "someuser"
password= "somepassword"
# the following is the user_dn format provided by the ldap server
user_dn = "uid="+username+",ou=someou,dc=somedc,dc=local"