Skip to content

Instantly share code, notes, and snippets.

View codepope's full-sized avatar
:shipit:
London, Cor Blimey Guvn'r

Dj Walker-Morgan codepope

:shipit:
London, Cor Blimey Guvn'r
View GitHub Profile
@codepope
codepope / 0_reuse_code.js
Last active August 29, 2015 14:27
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@codepope
codepope / MqttHangman.java
Created October 3, 2013 12:15
Just a rough first hack at Hangman over MQTT... players should subscribe to hangman/result and publish their single character guesses to hangman/guess. A client for playing is left as an exercise for the reader
package org.eclipse.pahodemo;
import org.eclipse.paho.client.mqttv3.MqttCallback;
import org.eclipse.paho.client.mqttv3.IMqttDeliveryToken;
import org.eclipse.paho.client.mqttv3.MqttClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;
import org.eclipse.paho.client.mqttv3.MqttException;
import org.eclipse.paho.client.mqttv3.MqttMessage;
import org.eclipse.paho.client.mqttv3.MqttPersistenceException;
class CountingResourceHandler extends ResourceHandler {
int req_count=0;
MqttClient client;
public CountingResourceHandler() {
super();
}
@Override
@codepope
codepope / Morseduino
Last active December 31, 2015 03:48
// Morse Code - USE MQTT!
// based on a project from 30 Arduino Projects for the Evil Genius
// thanks to Simon Monk
// Andy Piper @andypiper, Nov 2013
// Dj @codepope, Dec 2013 (Putting it all in a for loop - Just change the message
char* message="use mqtt";
int ledPin = 12;
@codepope
codepope / mycqlshmin.sh
Created March 9, 2017 11:59
Extract the minimum needed for cqlsh from scylla-tools-java
# Call as
#
# sh mycqlshmin.sh newdirname scylla-tools-java-dir
# Will make name directory, copy minimum files in for cqlsh to run
#
mkdir $2 $2/bin $2/lib
cp $1/bin/cqlsh $2/bin
cp -r $1/pylib $2
cp $1/lib/*.zip $2/lib
@codepope
codepope / HowToOTGFast.md
Created March 21, 2017 18:36 — forked from gbaman/HowToOTGFast.md
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

###Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)
More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH is

@codepope
codepope / mqtt_temp_read.ino
Created February 6, 2014 16:23
The Arduino/MQTT temperature reading program
/*
Sensor to MQTT basic example
*/
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
// Update these with values suitable for your network.
byte mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };

Keybase proof

I hereby claim:

  • I am codepope on github.
  • I am codepope (https://keybase.io/codepope) on keybase.
  • I have a public key whose fingerprint is 324F FC97 2C0F C5DF 399C 4114 3F1E 02F7 A16C 08DA

To claim this, I am signing this object:

@codepope
codepope / python_mongodb_example.py
Created August 8, 2017 13:34
A grandtour example of on the fly db creation.
from flask import Flask
from flask import render_template
from flask import request
import os
from urllib.parse import urlparse
import json
import psycopg2
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
Region Name Prefix API Endpoint
US South/Dallas/us-south bmix-dal https://composebroker-dashboard-public.mybluemix.net
United Kingdom/London/eu-gb bmix-lon https://composebroker-dashboard-public.eu-gb.mybluemix.net
Germany/eu-de bmix-eude ttps://composebroker-dashboard-public.eu-de.mybluemix.net
Sydney/au-syd bmix-syd https://composebroker-dashboard-public.au-syd.mybluemix.net