Skip to content

Instantly share code, notes, and snippets.

View emrysr's full-sized avatar

Emrys Roberts emrysr

View GitHub Profile
@emrysr
emrysr / long-list.php
Created June 25, 2019 15:32
php list of items displayed as collapsable items - no jquery
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>large list scrolling test</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
#nodes label:hover{
@emrysr
emrysr / pulse-svg.css
Created June 25, 2019 15:27
pulsing css animation through list of svg icons
#icon-list svg {
animation-name: pulse;
animation-duration: 1.6s;
animation-timing-function: linear;
animation-direction: alternate;
animation-iteration-count: infinite;
}
#icon-list svg:nth-child(1){
animation-delay: -.6s;
@emrysr
emrysr / update jessie mosquitto apt gpg key
Created January 23, 2019 08:53
fix issue with apt failing update on emonpi "An error occurred during the signature verification"
wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key
sudo apt-key add mosquitto-repo.gpg.key
@emrysr
emrysr / debug js
Created November 8, 2018 21:25
handy js debug functions
// ----------------------------------------------------------------
// DEBUG FUNCTIONS
/**
* output to developer console if in debug mode
*/
function debug(args) {
try {
log(args.callee.name, 'info')
} catch (e) {
log(args, 'info')
@emrysr
emrysr / ogg-to-gif
Created September 18, 2018 13:16
convert ogg to gif with palette
# create palette
ffmpeg -y -ss 30 -t 3 -i swipe-navigation.ogg -vf fps=10,scale=320:-1:flags=lanczos,palettegen pallete.png
# convert ogg video to gif using created palette
ffmpeg -i swipe-navigation.ogg -i palette.png -lavfi "fps=15,scale=320:-1:flags=lanczos [x]; [x][1:v] paletteuse" -y swipe-navigation.gif
@emrysr
emrysr / function-append.js
Created August 3, 2018 10:05
append or prepend to existing function in js
/**
* if a function already exists you can overwrite it but still keeping the original functionality
*
* this example adds a console message before and after the original function "functionToOverwrite"
*/
functionToOverwrite = (function() {
var cached_function = functionToOverwrite;
return function() {
@emrysr
emrysr / work-done.bash
Created July 24, 2018 13:50
get all commits on all branches for an author
git log --pretty=format:"%ad:%an:%d:%B" --date=short --reverse --branches --since=2.months.ago --author=Emrys
@emrysr
emrysr / emoncms-docker-mysql-connect
Last active July 19, 2018 12:38
connect to emoncms mysql container started with docker-compose
docker run -it --link emoncmsdocker_db_1:mysql --net emoncmsdocker_default --rm mysql sh -c 'exec mysql -hdb -uemoncms -pYOUR_SECURE_PASSWORD emoncms'
@emrysr
emrysr / mqtt_publish.php
Created July 3, 2018 13:09
test emonpi mqtt publish
<?php
namespace mqttPub;
define('EMONCMS_EXEC', 1);
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Emoncms - open source energy visualisation
@emrysr
emrysr / mqtt-pub-test.php
Created July 2, 2018 22:49
Mosquitto-PHP test script for emoncms
<?php
/*
creates mosquitto client and connects before the infinite blocking loop loopForever()
is used to keep the connection until finished
it finishes when the disconnect() is called once the publish() is sent
I have been able to loop this in a bash script 50 times without error:
`
$ for i in {1..50}; do php mqtt-pub-test.php ; done