Skip to content

Instantly share code, notes, and snippets.

View TheSkallywag's full-sized avatar

Skallywag TheSkallywag

View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Select2 with Bootstrap 4 theme</title>
</head>
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0/js/bootstrap.bundle.min.js"></script>
@TheSkallywag
TheSkallywag / gps_continuous.py
Created August 27, 2018 23:36
Python script to connect to a GPSD daemon and print the latest coordinate datapoints to the console.
###############################################################
# File: gps_continuous.py
# Description: Connect to a GPSD daemon and print the latest
# coordinate datapoints to the console.
#
# Author: Carlos Garcia-Saura (@CarlosGS) - 2018
# Modified by: Author (email) - year
###############################################################
import gpsd
@TheSkallywag
TheSkallywag / lightweight_camera_motion.py
Created August 27, 2018 23:36 — forked from CarlosGS/lightweight_camera_motion.py
Connect to an MJPG stream and compute the general direction of motion. The script first crops and downsamples the JPG frames using the JPEGtran library, to allow processing in low power platforms like the Raspberry Pi.
###############################################################
# File: lightweight_camera_motion.py
# Description: Connect to an MJPG stream and compute the
# general direction of motion.
# The script first crops and downsamples the
# JPEG frames using the JPEGtran library,
# to allow processing in low power platforms
# like the Raspberry Pi.
#
# Author: Carlos Garcia-Saura (@CarlosGS) - 2018
@TheSkallywag
TheSkallywag / raspberry_fast_capture.py
Created August 27, 2018 23:37 — forked from CarlosGS/raspberry_fast_capture.py
Fast reading from the raspberry camera with Python, Numpy, and OpenCV. See the comments for more details.
# Fast reading from the raspberry camera with Python, Numpy, and OpenCV
# Allows to process grayscale video up to 124 FPS (tested in Raspberry Zero Wifi with V2.1 camera)
#
# Made by @CarlosGS in May 2017
# Club de Robotica - Universidad Autonoma de Madrid
# http://crm.ii.uam.es/
# License: Public Domain, attribution appreciated
import cv2
import numpy as np
@TheSkallywag
TheSkallywag / conntrack_full.pl
Created August 27, 2018 23:56 — forked from arreyder/conntrack_full.pl
Collectd Exec Plugin to get the full conntrack stats
#!/usr/bin/perl
# The user this runs as under the collectd exec plugin must
# have sudo to run contrack.
#
# Something like:
#
# my_user ALL = NOPASSWD: /usr/sbin/conntrack
#
# contrack must also be in the users path. Example collectd config:
#
@TheSkallywag
TheSkallywag / mysql-sync.sh
Created May 14, 2019 18:16 — forked from akalongman/mysql-sync.sh
Sync one database to second using `pt-table-sync` + sync table structures as well
#!/bin/bash
# Fix for cron incorrect paths
HOME='/root'
# Sync database1 to database2
SRC_DB='database1'
DST_DB='database2'
EXCLUDE_TABLES=(table1 table2)
@TheSkallywag
TheSkallywag / README.md
Created June 28, 2019 22:52 — forked from tmilos/README.md
Modified Preorder Tree Traversal

Modified Preorder Tree Traversal

Hierarchical data metrics that allows fast read operations on tree like structures.

Based on Left and Right fields that are set during tree traversal. When entered into node value is set to it's Left, when exiting node value is set to it's Right.

Sample implementation

@TheSkallywag
TheSkallywag / A-RBAC-in-Database.md
Created June 28, 2019 23:04 — forked from eldarseitabla/A-RBAC-in-Database.md
RBAC - (role based access control) schemas in mysql, postgres and sqlite

RBAC - (role based access control) schemas in mysql, postgres and sqlite

This is data shemas for build RBAC

  • PostgreSQL shema
  • MySQL shema
  • Sqlite shema
@TheSkallywag
TheSkallywag / binary_search_tree.php
Created June 29, 2019 00:01 — forked from meetrajesh/binary_search_tree.php
An efficient binary search tree (BST) implementation in PHP.
<?php
class BinarySearchTree {
private $_root;
public function __construct() {
// setup sentinal node
$this->_root = new BinarySearchNode(null);
}
public function getRoot() {
return $this->hasNode() ? $this->_root->right : null;
@TheSkallywag
TheSkallywag / class.database.php
Created July 3, 2019 23:18 — forked from jonashansen229/class.database.php
PHP OOP Database class using MySQLI and Singleton pattern. Only one instance of the class will be made, this requires less memory.
<?php
/*
* Mysql database class - only one connection alowed
*/
class Database {
private $_connection;
private static $_instance; //The single instance
private $_host = "HOSTt";
private $_username = "USERNAME";
private $_password = "PASSWORd";