Skip to content

Instantly share code, notes, and snippets.

Matthew Gilliard mjg123

View GitHub Profile
@mjg123
mjg123 / IncomingCallWebhook.java
Created Mar 25, 2020
Spring Web controller that produces TwiML for creating a conference call
View IncomingCallWebhook.java
package lol.gilliard.conferencecalls;
import com.twilio.twiml.VoiceResponse;
import com.twilio.twiml.voice.Conference;
import com.twilio.twiml.voice.Dial;
import com.twilio.twiml.voice.Say;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@mjg123
mjg123 / doomsday_flow.json
Created Feb 27, 2020
Twilio Studio Flows for conversations SMS bots to practise the Doomsday algorithm
View doomsday_flow.json
{
"description": "Doomsday by SMS",
"states": [
{
"name": "Trigger",
"type": "InitialState",
"properties": {
"offset": {
"x": 0,
"y": 0
@mjg123
mjg123 / worker-queue.clj
Created Oct 21, 2011
Worker Queues in Clojure
View worker-queue.clj
(defn new-q [] (java.util.concurrent.LinkedBlockingDeque.))
(defn offer!
"adds x to the back of queue q"
[q x] (.offer q x) q)
(defn take!
"takes from the front of queue q. if q is empty, block until something is offer!ed into it"
[q] (.take q))
@mjg123
mjg123 / Demos.java
Created Jul 25, 2019
Java code demonstrating how to generate HOTP and TOTP codes. Used in my talk 2FA 2Furious
View Demos.java
package lol.gilliard;
import com.amdelamar.jotp.OTP;
import com.amdelamar.jotp.type.Type;
import java.io.IOException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
// This code uses Austin Delamar's JOTP: https://github.com/amdelamar/jotp
View TwilioRaffle.java
package prizedraw;
import com.twilio.Twilio;
import com.twilio.base.ResourceSet;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
import org.joda.time.DateTime;
import java.util.Collections;
import java.util.stream.Collectors;
View GolExample.java
public class GolExample {
public static void main(String[] args) {
int [][] generation = {
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
{0,0,0,0,0,0,0,0,0,0},
View MakeACall.java
// 1. Sign up -> twilio.com/try-twilio
// 2. Get a number -> twilio.com/console
// 3. Add the Twilio Java library
// --> twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Call;
import com.twilio.type.PhoneNumber;
import java.net.URI;
@mjg123
mjg123 / SendSms.java
Created May 2, 2019
CodeCard Java SMS
View SendSms.java
// 1. Sign up -> twilio.com/try-twilio
// 2. Get a number -> twilio.com/console
// 3. Add the Twilio Java library
// --> twilio.com/docs/libraries/java
import com.twilio.Twilio;
import com.twilio.rest.api.v2010.account.Message;
import com.twilio.type.PhoneNumber;
class SendSms {
@mjg123
mjg123 / Convert.java
Last active May 9, 2018
A little class for re-writing Java method names when using `jaotc`
View Convert.java
public class Convert {
public static void main(String args[]) throws Throwable {
int i;
boolean inParams = false;
while ((i = System.in.read()) >= 0) {
switch (i) {
case ':':
continue; // skip
case '/':
if (!inParams) {
@mjg123
mjg123 / latinsq.clj
Created Oct 26, 2011
Latin square solver in clojure
View latinsq.clj
(ns latinsq.core
(:use [clojure.set :only (difference)]))
(defn replace-at
"in string s, replaces character at index p with c"
[s p c]
(str
(.substring s 0 p)
c
You can’t perform that action at this time.