Old CrossFamily Front Page

Posted on by admin | Leave a comment

Python Environment (notes)

(Snippets taken from the Python Manual)
To create a virtual environment, decide upon a directory where you want to place it, and run the venvmodule as a script with the directory path:

python3 -m venv tutorial-env

This will create the tutorial-env directory if it doesn’t exist, and also create directories inside it containing a copy of the Python interpreter, the standard library, and various supporting files.

Once you’ve created a virtual environment, you may activate it. On Unix or MacOS, run:

source tutorial-env/bin/activate

(This script is written for the bash shell. If you use the csh or fish shells, there are alternateactivate.csh and activate.fish scripts you should use instead.)

Activating the virtual environment will change your shell’s prompt to show what virtual environment you’re using, and modify the environment so that running python will get you that particular version and installation of Python.

Managing Packages with PIP

From within the virtual environment:

(tutorial-env) $ python -m pip install novas
(tutorial-env) $ python -m pip install requests==2.6.0
(tutorial-env) $ python -m pip install --upgrade requests

pip uninstall followed by one or more package names will remove the packages from the virtual environment.
pip show will display information about a particular package
pip list will display all of the packages installed in the virtual environment
pip freeze will produce a similar list of the installed packages, but the output uses the format that pip install expects

(tutorial-env) $ pip freeze > requirements.txt
(tutorial-env) $ cat requirements.txt
(tutorial-env) $ python -m pip install -r requirements.txt

To run a script without pre-loading the virtual environment

tutorial-env/bin/python script.py

Or, using the activate script:

tutorial-bin/bin/activate
python script.py
Posted in Code | Tagged | Leave a comment

KanBoard

Creating and using self-hosted KanBoard based on https://kanboard.org.

Download the latest build from Docker and configure the mountpoints as below. Also, follow the setup to create the folders and set appropriate permissions:

Also, map ports so that they are not automatically assigned.

Next, run the image, create a bash Terminal and edit data/config.php with the following:

<?php
defined('ENABLE_URL_REWRITE') or define('ENABLE_URL_REWRITE', true);
defined('LOG_DRIVER') or define('LOG_DRIVER', 'system');
define('PLUGIN_INSTALLER', true);

Note that there is no closing statement on the PHP entry.

Now, restart the image and good to go.

Installed Plugins so far are:

  • Customizer
  • Bigboard
  • Calendar
  • Gantt
Posted in Uncategorized | Tagged | Leave a comment

Homebridge on Synology NAS

The following article shows a step-by-step process for setting up Homebridge on a Synology NAS – worked for me first time!

https://mariushosting.com/how-to-install-homebridge-on-your-synology-nas/

Page content saved off in case the link dies (beauty of the internet)

To access homebridge (internal only) – http://hubble:8080
(replace  Hubble with internal server address) 

Posted in Docker, Home Automation | Leave a comment

Website Bookmarks

General
PostIt Board – http://ideabordz.com
Icebreaker questions – http://icebreakers.equalexperts.com

Training Sites
datacamp.com
https://www.cybrary.it/course/cism/
https://www.pluralsight.com/

Other PostIt type boards
     Jamboard (Google)
     Funretro
     Mentimeter
     Miro

Posted in Uncategorized | Tagged | Leave a comment

Free Conference Bridge

Saving this link here for when I need a free conference bridge in the future..

https://www.freeconferencecall.com/

Posted in Uncategorized | Tagged , | Leave a comment

Security Websites

Some useful links to security related online checking tools:

Trackback an IP address – https://ipinfo.io
Run an application through a sandbox check – https://www.joesandbox.com
Online check a file/url/IP – https://www.virustotal.com/gui/home/search

Posted in Security | Tagged , , | Leave a comment

Telegram Bot API

The Telegram Bot API can be found here!

The web hooks look interesting for two way communication between bot and user(s), and looks simple enough to implement so possibly a future activity.

 

Posted in Code | Tagged | Leave a comment

Bot Notifications using Telegram

This PHP setup is based off of the excellent Python article provided by Man Hay Hong.

To get started you need to download/install Telegram and set yourself up as a user.

Once it is installed you need to setup a new bot by interacting with @BotFather and sending the following:

  • /start {this will provide some help info}
  • /newbot {@botfather will walk you through creating your new bot}

You now have your bot token – keep this safe as it enables anyone to control your bot and for you to interact through it.

Now you need your chatID so using the following URL in your browser you will see the additional info you need:

  • https://api.telegram.org/botput_your_token_here/getUpdates

Look for the following and record the digits as that is your chatID:

{"id":xxxxxxxxxxxxx <<<<<< chatID

Again, keep this information secure.

I used the following PHP code to then send messages from my internal web server. The code does also check that any messages sent originate internally otherwise it throws an error.

<?php
$bot_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$bot_chatid = 'xxxxxxxxxxxx';

/* telegram_getUpdates() - get telepgram update info */
function telegram_getUpdates() {
global $bot_token;

$send_mesg = 'https://api.telegram.org/bot' . $bot_token . '/getUpdates';
$retval = file_get_contents($send_mesg);

return $retval;
}

/* telegram_notify() - send message to telegram user from bot */
function telegram_notify($mesg) {
global $bot_token, $bot_chatid;

$url = 'https://api.telegram.org/bot' . $bot_token . '/sendMessage';
$data = array('chat_id' => $bot_chatid , 'parse_mode' => 'Markdown', 'text' => $mesg);

// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);

$retval = json_decode( $result);

return $retval;
}

if (preg_match('/192\.168\.1\./', $_SERVER['HTTP_X_REAL_IP'])) {
// Local network access via WEB
$mesg = '';

if (isset($_GET['mesg'])) {
/* We have a message to send so send it! */
$mesg = htmlspecialchars($_GET["mesg"]);

$result =  telegram_notify($mesg);
if ( $result->ok == true) 
echo "Sent";
else 
echo "Failed - " . $result->description;
} else {
/* No message so get the status instead */
$result = telegram_getUpdates();
echo $result;
}
} else {
// If we see a remote connection then send a 404
http_response_code(404);
}

?>

 

Posted in Code, Uncategorized | Tagged , , | Leave a comment

Powering ESP8266 & other devices

While I get this sorted out this page will be a holding page for parts located:

  • MT3608 DC to DC Boost converter (3.7v to 5v)
  • TP4056 Lithium Battery Charging board
  • 18650 Lithium battery
Posted in Electronics, Uncategorized | Tagged | Leave a comment