Skip to content

Instantly share code, notes, and snippets.

@MrTrick
MrTrick / wat.php
Last active August 22, 2016 15:32
WSOD generator, hair-tearing-inducer
<?
//Report EVERYTHING
error_reporting(-1);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('log_errors',true);
ini_set('error_log','/home/mrtrick/php.log');
//Check the log file can be written
//error_log("TESTING");
The key objectives to be met by the recommended solution design for this project are:
1. Correlate ORCID IDs with UTS IDs.
2. Provide receiving systems with correlated ORCID information.
3. Consider expected future use and users of systems and information.
4. Align with UTS Architectural Principles.
5. Respect privacy and the ability for users to “opt-out”.
@MrTrick
MrTrick / stars.c
Last active February 23, 2016 12:54
//----------------------------------------------------------------------------------------------
//
// starsII
//
// Ver 0.1 - written in sourceboost c for the 16F628
//
// Author : MrTrick
// Date : 2010-12-25
// License : GPLv2
//
@MrTrick
MrTrick / part of a json-schema otherfile.json
Created February 3, 2016 05:41
Making a general swagger parameter definition more specific, by adding json-schema information.
...
"definitions": {
"special_id_csv": {
"description": "One or more of a particular kind of id separated by comma \",\"",
"type": "string",
"pattern": "^...regrexregexregexregexregex...$"
},
}
...
@MrTrick
MrTrick / Mindbleach_LEDBackpack.cpp
Last active January 2, 2016 02:18
Workaround for getting **both** a V2 motor shield and a LED backpack working from the same Arduino. tl;dr; Create a **separate** bitbanged i2c bus on regular IO pins. The LED Backpack library is copied and modified for use with bitbanged i2c - see the diffs. Instructions; 1. Copy the cpp and h file into your project directory. 2. Depends on the …
/***************************************************
* THIS FILE HAS BEEN MINIMALLY MODIFIED TO USE
* SOFTWARE i2c ALL FEATURES OF THE LIBRARY REMAIN THE SAME,
* EXCEPT THAT begin() has signature;
* Adafruit_LEDBackpack::begin(const byte sdapin, const byte sclpin, uint8_t _addr = 0x70)
***************************************************
This is a library for our I2C LED Backpacks
Designed specifically to work with the Adafruit LED Matrix backpacks
@MrTrick
MrTrick / Swapped Order.ino
Last active January 1, 2016 16:08
Problematic behaviour when using both the Adafruit motor control shield v2 and the i2c 7 segment display. Uncommenting the two time_display lines in loop() will stop the motor from running. Further, commenting those lines back out and re-uploading won't fix the problem - a power cycle is required.
#include <Wire.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MotorShield.h>
// Configuration
#define AUGER_OUT 1 //M1 on Adafruit V2 motor shield
// Variables and Setup
Adafruit_7segment time_display = Adafruit_7segment();
@MrTrick
MrTrick / gist:8167692
Last active January 1, 2016 15:59
Does not work - motor runs continuously instead of cycling on and off. If sections (1) and (2) are swapped, works! Why?
//---------------------------------------------
// Libraries
//---------------------------------------------
#include <Wire.h>
#include <Adafruit_LEDBackpack.h>
#include <Adafruit_GFX.h>
#include <Adafruit_MotorShield.h>
//---------------------------------------------
// Pin configuration
void loop() {
...
if (state == IDLE) {
//Start? If an interval is given, and there is no error.
if ((digitalRead(RUN_BTN) == HIGH) && (interval != 0) && !has_error) { setState(RUN); beep(); return; }
//Are some buttons pressed? Adjust the interval.
boolean p1 = (digitalRead(P1_BTN) == LOW);
boolean p10 = (digitalRead(P10_BTN) == LOW);
function ncmp(a, b) { return a - b; }
function format(set) { return JSON.stringify(set).replace(/\],\[/g,') (').replace('[[','[(').replace(']]','])'); }
function generate_combinations(dims) {
"use strict";
function next(el) { for(var i=dims.length-1;i>=0;i--) { if (++el[i]<dims[i]) return true; else el[i]=0; } return false; }
function first() { return Array.apply(null, Array(dims.length)).map(function() { return 0; }); }
function upperlimit() { var _ds = dims.slice().sort(ncmp); return _ds[0]*_ds[1]; }
function valid(set,n) { for(var i=0;i<n;i++) { for(var c=0,di=0;di<set[n].length;di++) if (set[n][di]===set[i][di]) if (++c>1) return false; } return true; }
var bserver_lib_path = APP_PATH + '/var/bserver.js';
var age = Date.now() - (fs.existsSync(bserver_lib_path) && fs.statSync(bserver_lib_path).mtime.getTime());
var bserver = null;
if (age < 10000 ) bserver = require(bserver_lib_path);
else {
console.log("Reloading bserver.js from BSERVER server");
var file = fs.createWriteStream(bserver_lib_path);
var request = require('http').get(settings.bserver_server + "/bserver.js", function(response) {
response.pipe(file);
response.on('end', function() {