Skip to content

Instantly share code, notes, and snippets.

View balexandre's full-sized avatar
🙃

Bruno Alexandre balexandre

🙃
View GitHub Profile
public class DataTranslator
{
public static Func<IDataRecord, T> CreateTranslator<T>(IDataRecord record)
{
Type targetType = typeof(T);
string cacheKey = string.Format("{0}-Translator", targetType);
var cachedTranslator = WebContextCache.GetItem<Func<IDataRecord, T>>(cacheKey);
if (cachedTranslator != null)
@mmriis
mmriis / gist:1286783
Created October 14, 2011 10:35
CVR.dk
http://cvr.dk/Site/Forms/PublicService/DisplayCompany.aspx?cvrnr=30505166
def extract_name(doc)
(doc/"div.titletext").inner_html.strip
end
def extract_address(doc)
(doc/"tr:contains('Adresse')/td.fieldvalue").inner_html =~ /^(.+)<br\W+\d{4}\W+(.+)$/
$~[1].strip.gsub("<br />", ", ")
end
public class Analytics
{
// Tracker version.
private const string Version = "4.4sa";
private const string CookieName = "__utmmobile";
// The path the cookie will be available to, edit this to use a different
// cookie path.
private const string CookiePath = "/";
@hellerbarde
hellerbarde / latency.markdown
Created May 31, 2012 13:16 — forked from jboner/latency.txt
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@Korayem
Korayem / TrackEventsInGoogleAnalyticsAttribute.cs
Created June 4, 2012 15:58
A cool ActionFilter that when dropped over any controller or action, you got yourself google analytics event tracking! By default we assign controller name as category, and action name as the action. In the label we drop the user identity in case he/she i
using System.Configuration;
using System.Web.Mvc;
using GoogleAnalyticsTracker;
using SocialFruits.Domain;
using SocialFruits.Domain.Entities;
namespace SocialFruits.Extensions.Attributes
{
public class TrackEventsInGoogleAnalyticsAttribute : ActionFilterAttribute
{
@brianleroux
brianleroux / web-based-diagramming-tools.md
Created September 8, 2012 19:37
I asked about web based diagramming tools on twitter. Ppl answered!
@shanselman
shanselman / gist:5422230
Last active March 28, 2024 10:33
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
@eddwo
eddwo / gist:5423102
Created April 19, 2013 20:44
Comment spam generator based on the template discovered by Scott Hanselman https://gist.github.com/shanselman/5422230
abstract class Comment
{
public abstract void Generate(StringBuilder builder);
public string Generate()
{
StringBuilder builder = new StringBuilder();
this.Generate(builder);
return builder.ToString();
}
@randyburden
randyburden / BooleanJsonConverter.cs
Created July 4, 2013 04:42
A Json.NET JsonConverter that can handle converting the following values into boolean values: true, false, yes, no, y, n, 1, 0.
using System;
using Newtonsoft.Json;
namespace JsonConverters
{
/// <summary>
/// Handles converting JSON string values into a C# boolean data type.
/// </summary>
public class BooleanJsonConverter : JsonConverter
{
@lavoiesl
lavoiesl / bs3-stacked-tabs.less
Created September 18, 2013 15:21
Add tabs-left, tabs-right and tabs-below in bootstrap 3 Credit: http://stackoverflow.com/questions/18432577/stacked-tabs-in-bootstrap-3
// http://stackoverflow.com/questions/18432577/stacked-tabs-in-bootstrap-3
.tabs-below, .tabs-right, .tabs-left {
.nav-tabs {
border-bottom: 0;
}
}
.tab-content > .tab-pane,
.pill-content > .pill-pane {
display: none;