Skip to content

Instantly share code, notes, and snippets.

View Steveorevo's full-sized avatar

Stephen J. Carnam Steveorevo

View GitHub Profile
@TotallyInformation
TotallyInformation / README.md
Created September 29, 2017 22:22
UIbuilder with MoonJS - simple, responsive UI

Here is a quick example using UIbuilder which is an alternative UI for Node-RED.

It demonstrates the use of a lightweight front-end library, MoonJS, which can be a lot faster and easier to work with than Node-RED's built-in Dashboard UI once you reach the point of needing to customise the UI beyond the standard capabilities of Dashboard.

This is a really quick demo of what you can do with uibuilder. MoonJS is a lightweight alternative to the likes of Angular (used by Dashboard), REACT, VueJS, etc. It is fast and really easy to use.

Here are the steps to set up (details given below):

  1. Install MoonJS & uibuilder using npm
@denvers
denvers / nginx-directives-ispconfig
Last active July 15, 2022 20:57
Nginx directives for use in ISPConfig - Nginx PHP7 FPM
# Force non-www to www redirect
if ($host !~* ^www\.) {
rewrite ^(.*)$ $scheme://www.$host$1 permanent;
}
# Turn on SSL
# protip: https://mozilla.github.io/server-side-tls/ssl-config-generator/
ssl on;
add_header Strict-Transport-Security max-age=15768000;
@jordam
jordam / magiclight.py
Created August 13, 2015 12:59
A script to control MagicLight and other cheap wifi rgb lights
import socket, time
s = socket.socket()
address = ''
port = 5577
r = 0
g = 255
b = 0
keybit = "31".replace(':', '').decode('hex')
keybit += chr(r) + chr(g) + chr(b)
keybit += "00:f0:0f".replace(':', '').decode('hex')
@bappi-d-great
bappi-d-great / WordPress Multisite - only allow one site per user.php
Last active September 21, 2022 18:31
WordPress Multisite - only allow one site per user
<?php
function wpms_one_blog_only($active_signup) {
// get the array of the current user's blogs
$blogs = get_blogs_of_user( get_current_user_id() );
// all users may be members of blog 1 so remove it from the count, could be a "Dashboard" blog as well
if ($blogs["1"]) unset($blogs["1"]);
//if the user still has blogs, disable signup else continue with existing active_signup rules at SiteAdmin->Options
$n = count($blogs);
if(n > 0){
@astockwell
astockwell / _README.md
Last active December 30, 2023 22:39
PHP Serialization Fix. For use after a find/replace/sed on MySQL dump, to repair String lengths in serialized PHP objects. Optimized and refactored for memory-safe production use in Python (~7s for 250MB dump, ~400K replacements). Written also in Perl (~7s for 250MB), Ruby (~8s for 250MB) and Go (~20s for 250MB) for benchmark comparison. Python …
@gdamjan
gdamjan / avahi-alias.py
Created July 24, 2012 06:16
Register a mDNS/DNS-SD alias name for your computer using the Avahi daemon
#! /usr/bin/env python2
'''
Register a mDNS/DNS-SD alias name for your computer using the Avahi daemon
This script will register an alternate CNAME alias besides your hostname,
which could be useful for ex. when serving several http virtual hosts to
your ffriends on the local network and you don't want to make them configure
their /etc/hosts.
Why a CNAME? You could also publish your current address with avahi-publish-address
@rmccue
rmccue / plugin-file.php
Created January 17, 2012 12:27 — forked from kovshenin/plugin-file.php
Improved class concept
<?php
/*****
All new versions will be posted at
https://github.com/rmccue/Rotor_WPPlugin
Please use that repository instead of this Gist.
******/
@jjb
jjb / gist:996292
Created May 27, 2011 22:11
How to securely acquire the Mozilla root certificate bundle for use with curl, Net::HTTP, etc.

If you want to use curl or net-http/open-uri to access https resources, you will often (always?) get an error, because they don't have the large number of root certificates installed that web browsers have.

You can manually install the root certs, but first you have to get them from somewhere. This article gives a nice description of how to do that. The source of the cert files it points to is hosted by the curl project, who kindly provide it in the .pem format.

problem: Sadly, ironically, and comically, it's not possible to access that file via https! Luckily, the awesome curl project does provide us with the script that they use to produce the file, so we can do it securely ourselves. Here's how.

  1. git clone https://github.com/bagder/curl.git
  2. cd curl/lib
  3. edit mk-ca-bundle.pl and change: