Skip to content

Instantly share code, notes, and snippets.

View LordAro's full-sized avatar

Charles Pigott LordAro

View GitHub Profile
from csbot.plugin import Plugin
from csbot.util import nick
class Exam(Plugin):
PLUGIN_DEPENDS = ['usertrack', 'auth']
examdb = Plugin.use('mongodb', collection='exam')
@Plugin.command('exam', help=('exam: show time until your next (set) exam.'
#!/usr/bin/env python
import collections
import sys
import lxml.html
import requests
import pyalpm
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--
-- PostgreSQL database dump
--
SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
--- schema.sql 2017-01-29 00:22:58.170965988 +0000
+++ schema2.sql 2017-01-29 00:23:13.124518999 +0000
@@ -2,23 +2,12 @@
-- PostgreSQL database dump
--
--- Dumped from database version 9.5.5
--- Dumped by pg_dump version 9.5.5
-
SET statement_timeout = 0;
uint16_t machine::get_val(const operand_t &x)
{
switch (x.which()) {
case 0: { // string
// much sad here. duplicates a lot of get_operand
std::string op = boost::get<std::string>(x);
if (op.find('+') != std::string::npos) {
size_t pos = op.find('+');
return this->get_val(op.substr(0, pos)) + this->get_val(op.substr(pos + 1));
} else if (op.size() > 2 && op.front() == '[' && op.back() == ']') {
/* static */ const machine::op_map machine::OPERATIONS {{
{op_t::NOP, [](machine* m){(void)m;}},
{op_t::LOAD, &machine::load_func},
{op_t::STORE, &machine::store_func},
{op_t::DUP, [](machine* m){m->stack.push(m->stack.top());}},
{op_t::SWAP, &machine::swap_func},
{op_t::INC, [](machine *m){m->stack.top()++;}},
{op_t::DEC, [](machine *m){m->stack.top()--;}},
{op_t::ADD, [](machine *m){m->binop_func(std::plus<>());}},
{op_t::SUB, [](machine *m){m->binop_func(std::minus<>(), true);}},
#!/usr/bin/env sh
set -eu
# Expects API_KEY from env
API_BASE="https://ury.org.uk/api/v2/"
MIXCLOUD_BASE="https://www.mixcloud.com"
function api_call() {
/* static */ const machine::op_map machine::OPERATIONS {{
{op_t::ADD, [](machine *m){m->binop_func(std::plus<>());}},
{op_t::SUB, [](machine *m){m->binop_func(std::minus<>());}},
{op_t::INC, [](machine *m){m->stack.top()++;}},
{op_t::DEC, [](machine *m){m->stack.top()--;}},
{op_t::AND, [](machine *m){m->binop_func(std::bit_and<>());}},
{op_t::OR, [](machine *m){m->binop_func(std::bit_or<>());}},
{op_t::NOT, [](machine *m){m->stack.top() = ~m->stack.top();}},
{op_t::XOR, [](machine *m){m->binop_func(std::bit_xor<>());}},
{op_t::SHR, [](machine *m){m->binop_func([](uint16_t a, uint16_t b){return a >> b;});}},
[package]
name = "foo"
version = "1.0.0"
[dependencies]
lonlat_bng = "*"