Skip to content

Instantly share code, notes, and snippets.

View nickrobson's full-sized avatar
👨‍💻
beeping and booping

Nick Robson nickrobson

👨‍💻
beeping and booping
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nickrobson on github.
  • I am nickrobson (https://keybase.io/nickrobson) on keybase.
  • I have a public key whose fingerprint is 3569 207D 80BC 0CE5 34C0 606D 7387 E46A FFBD A4CE

To claim this, I am signing this object:

@nickrobson
nickrobson / sonos_get_queue.py
Created October 18, 2016 04:55
Gets your Sonos speaker's queue.
import json
import requests
import xml.etree.cElementTree as XML
SOAP_TEMPLATE = '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><s:Body>{0}</s:Body></s:Envelope>'
GET_QUEUE_BODY_TEMPLATE = '<u:Browse xmlns:u="urn:schemas-upnp-org:service:ContentDirectory:1"><ObjectID>Q:0</ObjectID><BrowseFlag>BrowseDirectChildren</BrowseFlag><Filter>dc:title,res,dc:creator,upnp:artist,upnp:album,upnp:albumArtURI</Filter><StartingIndex>{0}</StartingIndex><RequestedCount>{1}</RequestedCount><SortCriteria></SortCriteria></u:Browse>'
def cmd(sonos_ip, endpoint, soap_action, body):
headers = {
@nickrobson
nickrobson / Permute.java
Last active November 1, 2016 00:06
Gets all permutations of a string.
public class Permute {
public static void main(String[] args) {
for (String res : permute(args.length > 0 ? args[0] : "AABC")) {
System.out.println(res);
}
}
public String[] permute(String str) {
if (str.length() <= 1)
@nickrobson
nickrobson / MyAwesomeBot.java
Last active November 12, 2018 05:41
An example of how the DatePicker extension for jTelegramBotAPI can be used.
import com.jtelegram.api.TelegramBotRegistry;
import com.jtelegram.api.chat.id.ChatId;
import com.jtelegram.api.commands.filters.MentionFilter;
import com.jtelegram.api.commands.filters.TextFilter;
import com.jtelegram.api.menu.Menu;
import com.jtelegram.api.menu.MenuHandler;
import com.jtelegram.api.menu.viewer.RegularMenuViewer;
import com.jtelegram.api.requests.message.send.SendText;
import com.jtelegram.api.update.PollingUpdateProvider;
import com.jtelegram.api.util.TextBuilder;