Skip to content

Instantly share code, notes, and snippets.

View taxilian's full-sized avatar

Richard Bateman taxilian

View GitHub Profile
@taxilian
taxilian / ProxyHandler.cpp
Created December 22, 2010 16:07
Example of using HTTPService as an embedded web server
/*
* ProxyHandler.cpp
* fbplugin
*
* Copyright Facebook, inc
*/
#include "HTTPClient/HTTPRequest.h"
#include <boost/algorithm/string.hpp>
#include <boost/assign/list_of.hpp>
@taxilian
taxilian / default.py
Created March 21, 2011 17:06
example phenny configuration tied mostly to 2600hz
nick = 'taxTestBot'
host = 'irc.freenode.net'
channels = ['#2600hz_bottest']
owner = 'steph021'
password = 'F!reB0T!'
# These are people who will be able to use admin.py's functions...
admins = [owner, 'pyite']
# But admin.py is disabled by default, as follows:
@taxilian
taxilian / show_function.py
Created May 5, 2011 22:38
couchdbkit show function support
def show(self, show_name, doc_id, **params):
""" Execute a show function on the server and return the response.
If the response is json it will be deserialized, otherwise the string
will be returned.
Args:
@param show_name: should be 'designname/showname'
@param doc_id: id of the document to pass into the show document
@param params: params of the show
"""
@taxilian
taxilian / gist:1028036
Created June 15, 2011 20:32
modified jenkins launch plist
We couldn’t find that file to show.
@taxilian
taxilian / json.cpp
Created June 16, 2011 20:23
json-cpp to and from FB::variant
#include "json.h"
FB::variant jsonValueToVariant( Json::Value root )
{
Json::Value def;
if (root.isString())
return root.asString();
else if (root.isBool())
return root.asBool();
else if (root.isDouble())
@taxilian
taxilian / example.cpp
Created June 22, 2011 06:36
partial example of global keyboard event handler
void *EventLoop(void *args)
{
int state;
pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &state);
pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &state);
// In one thread run the event loop to get hotkey presses
EventHotKeyID gMyHotKeyID1, gMyHotKeyID2;
EventTypeSpec eventType;
@taxilian
taxilian / ImageDraw.cpp
Created July 6, 2011 21:21
Example windows image draw function for FireBreath
void PluginObject::drawImage(FB::PluginWindow *wnd, FB::PluginEvent* evt, unsigned char *img, int width, int height) {
HDC hdc=NULL;
BITMAPINFO bitmapInfo;
bitmapInfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
bitmapInfo.bmiHeader.biBitCount=32;
bitmapInfo.bmiHeader.biCompression=BI_RGB;
bitmapInfo.bmiHeader.biPlanes = 1;
bitmapInfo.bmiHeader.biSizeImage = width*height*4;
bitmapInfo.bmiHeader.biWidth = width;
@taxilian
taxilian / gist:1095427
Created July 20, 2011 17:28
Building libcurl and openssl on windows statically

Building static libcurl and openssl on Windows

These instructions were tested on Windows 7 Professional w/ Visual Studio 2010

Building openssl

  1. Download the latest openssl from the website; at the time of this writing, it is 1.0.0d
  2. Extract it to your drive; I put it in c:\code\openssl-1.0.0d
  3. install ActiveState perl unless you already have a non-cygwin perl installed on windows
@taxilian
taxilian / BitBlitter.cpp
Last active January 4, 2020 01:53
Example mac CoreGraphics draw function for FireBreath
// Platform independent
#include "BitBlitter.h"
#include "precompiled_headers.h" // Anything before this is PCH on windows
bool BitBlitter::onWindowRefresh( FB::RefreshEvent *evt, FB::PluginWindow *win )
{
boost::mutex::scoped_lock _l(preview_mutex);
@taxilian
taxilian / utf8_utils.cpp
Created July 29, 2011 18:41
utf8 conversion tools
std::string wstring_to_utf8(const std::wstring& src) {
std::string out_str;
#ifdef _WIN32
utf8::utf16to8(src.begin(), src.end(), std::back_inserter(out_str));
#else
utf8::utf32to8(src.begin(), src.end(), std::back_inserter(out_str));
#endif
return out_str;
}