Skip to content

Instantly share code, notes, and snippets.

@Cameron-D
Cameron-D / led.sh
Created November 29, 2016 11:54
Set Turris Omnia user LED colours based on WAN usage
#!/bin/bash
# interface speeds in BYTES per second
WAN_DOWN=$((700 * 1024))
WAN_UP=$((45 * 1024))
# probably don't need to edit from here on
# read current values
RX=$(cat /sys/class/net/pppoe-wan/statistics/rx_bytes)
@Cameron-D
Cameron-D / synapse.sh
Created November 16, 2016 11:56
Matrix Synapse FreeBSD setup commands
# Assumes new clean jail
pkg update
pkg upgrade
# Required packages
pkg install bash nano jpeg py27-setuptools27 py27-sqlite3
# Set up python
easy_install pip
pip install virtualenv
# Perhaps create a new user account now and switch to it
# csh gave venv errors
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook('pre_output_page', 'https_output_page');
function https_info() {
=============================================================================================================================================================================
Hits Total Self Child Line | JSON.lua - Times in seconds
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
. . . . 1 | -- -*- coding: utf-8 -*-
. . . . 2 | --
. . . . 3 | -- Copyright 2010-2011 Jeffrey Friedl
. . . . 4 | -- http://regex.info/blog/
. . . . 5 | --
1 0.00 0.00 0.00 6 | local VERSION = 20130720.01 -- version history at end of file
1 0.00 0.00 0.00 7 | local OBJDEF = { VERSION = VERSION }
archiveteam@archivetemp:/mnt/at/twitpic-grab$ luatrace.profile mytrace.txt
Total time 135.58 seconds
Times in seconds
Top 20 lines by total time
File:line Hits Total Self Child | Line
twitpic.lua:251 573 134.80 134.80 0.00 | local status_code = http_stat["statcode"]
twitpic.lua:255 573 0.35 0.35 0.00 | io.stdout:flush()
twitpic.lua:141 3170 0.13 0.13 0.00 | local url = urlpos["url"]["url"]
twitpic.lua:43 413 0.04 0.04 0.00 | local urls = {}
twitpic.lua:60 68 0.03 0.03 0.00 | for videourl in string.gmatch(html, '<meta name="twitter:player:stream" value="(http[^"]+)"') do
Traceback (most recent call last):
File "discover.py", line 152, in <module>
main()
File "discover.py", line 44, in main
for shortcode in check_range(start_num, end_num):
File "discover.py", line 89, in check_range
text = fetch(url)
File "discover.py", line 119, in fetch
print('Got', response.status_code, response.reason)
AttributeError: 'Response' object has no attribute 'reason'

Keybase proof

I hereby claim:

  • I am cameron-d on github.
  • I am camerond (https://keybase.io/camerond) on keybase.
  • I have a public key whose fingerprint is 5589 946D 4B09 A6EE 48C9 5E05 AA3A F5C6 4D94 05A5

To claim this, I am signing this object:

Blocking task: Get video URLs. Please wait...
Traceback (most recent call last):
File "video.py", line 71, in <module>
main()
File "video.py", line 22, in main
assert response.geturl() == HTML_PAGE.format(video_id)
AssertionError
Command '['python', 'video.py', u'ideal-garage-doors-2720066']' returned non-zero exit status 1
Blocking task: Get video URLs. Please wait...
Traceback (most recent call last):
@Cameron-D
Cameron-D / pollrecount.php
Created July 7, 2014 11:06
Recount MyBB Polls
<?php
if(!defined("IN_MYBB"))
{
die("This file cannot be accessed directly.");
}
function pollrecount_info()
{
return array(
"name" => "Poll Recount",

Okay, so I'm assuming that is being run from a hook on do_new_reply_start?

Instead of calling error() in your code, put in the code from inside Cedric's function:

if(preg_match($regex, $post->data['message'], $match)) {
  if(!isset($mybb->cookies['myplugin_errors'])) {
    $count = 0;
  } else {
    $count = $mybb->cookies['myplugin_errors'];

}