Skip to content

Instantly share code, notes, and snippets.

View veggerby's full-sized avatar

Jesper Veggerby veggerby

View GitHub Profile
@veggerby
veggerby / gist:9ff8facc36fba1f19e542a733f57660d
Created February 2, 2018 12:39
Git Ignore Changes to a File
To ignore changes to a file:
git update-index --assume-unchanged [file]
To unignore changes to a file:
git update-index --no-assume-unchanged [file]
@veggerby
veggerby / gist:1506137
Created December 21, 2011 13:54
CSS Inline Block (incl. IE7)
.inline-block
{
display: -moz-inline-block;
display: inline-block;
zoom:1; *display: inline; /* IE7 */
}
@veggerby
veggerby / gist:1316028
Created October 26, 2011 10:55
CSS media queries
/*
Hardboiled CSS3 Media Queries by Andy Clarke:
http://stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries/
Author: Andy Clarke
Web site: http://stuffandnonsense.co.uk
Twitter: http://twitter.com/malarkey
Hardboiled Web Design
@veggerby
veggerby / gist:1064442
Created July 5, 2011 08:02
Get relative time string from a date
public static string ToRelativeTime(this DateTime from)
{
DateTime now = DateTime.Now;
return from.ToRelativeTime(now);
}
public static string ToRelativeTime(this DateTime from, bool usePreAndSuffix)
{
DateTime now = DateTime.Now;
return from.ToRelativeTime(now, usePreAndSuffix);
@veggerby
veggerby / gist:1064440
Created July 5, 2011 08:00
Get gravatar URL from Email
public static string GravatarUrl(this UrlHelper url, string email, int size)
{
string imageUrl = ConfigurationManager.AppSettings["DefaultGravatar"]; // e.g. "identicon" or a URL to image
if (imageUrl.StartsWith("~/"))
{
imageUrl = url.Absolute(imageUrl);
}
if (string.IsNullOrEmpty(email))
{
@veggerby
veggerby / slug.cs
Created July 5, 2011 08:00
Generate a "slug" for a URL from a string
public static string ToSlug(this string message)
{
// replace space with -
message = Regex.Replace(message, @"[\s/\\\.,+|_]+", "-");
// normalize the message
message = message.Normalize(NormalizationForm.FormD);
// do simple DK char replace
message = message.Replace("ø", "oe").Replace("Ø", "Oe").Replace("æ", "ae").Replace("Æ", "Ae").Replace("å", "aa").Replace("Å", "Aa");
@veggerby
veggerby / count-tables.sql
Created July 5, 2011 07:58
SQL Script to Get Row Count of All Tables in Database
-- Method 1:
sp_msforeachtable "SELECT '?', COUNT(*) FROM ?"
-- Method 2: (nicer, more details)
CREATE TABLE #TempTable
(
tableName varchar(100),
numberofRows varchar(100),
@veggerby
veggerby / buttons.css
Created July 5, 2011 07:53
CSS Button
/*** Source: http://particletree.com/features/rediscovering-the-button-element/ ***/
/* BUTTONS */
.buttons a, .buttons button
{
display:block;
float:left;
margin:0 7px 0 0;
background-color:#f5f5f5;
border:1px solid #dedede;