Skip to content

Instantly share code, notes, and snippets.

View apiguy's full-sized avatar

Freedom Dumlao apiguy

View GitHub Profile
draw :text, "To Do:", :font_size => 24
draw :text, "Empty list...", :named => "todo_list", :height => 150
draw :edit_line, :named => "input"
draw :button, "Add to list", :named => "clicker"
public static Func<T, bool> ExBuildEqFuncFor<T>(string prop, object val)
{
var o = Expression.Parameter(typeof(T), "t");
Expression<Func<T, bool>> expression =
Expression.Lambda<Func<T, bool>>(
Expression.Equal(
Expression.PropertyOrField(o, prop),
Expression.Constant(val)), o);
return expression.Compile();
public static Func<T, bool> BuildEqFuncFor<T>(string prop, object val)
{
return t => t.GetType().InvokeMember(
prop, BindingFlags.GetProperty, null, t, null) == val;
}
public static Func<T, bool> ExBuildEqFuncFor<T>(string prop, object val)
{
var o = Expression.Parameter(typeof(T), "t");
Expression<Func<T, bool>> expression =
Expression.Lambda<Func<T, bool>>(
Expression.Equal(
Expression.PropertyOrField(o, prop),
Expression.Constant(val)), o);
return expression.Compile();
require "kiddo"
Kiddo.start do
draw :stack do
draw :text, "Text to reverse:", :font_size => 18
draw :edit_box, :named => "input"
draw :text, "Your string will show up here.", :named => "result"
draw :button, "Reverse It!", :named => "fun_button"
end
draw :text, "Some text to draw", :font_size => 24
require "kiddo"
Kiddo.start do
screen :named => "image_screen" do
draw :stack do
draw :image, "Penguins.jpg"
draw :button, "See info", :named => "see_info"
end
end
after :my_button.is_clicked do
# this will be executed after my_button is clicked
end
bind :status_dropdown, :to => ["Active", "Inactive", "Asleep"]
@apiguy
apiguy / gist:4660026
Created January 28, 2013 22:47
Super basic way to get a wsgi app running on cherrypy with autoreload. Useful for development and testing.
import cherrypy
from main import app
cherrypy.config.update({'server.socket_host': '0.0.0.0',
'server.socket_port': 8080})
cherrypy.tree.graft(app)
if __name__ == '__main__':
try:
cherrypy.engine.start()