Skip to content

Instantly share code, notes, and snippets.

@jaykz52
jaykz52 / Vehicle.coffee
Created December 27, 2010 01:47
An example of Coffeescript's inheritance system
class Vehicle
drive: ->
alert "The vehicle moves forward!"
class Motorcyle extends Vehicle
drive: ->
alert "The Motorcyle moves forward!"
class Car extends Vehicle
drive: ->
@jaykz52
jaykz52 / style2.scss
Created December 16, 2010 03:36
Example for Sass/ASP.NET Integration
/* style.scss */
@mixin colorize {
$color: blue;
$bg-color: green;
color: $color;
background-color: $bg-color;
}
p {
@jaykz52
jaykz52 / mixins_style.css
Created December 16, 2010 00:28
An example of the "compiled" css produced by Sass
p {
color: blue;
background-color: green;
margin-bottom: 20px; }
@jaykz52
jaykz52 / style_mixins.scss
Created December 16, 2010 00:27
An example of using mixins in Sass
@mixin colorize {
$color: blue;
$bg-color: green;
color: $color;
background-color: $bg-color;
}
p {
@include colorize;
margin-bottom: 20px;
@jaykz52
jaykz52 / theme.scss
Created December 15, 2010 04:26
An example of utilizing variables in Sass files
$main-color: #701A14;
$sub-color: #A64C32;
$accent-color: #BF8B5B;
/* Changing color schemes is as simple as updating the 3 lines above */
p {
color: $main-color;
background-color: $sub-color;
.accent {
color: $sub-color;
@jaykz52
jaykz52 / style.scss
Created December 15, 2010 03:55
An example of nesting/parent references in Sass
a {
color: green;
&:hover {
text-decoration: underline;
}
&:active {
color: purple;
}
&:visited {
color: yellow;
@jaykz52
jaykz52 / style.css
Created December 15, 2010 03:49
An example of how we traditionally handle the various anchor states
a {
text-decoration: none;
color: green;
}
a:hover {
text-decoration: underline;
}
a:active {
color: purple;
}
@jaykz52
jaykz52 / DBConnection_With_Factory.cs
Created December 14, 2010 03:10
An example of using static factory methods in place of constructors
public class DBConnection
{
private const int MAXCONNECTIONS = 5;
private static int connectionsOpen = 0;
private DBConnection(){}
// static factory in some sort of pooling situation
public static DBConnection GetConnection()
{
@jaykz52
jaykz52 / DBConnection_NoCompile.cs
Created December 14, 2010 02:57
An example of a situation where a developer is limited by constructor rules
// this class doesn't compile!
public class DBConnection
{
public DBConnection(string pConnectionString, bool pIsTransactional)
{
// do something mind-blowingly awesome
}
public DBConnection(string pConnectionString, bool pKeepAlive)
{
@jaykz52
jaykz52 / DBConnection.cs
Created December 14, 2010 02:33
An example of place where constructors don't allow us full control over a class's behavior
public class DBConnection
{
private const int MAXCONNECTIONS = 5; // arbitrary
public DBConnection()
{
// Oh no, what if we're over the max allowed connections!
}
}