Skip to content

Instantly share code, notes, and snippets.

💭
🐱‍🐉

Aaron Powell aaronpowell

💭
🐱‍🐉
Block or report user

Report or block aaronpowell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@aaronpowell
aaronpowell / Simple JavaScript console
Created Nov 10, 2010
A basic JavaScript console window for browsers that don't support the console object
View Simple JavaScript console
if (!window.console) {
window.onload = function() {
var txt = document.createElement('textarea');
txt.style.position = 'absolute';
txt.style.top = '0px';
txt.style.left = '0px';
txt.style.height = '800px';
txt.style.width = '500px';
txt.id = 'console';
document.body.appendChild(txt);
View DictionaryTests.cs
public class Foo : IEquatable<Foo>
{
readonly int bar;
public Foo(int bar)
{
this.bar = bar;
}
public override bool Equals(object obj)
View DictionaryTests.cs
public class Foo : IEquatable<Foo>
{
readonly int bar;
public Foo(int bar)
{
this.bar = bar;
}
public override bool Equals(object obj)
View Flatten Dictionary
var dict = new Dictionary<string, int> {
{ "John", 3 },
{ "Mary", 4 }
};
var flattened = dict.Select(x =>
Enumerable.Range(0, x.Value).Select(_ => x.Key)
)
.SelectMany(x => x);
@aaronpowell
aaronpowell / StronglyTypeAnonymous.cs
Created Dec 3, 2010
Makes an anonymous type implement an interface
View StronglyTypeAnonymous.cs
//uses ClaySharp: http://clay.codeplex.com
//add the following usings
//using ClaySharp;
//using ClaySharp.Behaviors;
void Main()
{
var foo = TypeMe<IFoo>(new { Id = 1, Name = "Aaron" });
Console.WriteLine(foo.Id);
Console.WriteLine(foo.Name);
View Loader.html
<!doctype html>
<html>
<head>
<title>Loader</title>
<script type="text/javascript">
//assume this is in an external file, so we do an external here
var loader = (function() {
var scripts = [];
var ret = {
@aaronpowell
aaronpowell / loader.js
Created Jan 28, 2011
A simple JavaScript library for lazy loading JavaScript files
View loader.js
var loader = (function() {
var scripts = [];
var dw = function(s) {
document.write(s);
};
var ret = {
add: function(src) {
if(!scripts.indexOf(src)) {
scripts.push(src);
}
@aaronpowell
aaronpowell / blinky.js
Created Feb 9, 2011
How to implement blink with jQuery
View blinky.js
(function($) {
$.fn.blinky = function(args) {
var opts = { frequency: 1e3, count: -1 };
args = $.extend(true, opts, args);
var i = 0;
var that = this;
var dfd = $.Deferred();
function go() {
if(that.length == 0) {
return dfd.reject();
@aaronpowell
aaronpowell / marquee.js
Created Feb 10, 2011
How to implement marquee with jQuery
View marquee.js
(function($) {
$.fn.textWidth = function(){
var calc = '<span style="display:none">' + $(this).text() + '</span>';
$('body').append(calc);
var width = $('body').find('span:last').width();
$('body').find('span:last').remove();
return width;
};
$.fn.marquee = function(args) {
View wins.cs
var s = "asd";
switch(true) {
case true:
if(s == "dsa") {
goto case false;
}
s = "dsa";
goto case true;
You can’t perform that action at this time.