This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Adds an item to the list only if it doesn't already exist there. | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <param name="coll"></param> | |
/// <param name="item"></param> | |
public static void AddIfNotExists<T>(this ICollection<T> coll, T item) { | |
if (!coll.Contains(item)) | |
{ | |
coll.Add(item); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ratings.Sort((x, y) => x.Grade.CompareTo(y.Grade)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string TrimTrailingComma(string value) | |
{ | |
if (value.Length >= 2) | |
{ | |
if(value[value.Length-1].Equals(" ") && value[value.Length-2].Equals(",")) | |
{ | |
value = value.Substring(0, value.Length - 2); | |
} | |
else if (value[value.Length - 1].Equals(",")) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function pollForUpdate(){ | |
setTimeout(function(){ | |
$.post('/some/url/', function(data){ | |
//process data | |
pollForUpdated(); | |
}); | |
}, 5000); | |
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function console_table(xs) { | |
function pad(n, s) { | |
var res = s; | |
for (var i = s.length; i < n; i++) | |
res += " "; | |
return res; | |
} | |
if (xs.length === 0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Pure CSS | |
.element { | |
position: relative; | |
top: 50%; | |
transform: translateY(-50%); | |
} | |
// Less Mixin | |
.vertical-align { | |
position: relative; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Object.prototype.extend = function(obj){ | |
if(typeof obj !== 'object') return this; | |
var current, prop, | |
i = 0, | |
length = arguments.length; | |
for(; i<length; i++){ | |
current = arguments[i]; | |
if(typeof current === 'object'){ | |
for(prop in current){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
textarea, textarea:focus { | |
width:100%; | |
height:100%; | |
margin: 0; | |
border:0; | |
border-color:transparent; | |
outline:none; | |
overflow-y:auto; | |
resize:none; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Marcus Noble - Conway's Game Of Life</title> | |
<style type="text/css"> | |
* { | |
box-sizing:border; | |
} | |
body{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "U8glib.h" | |
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NO_ACK); // Display which does not send AC | |
void draw(void) { | |
u8g.drawPixel(53,11); | |
u8g.drawPixel(54,11); | |
u8g.drawPixel(54,12); | |
u8g.drawPixel(53,12); | |
u8g.drawPixel(55,11); | |
u8g.drawPixel(55,12); |
OlderNewer