Skip to content

Instantly share code, notes, and snippets.

@JSchaenzle
JSchaenzle / CreateAccount.jsx
Last active April 21, 2018 14:47
React Form Validation
const fieldValidations = [
ruleRunner("name", "Name", required),
ruleRunner("emailAddress", "Email Address", required),
ruleRunner("password1", "Password", required, minLength(6)),
ruleRunner("password2", "Password Confirmation", mustMatch("password1", "Password"))
];
export default class CreateAccount extends React.Component {
constructor() {
// ...
@JSchaenzle
JSchaenzle / erb_foobar.rb
Last active August 29, 2015 14:02
Ruby ERB inline
def foobar
hash = `git show --pretty=%h`.strip.upcase
contents = <<-eof
#ifndef VERSION_INFO_H
#define VERSION_INFO_H
#define CURRENT_GET_HASH "#{hash}"
#endif
eof
puts contents
end
@JSchaenzle
JSchaenzle / rpi_spi.c
Last active August 29, 2015 14:01
RPi SPI
// Mode options: SPI_LOOP, SPI_CPHA, SPI_CPOL, SPI_LSB_FIRST,
// SPI_CS_HIGH, SPI_3WIRE, SPI_NO_CS, SPI_READY
static uint8_t mode = SPI_CPHA;
static uint8_t bits = 8;
static uint32_t speed = 3000000;
static uint16_t delay = 0;
SPI_RESULT_T SPI_DoTransfer(char * device, uint8_t * p_rx_buf, uint8_t * p_tx_buf, uint32_t len)
{
int fd;
@JSchaenzle
JSchaenzle / jqplot_temp.html
Created April 8, 2014 03:40
jqplot example - temperature process
<!DOCTYPE html>
<html lang="en">
<head>
<script src="./public/jquery/jquery-2.1.0.min.js"></script>
<script type="text/javascript" src="public/jqplot/jquery.jqplot.min.js"></script>
<script type="text/javascript" src="public/jqplot/jqplot.canvasTextRenderer.min.js"></script>
<script type="text/javascript" src="public/jqplot/jqplot.canvasAxisLabelRenderer.min.js"></script>
<script type="text/javascript" src="public/jqplot/jqplot.dateAxisRenderer.min.js"></script>
<script type="text/javascript" src="public/jqplot/jqplot.pointLabels.min.js"></script>
<script type="text/javascript" src="public/jqplot/jqplot.canvasOverlay.min.js"></script>
@JSchaenzle
JSchaenzle / common_defines
Created October 9, 2012 21:51
Ceedling PIC Demo - Config file
:commmon: &common_defines
- __PIC24HJ128GP202__
- UNITY_INT_WIDTH=16
- CMOCK_MEM_INDEX_TYPE=uint16_t
- CMOCK_MEM_PTR_AS_INT=uint16_t
- CMOCK_MEM_ALIGN=1
- CMOCK_MEM_SIZE=4096
@JSchaenzle
JSchaenzle / RapidXmlExample.c
Created May 18, 2012 18:37
RapidXml example parsing beer journal
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <vector>
#include "rapidxml-1.13/rapidxml.hpp"
using namespace rapidxml;
using namespace std;
@JSchaenzle
JSchaenzle / AscomRubyExample1.rb
Created March 4, 2012 23:50
Controlling ASCOM devices from Ruby
require 'win32ole' # this allows us to create instances of Windows COM objects
# create instances of each of our drivers
$filt = WIN32OLE.new("ASCOM.Simulator.FilterWheel")
$foc = WIN32OLE.new("ASCOM.Simulator.Focuser")
$tele = WIN32OLE.new("ASCOM.Simulator.Telescope")
$cam = WIN32OLE.new("ASCOM.Simulator.Camera")
# a function that disconnects from each connected device
def DisconnectAllDevices()