SlideShare a Scribd company logo
Raspberry Pi A La CFML
Tasty, tasty CFML on a Pi
Brad Wood
@bdw429s
pi.bradwood.com
● ColdFusion Architect (12 years)
● Geek
● Android Lover
● Blogger (codersrevolution.com)
● ColdBox Platform Evangelist
● Musician
● Shade-Tree Mechanic
● Husband (12 years)
● Dad (3 beautiful girls)
The Weird Dude With The Mic
What Is It?
What Is It?
Arduino
Haven’t I seen this before?
Raspberry Pi
● $35 $25
● 1 GB Ram
● 900 MHz Quadcore ARM CPU (overclockable)
● HDMI
● 4x USB
● Micro USB power
● Audio Jack
● Camera Interface
● Network
● GPIO
● Micro SD
What Is It?
Fits in the palm of your hand.
What Is It?
Well, almost...
What Is It?
● 2A power adapter
● USB Keyboard
● USB Mouse
● MicroSD card
● An operating system
● HDMI display
● Wifi or Ethernet hookup
● LED-adorned hat (optional)
You also want/need…
It Does Cool Stuff!
Like What?
Run Linux
Like What?
Use Openoffice
Make a cool case
Like What?
Play Minecraft
Like What?
Program in Python (Scratch)
Like What?
Media Center
Like What?
Robot
Like What?
Make a 4-RPI Cluster
Like What?
Make a 40-RPI Cluster
Like What?
Make a 64-RPI Cluster
Like What?
And you can run CFML
Like What?
● NOOBS
● Raspbian Linux (Debian)
○ Gnome Desktop (Pi Store)
○ Bash (apt-get)
● Oracle Java 1.8 (ARM)
● SSH
Environment
● PuTTY
● IP Address?? (Router, Nmap)
● CommandBox 2.0.0 beta
○ REPL
○ ForgeBox
○ Embedded Server
Tools
/etc/apt/sources.list.d/box.list
$> apt-get install commandbox
/usr/bin/box
$> box version
Install CommandBox
myFile.cfm
<cfoutput>#now()#</cfoutput>
$> box myFile.cfm
Run CFML!
myScript
#! /usr/bin/env box
<cfoutput>#now()#</cfoutput>
$> chmod a+x myScript
$> ./myScript
Run CFML!
$> box
CommandBox> install contentbox
CommandBox> start --rewritesEnabled
In-memory H2 DB
Install ContentBox
Install ContentBox
#!/bin/sh
# Get current CPU usage (10-second average, actually)
top -bn 2 -d 10 | grep '^%Cpu' | tail -n 1 | gawk
'{print $2+$4+$6}' >> ~/stats.txt
<div style="float:right;">
#cb.widget("cpu-load")#
</div>
Adding CPU Load
Adding CPU Load
“Flot” JS graphing lib
#!/bin/sh
# Get current system memory max and usage, in that order
mem_system=`free -m | grep Mem: | gawk '{print $2,$3}'`
# Start by getting the pid of the largest java process
java_pid=`top -b -n 1|awk '{if ($1~/[0-9]+/) {if ($5~/m/)
{$5=int($5*1024*1024)};print}}'|sort -k5rn,5 | grep java
| head -n1 | gawk '{print $1}'`
# Get the actual heap usage
mem_heap=`jstat -gc $java_pid | tail -n 1 | gawk '{print
($1+$2+$5+$7+$9)/1000,($3+$4+$6+$8+$10)/1000}'`
Adding Memory Usage
#cb.widget("mem-load")#
Adding Memory Usage
Rate Limiter installed
Posted to Reddit!
Performance test parameters
● No overclocking
● Bumped heap size to 768 MB
● Simple page with #now()# output
● Use CLI load tool call “Siege”
● Started with 1 thread and increased to 100 threads
How fast does this baby go?
#!/bin/bash
url="http://192.168.1.xxx/bench/"
reqs=5000
NUMS="1 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100"
for NUM in $NUMS
do
RPS=`siege -r $((reqs/NUM)) -c $NUM "$url" 2>&1 | grep "Transaction
rate:" | awk '{print $3}'`
echo -e "$NUMt$RPS"
done
How fast does this baby go?
How fast does this baby go?
1000 request per second!
What’s Next?
GPIO
(General Purpose Input Output)
● 40 pins of wonderment
○ 8 Ground pins
○ 2 +3.3v pins (50 mA max)
○ 2 +5v pins (direct current from power supply )
○ 28 digital pins 3.3v “high” (50 mA max)
● Three different naming schemes
○ Broadcom (BCM) chip numbers
○ Physical header position
○ Wiring Pi Numbers
GPIO
(General Purpose Input Output)
GPIO
(General Purpose Input Output)
● Cobbler (breakout) board
● Solderless Breadboard
● Red LED
● 330 Ohm resistor
● Hook in series between
digital pin and ground
Pi4J
● Java-based library for interacting with GPIO pins
● Wraps “native” JNI calls to C library
● Easy to use from CFML!
Yum!!
Pi4J
$> curl -s get.pi4j.com | sudo bash
$> cp /opt/pi4j/lib/pi4j-core.jar ~/.CommandBox/lib/
$> cp /opt/pi4j/lib/pi4j-device.jar ~/.CommandBox/lib/
$> cp /opt/pi4j/lib/pi4j-service.jar ~/.CommandBox/lib/
$> cp /opt/pi4j/lib/pi4j-gpio-extension.jar ~/.CommandBox/lib/
CommandBox REPL + Pi4J =
Blinky Blinky LED
GPIO = createObject(
'java', 'com.pi4j.io.gpio.GpioFactory').getInstance()
pinState = createObject(
'java', 'com.pi4j.io.gpio.PinState')
Raspipin = createObject(
'java', 'com.pi4j.io.gpio.RaspiPin')
LED = GPIO.provisionDigitalOutputPin(
RaspiPin.GPIO_01, "MyLED", PinState.HIGH)
CommandBox REPL + Pi4J =
Blinky Blinky LED
// Have you tried turning it
// off and back on again?
LED.low()
LED.high()
// Toggle the current state
LED.toggle()
// On and back off once
LED.pulse( 2000 )
The (LED) Matrix has you
64 LEDs (8x8)
The (LED) Matrix has you
Only 16 pins!
The (LED) Matrix has you
The (LED) Matrix has you
--Multiplexing--
Only one column can be lit at a time.
The (LED) Matrix has you
Inline 330 Ohm resistor on each row
Each column switched to ground via NPN transistor
The (LED) Matrix has you
CFML
Redraw each column > 60 times a second
The (LED) Matrix has you
Shift Your Focus
Shift Register
Shift Your Focus
SIPO -- Serial In, Parallel Out
Shift Your Focus
1 0 1 0 1
0
1
0
Bit banging
Allows transfer of large amount of data
over a few wires in “chunks”
Shift Your Focus
5 input wires drives 16 output
Data
Clock
Latch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
5V
GND
Shift Your Focus
Design In Flux
Design In Flux
Wired To The Brim
Wired To The Brim
“Smiley” animation
delay 10000
frame
00111100
01000010
10100101
10000001
10100101
10011001
01000010
00111100
The Code
https://github.com/bdw429s/CFML-Pi-Hat/
Is that bacon I smell?
Is that bacon I smell?
What’s Next?
● Interactive projects (control from web)
● Clustered Pis (CFML, Couchbase, etc)
● Home Automation
● CFGPIO library
● What will you build?

More Related Content

PDF
Fast and cost effective geospatial analysis pipeline with AWS lambda
PDF
KubeCon EU 2016: Custom Volume Plugins
PDF
Happy Go Programming Part 1
PDF
GoLang & GoatCore
DOCX
serverstats
PDF
OSS AWS 핸즈온 강의
PDF
PyHEP 2019: Python 3.8
PDF
Vim Script Programming
Fast and cost effective geospatial analysis pipeline with AWS lambda
KubeCon EU 2016: Custom Volume Plugins
Happy Go Programming Part 1
GoLang & GoatCore
serverstats
OSS AWS 핸즈온 강의
PyHEP 2019: Python 3.8
Vim Script Programming

What's hot (18)

PDF
Go初心者がGoでコマンドラインツールの作成に挑戦した話
PPTX
Improving go-git performance
PDF
Python と Docker で mypy Playground を開発した話
PDF
Some Pry Features
PPT
Php perf
PPT
Linux Basics
KEY
Clojure + MongoDB on Heroku
KEY
[JAM 1.2] Design & Multitasking (Andrew Solovey)
PPTX
Jk rubyslava 25
PPTX
Rubyslava + PyVo #48
PPTX
Parse, scale to millions
PDF
Scaling FastAGI Applications with Go
PDF
Configuration surgery with Augeas (OggCamp 12)
KEY
Amepad lt(tmpfs)
PPTX
15 map reduce on azure
KEY
Ender
PDF
Shrink to grow
PPTX
Value protocols and codables
Go初心者がGoでコマンドラインツールの作成に挑戦した話
Improving go-git performance
Python と Docker で mypy Playground を開発した話
Some Pry Features
Php perf
Linux Basics
Clojure + MongoDB on Heroku
[JAM 1.2] Design & Multitasking (Andrew Solovey)
Jk rubyslava 25
Rubyslava + PyVo #48
Parse, scale to millions
Scaling FastAGI Applications with Go
Configuration surgery with Augeas (OggCamp 12)
Amepad lt(tmpfs)
15 map reduce on azure
Ender
Shrink to grow
Value protocols and codables
Ad

Similar to Raspberry pi a la cfml (20)

PDF
Raspberry pi: Conceptos básicos de la arquitectura de la computadora raspberr...
PPTX
How to make your Money Machine with Internet of Things
PPTX
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
PDF
Introduction to Raspberry PI
PPTX
Up and running with Raspberry Pi
PDF
Raspberry Pi Computer Architecture Essentials Dennis Andrew K
PDF
JS Fest 2018. Володимир Шиманський. Запуск двіжка JS на мікроконтролері
DOCX
Raspberry pi, Summer $ Short Term Courses in waayoo.com
PDF
Taking the hard out of hardware
PDF
Intro to the raspberry pi board
PPTX
Starting Raspberry Pi
PPTX
Java on Raspberry Pi Lab
ODP
Raspberry Pi introduction
ODP
Introduction to Raspberry Pi and GPIO
PDF
Iot Bootcamp - abridged - part 1
PPTX
Raspberry Pi Introduction
PPTX
Oracle IoT Kids Workshop
PDF
The GNU Debugger GDB for the benefit of Embedded Engineering
PDF
OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...
PPTX
Connected hardware for Software Engineers 101
Raspberry pi: Conceptos básicos de la arquitectura de la computadora raspberr...
How to make your Money Machine with Internet of Things
Java Device I/O at Raspberry PI to Build a Candy Vending Machine
Introduction to Raspberry PI
Up and running with Raspberry Pi
Raspberry Pi Computer Architecture Essentials Dennis Andrew K
JS Fest 2018. Володимир Шиманський. Запуск двіжка JS на мікроконтролері
Raspberry pi, Summer $ Short Term Courses in waayoo.com
Taking the hard out of hardware
Intro to the raspberry pi board
Starting Raspberry Pi
Java on Raspberry Pi Lab
Raspberry Pi introduction
Introduction to Raspberry Pi and GPIO
Iot Bootcamp - abridged - part 1
Raspberry Pi Introduction
Oracle IoT Kids Workshop
The GNU Debugger GDB for the benefit of Embedded Engineering
OSIS18_IoT : Solution de mise au point pour les systemes embarques, par Julio...
Connected hardware for Software Engineers 101
Ad

More from ColdFusionConference (20)

PDF
Api manager preconference
PDF
PDF
Building better SQL Server Databases
PDF
API Economy, Realizing the Business Value of APIs
PDF
Don't just pdf, Smart PDF
PDF
Crafting ColdFusion Applications like an Architect
PDF
Security And Access Control For APIS using CF API Manager
PDF
Monetizing Business Models: ColdFusion and APIS
PDF
Become a Security Rockstar with ColdFusion 2016
PDF
ColdFusion in Transit action
PDF
Developer Insights for Application Upgrade to ColdFusion 2016
PDF
Where is cold fusion headed
PDF
ColdFusion Keynote: Building the Agile Web Since 1995
PDF
Instant ColdFusion with Vagrant
PPT
Restful services with ColdFusion
PDF
Super Fast Application development with Mura CMS
PDF
Build your own secure and real-time dashboard for mobile and web
PDF
Why Everyone else writes bad code
PDF
Securing applications
PDF
Testing automaton
Api manager preconference
Building better SQL Server Databases
API Economy, Realizing the Business Value of APIs
Don't just pdf, Smart PDF
Crafting ColdFusion Applications like an Architect
Security And Access Control For APIS using CF API Manager
Monetizing Business Models: ColdFusion and APIS
Become a Security Rockstar with ColdFusion 2016
ColdFusion in Transit action
Developer Insights for Application Upgrade to ColdFusion 2016
Where is cold fusion headed
ColdFusion Keynote: Building the Agile Web Since 1995
Instant ColdFusion with Vagrant
Restful services with ColdFusion
Super Fast Application development with Mura CMS
Build your own secure and real-time dashboard for mobile and web
Why Everyone else writes bad code
Securing applications
Testing automaton

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
KodekX | Application Modernization Development
PPTX
Cloud computing and distributed systems.
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Machine learning based COVID-19 study performance prediction
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Approach and Philosophy of On baking technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Review of recent advances in non-invasive hemoglobin estimation
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
KodekX | Application Modernization Development
Cloud computing and distributed systems.
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Machine learning based COVID-19 study performance prediction
Per capita expenditure prediction using model stacking based on satellite ima...
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
Chapter 3 Spatial Domain Image Processing.pdf
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Approach and Philosophy of On baking technology
Advanced methodologies resolving dimensionality complications for autism neur...
Understanding_Digital_Forensics_Presentation.pptx

Raspberry pi a la cfml