Skip to content

Instantly share code, notes, and snippets.

@belsrc
belsrc / gist:4132373
Created November 22, 2012 17:55
Apple Touch Icon Links - HTML
<!-- From Mathias Bynens' blog post 'Everything you always wanted to know about touch icons' (http://mathiasbynens.be/notes/touch-icons) -->
<!-- For third-generation iPad with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="apple-touch-icon-144x144-precomposed.png">
<!-- For iPhone with high-resolution Retina display: -->
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114x114-precomposed.png">
<!-- For first- and second-generation iPad: -->
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72x72-precomposed.png">
@belsrc
belsrc / gist:4137754
Created November 23, 2012 23:55
Measuring container height before collapsing - C#
private void Window_Loaded( object sender, RoutedEventArgs e ) {
container.Measure( new Size( Double.PositiveInfinity, Double.PositiveInfinity ) );
this._containHeight = container.DesiredSize.Height;
container.Height = 0;
}
@belsrc
belsrc / gist:4141280
Last active October 13, 2015 04:47
Send SMTP Mail - C#
private void SendEmail(string from, IEnumerable<string> to, string subj, string body, bool isHtml = false, SmtpClient client) {
MailMessage message = new MailMessage();
message.From = new MailAddress( from );
foreach( string copy in cc ) {
message.To.Add( new MailAddress( copy ));
}
message.Subject = subj;
message.Body = body;
message.IsBodyHtml = isHtml;
@belsrc
belsrc / gist:4715772
Last active December 12, 2015 04:38
WPF Gravatar Image Binding
using Cgum; // Common methods - EncryptMd5() [personal library]
// init: Gravatar = GetAvatar( email )
public static readonly DependencyProperty GravatarProperty =
DependencyProperty.Register( "Gravatar",
typeof( BitmapImage ),
typeof( SingleCustomerVM ),
new PropertyMetadata(
new BitmapImage()
@belsrc
belsrc / gist:4715782
Last active December 12, 2015 04:38
Find duplicate items in multiple lists
List<List<string>> lists = new List<List<string>>() {
new List<string> {"Hello", "World", "7"},
new List<string> {"Hello", "7", "Person"},
new List<string> {"7", "7", "Hello"}
};
List<string> common = lists.Cast<IEnumerable<string>>(
.Aggregate( ( a, b ) => a.Intersect( b ) )
.ToList();
@belsrc
belsrc / gist:4997411
Created February 20, 2013 17:42
IEnumerable String Replace
var list = list.Select( s => s.Replace( toReplace, replace ) ).ToArray();
@belsrc
belsrc / gist:5178977
Created March 17, 2013 00:27
ADO.Net GetData
private DataTable GetData( string conString, string table ) {
DataTable dt = new DataTable();
using( SqlConnection sqlConn = new SqlConnection( conString ) ) {
sqlConn.Open();
using( SqlCommand sqlCmd = new SqlCommand( "SELECT * FROM " + table, sqlConn ) ) {
using( SqlDataAdapter sqlDa = new SqlDataAdapter( sqlCmd ) ) {
sqlDa.Fill( dt );
}
}
@belsrc
belsrc / gist:451921b27eadfa4479e1
Last active December 6, 2019 00:36
touch command in Powershell
# Type 'notepad $profile' to open your profile ps1 file and add
# This will add the file if it doesn't exist or update the
# last write time if it does
# If you get some message about not being able to run scripts then you need to type the following command and restart powershell
# Set-ExecutionPolicy Bypass
Function touch {
$file = $args[0]
if($file -eq $null) {
@belsrc
belsrc / gist:672b75d1f89a9a5c192c
Last active April 15, 2023 15:13
Simple Vue.js filters that I usually need
/**
* Changes value to past tense.
* Simple filter does not support irregular verbs such as eat-ate, fly-flew, etc.
* http://jsfiddle.net/bryan_k/0xczme2r/
*
* @param {String} value The value string.
*/
Vue.filter('past-tense', function(value) {
// Slightly follows http://www.oxforddictionaries.com/us/words/verb-tenses-adding-ed-and-ing
var vowels = ['a', 'e', 'i', 'o', 'u'];
@belsrc
belsrc / gist:70548d021d15a8e397de
Created October 5, 2014 21:04
Download Site for offline use
# -p get all images, etc. needed to display HTML page.
# --mirror turns on recursion and time-stamping, sets infinite
# recursion depth and keeps FTP directory listings
# --html-extension save HTML docs with .html extensions
# --convert-links make links in downloaded HTML point to local files.
wget --mirror -p --html-extension --convert-links www.example.com