Skip to content

Instantly share code, notes, and snippets.

View jasonyost's full-sized avatar

Jason Yost jasonyost

View GitHub Profile
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...
}
@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.Split(inputString, "<br>");
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);
@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.");
}
});
@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 / 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 / command.zsh
Created June 19, 2014 19:45
Reload .zshrc
source ~/.zshrc
# or the shorter
. ~/.zshrc
# In the .zshrc file you can add an alias such as
alias zshreload="source ~/.zshrc"
# You can then just type zshreload after making changes to your .zshrc file.
@jasonyost
jasonyost / .zshrc
Created June 19, 2014 19:57
My .zshrc
# Path to your oh-my-zsh installation.
export ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="pygmalion"
# Example aliases
@jasonyost
jasonyost / virtualbox-additions.sh
Created June 20, 2014 05:03
Run command to fix screen resolution on ubuntu linux
sudo apt-get install virtualbox-guest-utils virtualbox-guest-x11 virtualbox-guest-dkms