Skip to content

Instantly share code, notes, and snippets.

View smockle's full-sized avatar

Clay Miller smockle

View GitHub Profile
@smockle
smockle / MonthComparer.cs
Created April 3, 2013 19:58
MonthComparer matches month names to month numbers for comparison. It's written in C#.
public class MonthComparer : IComparer<string> {
public int Compare(string a, string b) {
var c = DateTime.ParseExact(a, "MMMM", CultureInfo.CurrentCulture).Month;
var d = DateTime.ParseExact(b, "MMMM", CultureInfo.CurrentCulture).Month;
return c - d;
}
}
@smockle
smockle / Fonts.css
Created April 8, 2013 19:37
Fonts is a web fonts example.
/* Add the following to web.config:
* <system.webServer>
* <staticContent>
* <remove fileExtension=".ttf" />
* <mimeMap fileExtension=".ttf" mimeType="application/x-font-ttf" />
* <remove fileExtension=".woff" />
* <mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
* <remove fileExtension=".svg" />
* <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
* </staticContent>
@smockle
smockle / SSH.sh
Created April 18, 2013 15:27
SSH with specified shell
ssh -t username@server "/bin/bash -i"
@smockle
smockle / Shorthand.js
Created May 5, 2013 21:15
Shorthand for jQuery's $(document).ready(function () { });
$(function() {
// Code here
});
@smockle
smockle / Screenshots.txt
Created May 6, 2013 00:36
Directions for taking a screenshot in OSX.
Command-Shift-3: Take a screenshot of the screen, and save it as a file on the desktop
Command-Shift-4, then select an area: Take a screenshot of an area and save it as a file on the desktop
Command-Shift-4, then space, then click a window: Take a screenshot of a window and save it as a file on the desktop
Command-Control-Shift-3: Take a screenshot of the screen, and save it to the clipboard
Command-Control-Shift-4, then select an area: Take a screenshot of an area and save it to the clipboard
Command-Control-Shift-4, then space, then click a window: Take a screenshot of a window and save it to the clipboard
@smockle
smockle / Killswitch.js
Created May 7, 2013 23:34
Killswitch is obfuscated JavaScript that ensures a header image includes a secret message.
// <header><img src="<%: Url.Content("~/content/images/header.png") %>" data-message="10110010110000100000010001110100010011101010011001110110011101101000011001000110000001001100111010010110000101100010111000000100101001100010111010000110000101100000010010010010"></header>
var __h = $("header img");
var __b = $("body");
if (__h.height() != null && __h.attr("data-message") != "01001001001000000110100001100001011101000110010100100000011101000110100001101001011100110010000001100010011000010110111001101110011001010111001000101110001000000100001101001101".split("").reverse().join("")) {
__b.empty();
var __s = "01111100011011101001011000100110111101000011110001111100000011101111010000111100011101000001011011000110101011101011011000000100111011101111011000010110000001001110111011110110011101101101011000000100100100100000010001110100101001101011001001111100000011100011110001111100000011101111010000111100111111001100111011100110011101101001011001001110010001100000010000101110100101100000010001110110
@smockle
smockle / Routing.cs
Created May 7, 2013 23:39
Routing creates URLs without displaying a controller name. For ASP.NET MVC4.
RouteTable.Routes.MapRoute("SpecificRoute", "{action}/{id}", new { controller = "Home", action = "Index", id = UrlParameter.Optional });
@smockle
smockle / Tweet.cs
Created May 8, 2013 00:05
Tweets uses HTTPWebRequest to authenticate and post to Twitter.
/* Submit to Twitter. */
public void Twitter(Post post) {
// Get the OAuth params.
string status = post.title + " http://blog.smockle.com/" + post.id;
string postBody = "status=" + Uri.EscapeDataString(status);
string oauth_consumer_key = Properties.Settings.Default.Twitter_Consumer_Key;
string oauth_nonce = Convert.ToBase64String(new ASCIIEncoding().GetBytes(DateTime.Now.Ticks.ToString()));
string oauth_signature_method = "HMAC-SHA1";
string oauth_token = Properties.Settings.Default.Twitter_Token;
@smockle
smockle / Timing.js
Created May 8, 2013 00:09
Timing demonstrates a JavaScript delay and loop.
// Delay
window.setTimeout(function(){}, 1000);
// Loop
var l = window.setInterval(function(){}, 1000);
window.clearInterval(l);
@smockle
smockle / Flip.css
Created May 9, 2013 19:45
Flip demonstrates a flip animation using CSS. Tested in Google Chrome 26, IE 10, and Firefox Nightly.
/* entire container, keeps perspective */
body .flip-container {
width: 100%;
}
body .flip-container .flipper {
position: relative;
}
/* hide back of pane during swap */