Skip to content

Instantly share code, notes, and snippets.

View fiveisprime's full-sized avatar
🖤

Matt Hernandez fiveisprime

🖤
View GitHub Profile
@fiveisprime
fiveisprime / gist:2943060
Created June 17, 2012 01:15
Lion Color Picker
set chosenColor to choose color default color {65535, 65535, 65535}
set the formattedColor to my hex(chosenColor)
on hex(chosenColor)
set the hex_list to {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"}
set the hex_value to ""
repeat with i from 1 to the count of the chosenColor
set this_value to (item i of the chosenColor) div 256
set x to item ((this_value div 16) + 1) of the hex_list
set y to item (((this_value / 16 mod 1) * 16) + 1) of the hex_list
set the hex_value to (the hex_value & x & y) as string
@fiveisprime
fiveisprime / employee-options.js
Created June 17, 2012 01:26
Object.create inheritance example
var employee = Object.create(matt, {
id: {
value: '1234',
writable: false
},
credentials: {
get: function() {
return this.introduce() + " and my ID is: " + this.id;
}
}
<!-- IE9 Pin elements -->
<meta name="application-name" content="EventArgs - A Web Development Blog">
<meta name="msapplication-tooltip" content="EventArgs">
<meta name="msapplication-starturl" content="http://eventargs.com/">
<meta name="msapplication-task" content="name=HTML;action-uri=http://eventargs.com/category/html;icon-uri=http://eventargs.com/cloud.ico">
<meta name="msapplication-task" content="name=.NET;action-uri=http://eventargs.com/category/net;icon-uri=http://eventargs.com/book.ico">
<meta name="msapplication-task" content="name=JavaScript;action-uri=http://eventargs.com/category/javascript;icon-uri=http://eventargs.com/favicon.ico">
@fiveisprime
fiveisprime / view.html
Created June 17, 2012 01:33
Knockout example
<div data-bind="with: people">
Important people:
<label>First Name</label>
<input type="text" data-bind="value: first" />
<label>Last Name</label></div>
<input type="text" data-bind="value: last" />
<button data-bind="click: addPerson">Add Person</button>
<button data-bind="click: remove">Remove Person</button>
@fiveisprime
fiveisprime / button.xaml
Created June 17, 2012 01:37
Routed Events With Visual States in Silverlight 4
<button Style="{StaticResource ButtonStyle}"
Height="126"
Width="137"
Name="button"/>
@fiveisprime
fiveisprime / gist:2943110
Created June 17, 2012 01:42
MouseDragElement behavior with code behind
Canvas designArea = (Canvas)sender;
// Create the rectangle and give it a border and fill.
// Note that a rectangle with no fill requires users to drag from the border only.
Rectangle rectangle = new Rectangle();
rectangle.Height = 120;
rectangle.Width = 90;
rectangle.StrokeThickness = 1;
rectangle.Stroke = new SolidColorBrush(Colors.Black);
rectangle.Fill = new SolidColorBrush(Colors.White);
@fiveisprime
fiveisprime / behavior.xaml
Created June 17, 2012 01:46
MouseDragElementBehavior
<i:Interaction.Behaviors>
<ei:MouseDragElementBehavior/>
<i:Interaction.Behaviors>
@fiveisprime
fiveisprime / Circle.dart
Created July 21, 2012 01:22
Dart Shapes
/**
* Represents a drawable circle for use with a canvas element.
*/
class Circle extends Shape {
num size;
/**
* Initializes a new Circle instance.
*/
Circle(context, positionX, positionY, size, speedX, speedY, color) {
var unwatch = function(obj, prop) {
var value = obj[prop];
// Delete the property that has the get/set functions specified
// then add the property back using the original value.
delete obj[prop];
obj[prop] = value;
return this;
};
@fiveisprime
fiveisprime / gist:4180358
Created December 1, 2012 03:02
lookout.js example
var myObject = { id: 100, name: 'my object' };
// Subscribe to changes to all properties of the myObject object.
// The callback accepts the property name along with the previous and current value
// of the property.
lookout(myObject, function(prop, oldValue, newValue) {
// Log the name of the property that changed and it's previous/current value.
console.log(prop + ' just changed from [' + oldValue + '] to [' + newValue + ']');
});