Skip to content

Instantly share code, notes, and snippets.

View joaofx's full-sized avatar
😁

Joao Carlos Clementoni joaofx

😁
View GitHub Profile
@roryf
roryf / Flash.cs
Created July 27, 2011 15:19
Flash message implementation for ASP.NET MVC
public class Flash : DynamicObject
{
private readonly TempDataDictionary _store;
private const string KeyPrefix = "Flash";
public Flash(TempDataDictionary store)
{
_store = store;
}
@amcclosky
amcclosky / raw_sql_util.rb
Created January 9, 2012 21:32
Simple Rails lib for executing raw SQL
module RawSqlUtil
def sql_select(sql, params)
# We have to do this weirdness because sanitize_sql_array is a protected method
query = ActiveRecord::Base.send(:sanitize_sql_array, [sql].concat(params))
ActiveRecord::Base.connection.select_all(query)
end
@SamSaffron
SamSaffron / gist:1599013
Created January 12, 2012 05:59
dapper.rainbow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using Dapper;
// to have a play, install Dapper.Rainbow from nuget
@roryf
roryf / IndexlessEnumerableModelBinder.cs
Created March 29, 2012 16:09
An ASP.NET MVC ModelBinder for binding form values of the form name[].property rather than name[index].property. Assumes form values are POSTed in markup order, unsure if this is always true.
public class IndexlessEnumerableModelBinder<TItemType> : DefaultModelBinder
where TItemType : class
{
protected override void BindProperty(ControllerContext controllerContext, ModelBindingContext bindingContext, PropertyDescriptor propertyDescriptor)
{
if (typeof(IEnumerable<TItemType>).IsAssignableFrom(propertyDescriptor.PropertyType))
{
var nameOfPropertyToBind = propertyDescriptor.Name;
var form = controllerContext.HttpContext.Request.Form;
@raygt
raygt / gist:3138501
Created July 18, 2012 19:59
Selenium 2 Webdriver Iterating Table
I found example 2 on the web but it was not exactly what i needed. so.. I put together example 1.
C# Example 1
public void VerifyTable(string header, string expected)
{
IWebElement table = _driverWithJs.FindElement(By.XPath("//div[@id='main']/table"));
ReadOnlyCollection<IWebElement> allRows = table.FindElements(By.TagName("tr"));
@MrDys
MrDys / gist:3512455
Created August 29, 2012 13:26
Link directly to an open modal window in Bootstrap
/* If you've ever had the need to link directly to an open modal window with Bootstrap, here's a quick and easy way to do it:
Make sure your modal has an id:
<div class="modal" id="myModal" ... >
Then stick this bit of Javascript at at the end of your document:
*/
$(document).ready(function() {
using System;
using System.Collections.Generic;
using FubuCore.Reflection;
using FubuMVC.Core.UI.Configuration;
using HtmlTags;
using MyProject.Core.Infrastructure.Extensions;
namespace MyProject.Core.Infrastructure.Fubu.HtmlConventions
{
public class EnumRadioButtonListEditor : ElementBuilder
@rpgmaker
rpgmaker / gist:4405468
Last active August 11, 2022 14:24
Expression Parser and example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Concurrent;
using System.Linq.Expressions;
using System.Collections;
namespace ExpressionParser {
(function ($) {
$.fubuvalidation.Processor.findElementsWith(function(context) {
var element = $("#" + context.key, context.form);
if (element.size() == 0) {
return;
}
context.element = element;
});
$.fubuvalidation.Processor.findElementsWith(function(context) {
var element = $("[name=" + context.key + "]", context.form);
@pdwetz
pdwetz / gist:4677630
Last active December 22, 2016 16:53
Useful little bits for FubuMVC; rather than dig through source, keeping them here for quick reference. I'll eventually post an article with them that's better for public consumption.
// If using FubuAthentication, update auth ticket as needed (e.g. account creation or key updated)
private readonly IAuthenticationSession _auth;
public SomeController(IAuthenticationSession auth) { _auth = auth; }
_auth.MarkAuthenticated(user.Email);
// If using FubuAuthentication, make route available to anonymous users
[NotAuthenticated]
public FubuContinuation SomeRoute(SomeRouteInputModel input)
{
// Use a continuation to redirect to input-less page