Skip to content

Instantly share code, notes, and snippets.

View jasonyost's full-sized avatar

Jason Yost jasonyost

View GitHub Profile
@jasonyost
jasonyost / animatedjs-example.html
Created June 17, 2014 07:32
Animated.js Tag Example
<div id="opacity" data-animated-property="opacity" data-animated-from="1" data-animated-to="0"></div>
@jasonyost
jasonyost / output.haml
Created June 16, 2014 10:16
Atom snippet for creating HTML document in HAML
!!!
%html
%head
%title
= content_for?(:title) ? yield(:title) : ""
%body
= yield
@jasonyost
jasonyost / ASP.NET jQuery POST exclude ViewState
Last active August 29, 2015 14:01
ASP.NET jQuery POST exclude ViewState
// POST all the datas! except the ViewState
jQuery.post('https://www.example.com', jQuery("#form :not(#__VIEWSTATE) > :input").serialize() ,function(data,status){
if(data[0]["Status"] == "Success"){
jQuery("#poststatus").html("Thank you!");
}else{
jQuery("#poststatus").html("There has been an error while accepting your submission. Please contact us.");
}
});
using System.Web.Mvc;
public static class GravatarExtensions
{
public static MvcHtmlString Gravatar(this HtmlHelper helper, string email, string username, int size)
{
var baseURL = "http://www.gravatar.com/avatar/{0}?s={1}&d=identicon&r=PG";
TagBuilder link = new TagBuilder("a");
link.Attributes.Add("href", "/User/" + username);
Regex.Split(inputString, "<br>");
@jasonyost
jasonyost / MD5.cs
Created July 23, 2010 04:50
Create MD5 from string in C#
public static string MD5Hash(string input)
{
StringBuilder hash = new StringBuilder();
MD5CryptoServiceProvider md5provider = new MD5CryptoServiceProvider();
byte[] bytes = md5provider.ComputeHash(new UTF8Encoding().GetBytes(input));
for (int i = 0; i < bytes.Length; i++)
{
hash.Append(bytes[i].ToString("x2"));
}
Regex rxnum = new Regex(@"(\d+(?! */))? *-? *(?:(\d+) */ *(\d+))?.*$");
Match numMatch = rxnum.Match(ingredient);
if (numMatch.Success)
{
amount = (!string.IsNullOrEmpty(numMatch.Groups[1].Value) ? numMatch.Groups[1].Value : string.Empty) + (!string.IsNullOrEmpty(numMatch.Groups[2].Value) ? " " + numMatch.Groups[2].Value + "/" + numMatch.Groups[3].Value : string.Empty);
// do something with the amount...
}