Skip to content

Instantly share code, notes, and snippets.

View alassek's full-sized avatar

Adam Lassek alassek

View GitHub Profile
export:
foreach ($n in (1..15)) { cmd.exe /c "mysqldump -u root --password={password here} s88franchise$n > s88franchise$n.sql" }
import:
foreach ($n in (1..15)) { cmd.exe /c "mysql -u root --password={password here} s88franchise$n < s88franchise$n.sql" }
import (bash):
private bool ValidEmailAddress(string emailAddress)
{
string qtext = "[^\\x0d\\x22\\x5c\\x80-\\xff]"; // <any CHAR excepting <">, "\" & CR, and including linear-white-space>
string dtext = "[^\\x0d\\x5b-\\x5d\\x80-\\xff]"; // <any CHAR excluding "[", "]", "\" & CR, & including linear-white-space>
string atom = "[^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+"; // *<any CHAR except specials, SPACE and CTLs>
string quoted_pair = "\\x5c[\\x00-\\x7f]"; // "\" CHAR
string quoted_string = string.Format("\\x22({0}|{1})*\\x22", qtext, quoted_pair); // <"> *(qtext/quoted-pair) <">
string word = string.Format("({0}|{1})", atom, quoted_string); //atom / quoted-string
string domain_literal = string.Format("\\x5b({0}|{1})*\\x5d", dtext, quoted_pair); // "[" *(dtext / quoted-pair) "]"
//case-insensitive selector for ASP.Net ID's
//usage: $(':aspnetid(id)')
jQuery.extend(
jQuery.expr[":"],
{
aspnetid: function(a, i, m) {
return (new RegExp(m[3] + '$', 'i')).test(jQuery(a).attr('id'));
}
}
String.prototype.padLeft = function(length, s) {
var pad = [];
var padding = length - this.length;
if (padding > 0) {
for (i = 0; i < padding; i++) pad.push(s);
return pad.join('') + this;
}
return this + '';
}
public static class Extensions
{
public static bool IsNumeric(this String value)
{
return Regex.IsMatch(value, @"^\d+$");
}
public static string Numeric(this string value)
{
return Regex.Replace(value, "\\D", String.Empty);
@alassek
alassek / ModernButton.cs
Created February 24, 2009 22:37
ASP.Net Button control that renders with Button tag instead of input
[ParseChildren(false)]
public class ModernButton : WebControl
{
//Fields
private static readonly object EventClick;
private static readonly object EventCommand;
//Events
public event EventHandler Click;
public event CommandEventHandler Command;