Skip to content

Instantly share code, notes, and snippets.

View rmariuzzo's full-sized avatar
🤒
Fighting a cancer.

Rubens Mariuzzo rmariuzzo

🤒
Fighting a cancer.
View GitHub Profile
@rmariuzzo
rmariuzzo / GetExpressionText.cs
Last active December 12, 2015 04:48
A better `ExpressionHelper.GetExpressionText` that handles Convert Expression.
/// <summary>
/// Return the expression text
/// </summary>
/// <typeparam name="TModel"></typeparam>
/// <param name="expression"></param>
/// <returns></returns>
public static string GetExpressionText<TModel>(Expression<Func<TModel, object>> expression)
{
var expr = (LambdaExpression)expression;
if (expr.Body.NodeType == ExpressionType.Convert)
@rmariuzzo
rmariuzzo / palindrome.js
Created March 16, 2012 05:20
Contest: 1 line of JS: Smallest Palindrome Checker
/**
* Check if a word or phrase is a palindrome in 106 characters of JavaScript.
*/
function isPalindrome(s) {
return s.match(/[a-zA-Z]/g).join('').toLowerCase()==s.match(/[a-zA-Z]/g).reverse().join('').toLowerCase();
}
@rmariuzzo
rmariuzzo / hex2int
Created January 26, 2012 13:09
A simple JavaScript function to convert an hexadecimal value into its integer base-10 equivalent.
/**
* Convert an hexadecimal value in a integer base-10.
* @param hex An hexadecimal value to convert.
* @return An integer base-10 equivalent to the given hexadecimal value.
*/
function hex2int(hex) {
return parseInt(hex, 16);
}