Skip to content

Instantly share code, notes, and snippets.

@jsinai
jsinai / switchenv
Last active February 8, 2022 01:53
A script to make it more convenient to switch environments in the world of dotenv and kubernetes. Make sure to change line 3 (BCC)
#! /bin/bash
BCC=~/git/bs/bsn-cloud-configuration
set -e
usage()
{
cat <<EOF
Usage: $0 [options]
@jsinai
jsinai / index.js
Created November 23, 2021 01:08
Example of a file upload server written in JavaScript. This is useful as e.g. a log upload service. The BrightSign player will upload log files to this server if the "ul" registry entry is set to point to this endpoint..
const express = require('express');
const multer = require('multer');
const app = express();
const storage = multer.diskStorage({
destination: './uploads/',
filename: function(req, file, cb) {
cb(null, file.originalname);
}
@jsinai
jsinai / index.js
Last active August 23, 2018 16:03
An example of a heartbeat that detects if an html application stops responding, and restarts it. See this project for a full example of how to include a plugin like this in your BrightAuthor application: https://github.com/brightsign/node.js-starter-project
var express = require('express');
var app = express();
var bsSocketMessage = new BSDatagramSocket();
var intervl = undefined;
var udpPort = 5003;
var heartBeatFreqMs = 4000;
function main() {
// For testing:
@jsinai
jsinai / getnetworkinfo.brs
Created July 25, 2017 15:17
Shows how to get network interface information using an http endpoint.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Shows how to get network interface information using an http endpoint.
' This is especially useful from javascript.
' The http endpoint is http://localhost:8080/get-network-info.
' As written, this gets the wired (ethernet) interface info. You can
' get the wifi interface info by passing a 1 instead of 0 to
' GetNicInfo on line 66:
' m.mVar.GetNicInfo(1, retAA.info)
Sub Main()
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
@jsinai
jsinai / provisionScript.brs
Created May 25, 2017 16:08
A script suitable for serving from an Option 43 DHCP server.
'This script will bootstrap a BrightSign and is suitable for use with DHCP option
'43. It's job is to download an application/presentation zip file, and/or a
'firmware update.
'
'The application zip file is a standard zip file that can contain any combination
'of files that can run on a BrightSign. The only requirement is that it contains
' an autorun.brs to bootstrap the application.
'
'There are several tokens that need to be filled in for this script to work. It
'is designed to download two files at once, usually the application zip and a
@jsinai
jsinai / registry.brs
Last active May 23, 2017 22:33
Provides the ability to read and write values to the registry from Javascript. Use any Javascript http library such as fetch to get and post values.
' Example of registry entries to save and retrieve:
'{
' "mystring": "foo",
' "myinteger": 1,
' "myboolean": true
'}
' Example of retrieving values using curl on MacOs:
' curl http://172.16.1.96:8081/registry-settings?keys=mystring,myinteger
'
' Example of saving values with curl on MacOs:
@jsinai
jsinai / dws.brs
Last active May 18, 2017 21:14
Configures the Diagnostic Web Server on a BrightSign. See notify.brs for the Notify subroutine.
Sub Main()
nc = CreateObject("roNetworkConfiguration", 0)
if type(nc) <> "roNetworkConfiguration" then
nc = CreateObject("roNetworkConfiguration", 1)
endif
if type(nc) = "roNetworkConfiguration" then
dwsAA = CreateObject("roAssociativeArray")
dwsAA["port"] = "80"
' Turn off authentication:
@jsinai
jsinai / canonical.brs
Last active April 16, 2022 17:39
A canonical BrightScript that shows how to launch an HTML site that is resident on the player. The entry point is index.html. Works in tandem with canonical.css.
Sub Main(args)
url$ = "file:///index.html"
if args <> invalid and args.Count() > 0 then
url$ = args[0]
end if
print "url = ";url$
DoCanonicalInit()
@jsinai
jsinai / send2bs
Last active May 19, 2017 15:23
How to send a file to a BrightSign over a local network. Requires the Diagnostic Web Server to be configured. Suitable for an operating system that supports bash, like macos or ubuntu. Usage: send2bs <brightsign player ip address> <file to send> admin:<serial>.
#!/bin/bash
# Usage: send2bs <brightsign player ip address> <file to send> admin:<serial>.
# The last argument is the credentials, which can be omitted if you turn off authentication on the initial page
# of the diagnostic web server (DWS) by clicking "change password" > Remove Password.
remote=$1
filename=$2
if [ -z ${3} ]; then creds=""; else creds="--digest -u $3"; fi
cmd="curl -X POST --data-binary \"@${filename}\" ${creds} --header \"Allow-Overwrite: true\" --header \"Content-Type: application/octet-stream\" \"http://${remote}/upload.xml?rp=sd&r=sd&t=${filename}\" | grep -q '<result>SUCCESS</result>'"
if eval $cmd; then
echo Sent
@jsinai
jsinai / notify.brs
Last active May 11, 2017 19:57
A BrightScript subroutine that displays a message on the screen. Sample usage: Notify("my message", -1)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Delay is in ms. Message will be displayed for this length of time.
' Specify 0 to return immediately, and rely on the parent message loop.
' Specify -1 for infinite display with a local message loop.
Sub Notify(message As String, delay As Integer)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
print message
gaa = GetGlobalAA()
If gaa.tw = invalid Then
videoMode = CreateObject("roVideoMode")