Skip to content

Instantly share code, notes, and snippets.

View jkariscodes's full-sized avatar
🎯
Focusing

Joseph Kariuki jkariscodes

🎯
Focusing
View GitHub Profile
import requests
response = requests.get('https://google.com')
print(response.status_code)
@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"
},
@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
#!/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 / 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 / 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
"""
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)
#!/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'}`
@jkariscodes
jkariscodes / Update-branch.md
Created March 21, 2020 10:10 — 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.

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

@jkariscodes
jkariscodes / cmis_test.py
Created May 31, 2019 05:31
CMIS repository test
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