Skip to content

Instantly share code, notes, and snippets.

View chrisgward's full-sized avatar

Chris Ward chrisgward

View GitHub Profile
import org.eclipse.paho.client.mqttv3.*;
public class Publisher {
public static MqttAsyncClient makeClient(int qos) throws MqttException {
MqttAsyncClient client = new MqttAsyncClient("tcp://comp3310.ddns.net:1883", "3310-u6053464-fastpub" + qos);
MqttConnectOptions options = new MqttConnectOptions();
options.setUserName("students");
options.setPassword("33106331".toCharArray());
options.setCleanSession(true);
client.setCallback(new MqttCallback() {
@chrisgward
chrisgward / lcd.S
Last active February 19, 2019 03:24
LCD library for STM32L476VG Discovery
/*
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Chris Ward <[email protected]> wrote this file. As long as you retain
* this notice you can do whatever you want with this stuff. If we meet some
* day, and you think this stuff is worth it, you can buy me a beer in return.
* ----------------------------------------------------------------------------
*/
.syntax unified
@chrisgward
chrisgward / easy.txt.solved
Created May 11, 2017 19:44
Sudoku Solutions for COMP1100/COMP1130 2017
483921657967345821251876493548132976729564138136798245372689514814253769695417382
245981376169273584837564219976125438513498627482736951391657842728349165654812793
462831957795426183381795426173984265659312748248567319926178534834259671517643892
137256849928314567465897312673542981819673254542189736256731498391428675784965123
523816749784593126691472835239145687457268913168937254342789561915624378876351492
176923584524817639893654271957348162638192457412765398265489713781236945349571826
143986257679425381285731694962354178357618942418279563821567439796143825534892716
487156932362498751915372864846519273593724186271863549124685397738941625659237418
814976532659123478732854169948265317275341896163798245391682754587439621426517983
761928453925743168438615927357461289894372615216589374689154732142837596573296841
proc ansi {arg} {
set split [split $arg ""]
set return ""
for {set i 0} {$i < [llength $split]} {incr i} {
if {[lindex $split $i] == "\x1b"} {
set codes ""
incr i 2
while {[lindex $split $i] != "m" && $i < [llength $split]} {
set codes "$codes[lindex $split $i]"
bind pub n&- ~ stcl
proc stcl {nick host hand chan arg} {
set ctx [getctx]
set lines 5
set prefix 1
set first [lindex [split $arg " "] 0]
set skipempty 1
if {$first == "-q"} {
set arg [string range $arg 3 end]
@chrisgward
chrisgward / wolframalpha.tcl
Created July 20, 2014 05:59
WolframAlpha Nromal Script (Lain compatible)
package require tdom
proc wolframalpha {nick channel arg} {
if {$arg == ""} {
return "Please provide a search query."
} elseif {[string first "Necrodoom" $arg] != -1} {
return "Did you mean: stop spamming $::botnick?"
}
set xml [wget http://api.wolframalpha.com/v2/query?format=plaintext&appid=APPID&[::http::formatQuery input $arg]]
set document [dom parse $xml]
proc essentials_repo {n c t} {
set args [split $t " "]
set length [llength $args]
if {$length == 0} {
return [essentials_repo_usage]
} elseif {$length == 1} {
set type "Release"
} else {
switch -regexp -nocase -- [lindex $args 1] {