Skip to content

Instantly share code, notes, and snippets.

John Ellis deckerego

Block or report user

Report or block deckerego

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@deckerego
deckerego / etc_cron.daily_backup
Last active Dec 4, 2019
Use the disk archiver (DAR) to perform a full backup every other month, otherwise create an incremental backup.
View etc_cron.daily_backup
#!/bin/bash
source /etc/default/backup
MONTH_TWO=$(date -d "- 2 month" '+%Y-%m')
MONTH_PREV=$(date -d "- 1 month" '+%Y-%m')
MONTH_NOW=$(date '+%Y-%m')
DATE=`date +%Y-%m-%d`
HOST=`hostname`
@deckerego
deckerego / code.py
Created Nov 5, 2019
Audio level meter with Circuit Playground Express
View code.py
import array
import math
import time
import neopixel
import audiobusio
import board
def avg(values):
return sum(values) / len(values)
@deckerego
deckerego / code.py
Created Nov 4, 2019
Use a remote control to change the lights on a Circuit Playground Express
View code.py
import pulseio
import board
import time
import neopixel
import adafruit_irremote
power = True
color = (255, 255, 255)
brightness = 0.1
@deckerego
deckerego / code.py
Created Nov 4, 2019
Create a campfire effect with a Circuit Playground Express. Copy a crackle.wav audio file for the sound effect, and toggle the switch to mute/unmute.
View code.py
from time import sleep
from random import random
from board import SPEAKER, SLIDE_SWITCH, SPEAKER_ENABLE, NEOPIXEL
from neopixel import NeoPixel
from digitalio import DigitalInOut, Direction, Pull
from audioio import WaveFile
from audioio import AudioOut
from simpleio import map_range
# NeoPixels
@deckerego
deckerego / code.py
Created Nov 2, 2019
Multi-sensor Feedback with Circuit Playground Express
View code.py
# Circuit Playground NeoPixel
import time
import board
import neopixel
import busio
import analogio
import digitalio
import simpleio
import adafruit_thermistor
import adafruit_lis3dh
@deckerego
deckerego / send_io.sh
Created Nov 15, 2015
Send Adafruit IO data using curl
View send_io.sh
#!/bin/sh
curl -H 'X-AIO-Key: feedfacedaedbeef' -H 'Content-Type: application/json' -X POST https://io.adafruit.com/api/feeds/myfeedname/data.json -d'{"value": 17}'
@deckerego
deckerego / findport.sh
Created Feb 21, 2019
Finding an unused port, starting at 1080
View findport.sh
netstat -aln | awk '
$6 == "LISTEN" {
if ($4 ~ "[.:][0-9]+$") {
len=split($4, a, /[:.]/);
port = a[len];
p[port] = 1
}
}
END {
for (i = 1080; i < 65000 && p[i]; i++){};
@deckerego
deckerego / slack.js
Created Sep 14, 2018
Send a Message to Slack
View slack.js
'use strict';
const https = require('https');
class Slack {
constructor(slackPath) {
this._options = {
hostname: "hooks.slack.com",
method: "POST",
path: slackPath,
@deckerego
deckerego / tokenCount.js
Created Sep 3, 2018
Count token frequency (word count) for a string in JavaScript
View tokenCount.js
var testString = "cat you cat are a cat who is a cat nope not a cat";
var tokenized = testString.split(" ");
var tokenFreq = tokenized.reduce((acc, val) => { acc[val] ? acc[val]++ : acc[val] = 1; return acc; }, {});
Object.entries(tokenFreq).forEach(entry => console.log(entry[0], ": ", entry[1]));
@deckerego
deckerego / JSTest.swift
Created Jun 14, 2018
Example of executing JavaScript in iOS using Swift
View JSTest.swift
let context = JSContext()!
let myNumber = 12
context.setObject(myNumber, forKeyedSubscript: "myNumber" as NSString)
let result = context.evaluateScript("myNumber + 20;")
print("JavaScript eval: \(result!.toInt32())")
You can’t perform that action at this time.