This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def index_in_tuple(value, iterable): | |
return [num for num, val in enumerate(iterable) if val is value][0] | |
# Works for lists too, but those already have this functionality built in. | |
# How it works: | |
# value = "three" | |
# iterable = ("one", "two", "three", "four") | |
# enumerate(iterable) => ( (0, "one"), (1, "two") ... ) | |
# num for num, val => 0, "one" [...] # num refers to the '0' in this case | |
# ..."if val is value" => but only if "one" is "three" (which it's not) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I had the worst time in the world trying to determine how to do this. | |
// I did not find the answer in one concise resource. I figured I'd make this available | |
// to anyone else having the same trouble. | |
#include <usr/include/boost/python.hpp> // use your path here | |
#include <iostream> | |
#include <string> | |
namespace py = boost::python; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I've been trying to better understand pointers, so I made this as a reference for myself. | |
// Figured it wouldn't hurt to make it available if anyone else is having any problems. | |
#include <iostream> | |
using namespace std; | |
int main() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
A class to manage arrays of pointers, all of which can be accessed individually. | |
Copyright (C) 2012 Tom Thorogood | |
This program is free software: you can redistribute it and/or modify | |
it under the terms of the GNU General Public License as published by | |
the Free Software Foundation, either version 3 of the License, or | |
(at your option) any later version. | |
This program is distributed in the hope that it will be useful, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void submitBroadcast(BroadcastMessage* broadcast) | |
{ | |
namespace TypeBits = Enums::SignalTypes; | |
unsigned char signalType = broadcast->getSignalType(); | |
// Verify the integrity of this broadcast. | |
if (signalType < SIGNALRANGE[0] || signalType > SIGNALRANGE[1]) | |
{ | |
//@TODO: Throw Error! | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
using namespace std; | |
typedef string (*callback)(string); | |
string cb1 (string str) | |
{ | |
return str + "...in bed!"; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a complete example of how to build a slideshow in mogu. For more information, | |
# check out the mogu wiki at http://www.github.com/tomthorogood/mogu/wiki | |
widgets["slidestack"] = \ | |
{ | |
type : container, | |
styles : "width_400 height_300" | |
name : "slidestack" #for event bindings | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The following is a demonstration of creating a test suite in the Mogu framework. There are some utility functions that allow you to hand-tool Mogu widgets for testing. | |
The following test will demonstrate checking the parsed string "|WidgetName| $value$", valid Mogu syntax in the Borel distribution. Having this string in your database should be parsed to the current text value of the widget registered as "WidgetName". | |
For instance, if you had the following: | |
```python | |
widgets["testwidget"] = \ | |
{ | |
type : text, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Note! The VM has Python 2.6.6, which does not have argparse installed by default. | |
# | |
# You can fix this by running the following two commands: | |
# sudo apt-get install python-pip | |
# sudo pip install argparse | |
# | |
# Make sure to chmod +x opencompare.py | |
# Then you can do ./opencompare.py test_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will show a complete example of adding a user into a Mogu application. | |
# First, you will need to provide a username andpassword. Both of these widgets should be named widgets. In this example, we use an email address as a username to also exemplify adding a contact email for password resets. | |
# The username is going to be the user's email address. | |
# We are going to create a validator for this field, which will | |
# be updated in real time as a user enters their email. | |
# We also add a tooltip here. | |
widgets["registration:form:username"] = \ |
OlderNewer