Skip to content

Instantly share code, notes, and snippets.

View BruceHubbard's full-sized avatar

Bruce Hubbard BruceHubbard

View GitHub Profile
@BruceHubbard
BruceHubbard / gist:768508
Created January 6, 2011 20:24
Prevent Double Click In Web Forms
public static void PreventDoubleClick(Page page, Button button, string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("if (typeof(Page_ClientValidate) == 'function') { ");
sb.Append("if (Page_ClientValidate() == false) { return false; }} ");
sb.Append("this.value = '" + message + "';");
sb.Append("this.disabled = true;");
sb.Append(page.ClientScript.GetPostBackEventReference(button, String.Empty));
sb.Append(";");
button.Attributes.Add("onclick", sb.ToString());
@BruceHubbard
BruceHubbard / RequireJS_Example.js
Created July 19, 2011 15:35
RequireJS Example
define(
// template dependency
[
'app/text!app/views/templates/myMustacheTemplate.html',
'Scripts/mustache/mustache',
'Scripts/jquery',
'Scripts/jquery-ui-1.8.13.min',
'app/services/myServiceFile'
],
@BruceHubbard
BruceHubbard / IEFilters.css
Created July 19, 2011 15:51
SASS IE Filter problem
/*
The filter property below is causing a parse error.
*/
.push-status.cancelled .progress {
filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#00E85734', EndColorStr='#00E85734');
}
/* When I ran it I got this (keep reading to see my solution */
/* An error occurred while compiling the Sass file. Details:
@BruceHubbard
BruceHubbard / Require_app.js
Created November 9, 2011 14:01
Require Kickstart
// load per-page functionality
var $dataPage = $('body').attr('data-page');
if ($dataPage) {
//note, there is no '.js' on the end of $dataPage
require(['app/pages/' + $dataPage]);
}
@BruceHubbard
BruceHubbard / Getting Dressed Take Home Problem
Created January 11, 2012 18:35
Getting Dressed Take Home Problem
//I took out the file input part and replaced it with an array. That would cut out the file I/O parts
//and cut down the time needed to complete it.
Create a C# program that solves the following dependency problem:
A person needs to figure out which order his/her clothes need to be put on. The person
creates a file that contains the dependencies.
This input is a declared array of dependencies with the [0] index being the dependency
and the [1] index being the item.
@BruceHubbard
BruceHubbard / triangle_problem.js
Created January 17, 2012 18:14
Dayton Clean Coders triangle problems specs and source
////Specs
describe('Triangle Classify',function(){
describe('Classify', function() {
it('On passing 3 different lengths returns scalene', function() {
expect(classify(3, 4, 5)).toBe(types.s);
});
it('On passing 2 equal lenghts returns isosceles', function() {
expect(classify(3,3,2)).toBe(types.i);
expect(classify(3,2,3)).toBe(types.i);
expect(classify(2,3,3)).toBe(types.i);
@BruceHubbard
BruceHubbard / 2012_Conferences.txt
Created April 23, 2012 15:59
2012 Conferences
2012 Conferences
Past:
1/11-13 CodeMash
1/24-25 Node Summit
3/9-17 SxSW
3/15-17 CodePalousa
4/2-3 JSConf (AZ)
4/23 Kalamazoo X
@BruceHubbard
BruceHubbard / listing_page.js
Created July 26, 2012 13:39
Listing Page Example
define(
['app/text!app/views/templates/item-list.html', 'app/views/listing-page'],
function(itemTpl, listingPageVw) {
var listing = listingPage.initialize($('.listing-page'), {
storeUrl: 'Item/All',
template: itemTpl,
usePaging: true
};
INPUT = "./input/1.txt"
TARGET = 250000
DAYS_LEFT = 7
PEOPLE = [
{:name => "I", :perDay => 1, :yield => 1.0},
{:name => "My son", :perDay => 2, :yield => 0.95},
{:name => "My brother", :perDay => 3, :yield => 0.85},
{:name => "My niece", :perDay => 4, :yield => 0.60}
]
LINES = File.open(INPUT, "r").read.strip.split("\n").collect{|s| s.to_i}
@BruceHubbard
BruceHubbard / nokogiri.rb
Created November 27, 2012 16:53
Nokogiri Examples
Nokogiri::HTML.parse(open(url)).css('.tn a').collect {|img| img["href"]}
#open(url) - opens and returns an html document
#css('selector') is just like jquery except server side. It returns a (ruby equivalent of a) linq-like enumerable
#collect is the same as .NET's select function
#So this one line when I set url to a Craigslist listing detail page will open that page and return an array of images for that listing.