Skip to content

Instantly share code, notes, and snippets.

View mteece's full-sized avatar

Matthew Teece mteece

View GitHub Profile
@mteece
mteece / RecordResposeObject.cs
Created November 2, 2011 20:07
C# wrapper for generic objects response. Useful for objects in WCF with Ajax and JSON.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
/*
using My.Domain.Namespace;
@mteece
mteece / ListResponseObject.cs
Created November 15, 2011 20:05
C# wrapper for responses, returning a list of objects in WCF. Useful for Ajax and JSON, uses generics.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
/*
using My.Domain.Namespace;
(function(){
// FizzBuzz
for(var i=1; i<=100; i++) {
var fizz = (i % 3 == 0 ? "fizz" : "") + (i % 5 == 0 ? "buzz" : "");
console.log(fizz == "" ? i : fizz);
}
})();
@mteece
mteece / App.stub.MyObject.js
Created December 21, 2011 16:32
Object oriented Javascript with ExtJS.
// Object oriented Javascript with ExtJS
Ext.namespace('App.stub');
App.stub.MyObject = Ext.extend(Object, {
prop1: 'some string',
prop2: 100,
prop3: {
month: 10,
@mteece
mteece / ArrayOfObjectsIterator.js
Created January 26, 2012 15:59
Quickly iterate an array with objects.
(function(){
var data = {
"GetResult":[
{
"ID":1,
"width":150,
"height":50
},
{
@mteece
mteece / ExtHorizontalFormLayout.js
Created January 26, 2012 17:56
Ext JS 4.0.7 form layout using Ext.form.Panel with Ext.form.FieldSet, help button tool, and toolbar interface.
Ext.create('Ext.form.Panel', {
title: 'Simple Form with FieldSets',
labelWidth: 75, // label settings here cascade unless overridden
url: '/user/save',
frame: true,
bodyStyle: 'padding: 5px 5px 0',
width: 550,
renderTo: Ext.getBody(),
layout: 'column', // arrange fieldsets side by side
defaults: {
@mteece
mteece / Search.js
Created March 15, 2012 16:50
Ext Controller Button click event firing twice.
/* Ext Controller Button click event firing twice.
*
* In our custom routing we lookup the controller by name and fire the init() method.
* We found in doing so when we had components with event listeners firing twice.
* To get around all the duplicate events, rather than say clearing all the event
* listeners in init(), we moved the this.control() into the onLaunch() event.
* As init() is called when your application boots up, and the onLaunch() is
* kind of like init(), but called after the viewport is created.
*/
@mteece
mteece / PieChartSeriesCLickEvent.js
Created April 4, 2012 14:16
Ext JS 4.0.7 Pie Chart with series event listeners.
/*
* Ext JS 4.0.7 Pie Chart with series event listeners.
* Place the listener inside the series and not the chart as you want the event on each series (slice specific data).
* Now, the item variable holds all of information and data. For each series, the property to get data will differ.
* So, you will have to inspect the item object using Firebug or Chrome developer tools. The events are;
* itemmouseup, itemmousedown, itemmousemove, and afterrender.
*/
var store = Ext.create('Ext.data.JsonStore', {
fields: ['name', 'data1', 'data2', 'data3', 'data4', 'data5'],
@mteece
mteece / BasicGridPanel.js
Created April 11, 2012 15:12
Basic store and grid panel with a text filter.
Ext.create('Ext.data.Store', {
storeId:'simpsonsStore',
fields:['username', 'name', 'email', 'phone'],
data:{'items':[
{ 'username': 'lsimpson', 'name': 'Lisa', 'email':'lisa@simpsons.com', 'phone':'555-111-1224' },
{ 'username': 'bsimpson', 'name': 'Bart', 'email':'bart@simpsons.com', 'phone':'555-222-1234' },
{ 'username': 'hsimpson', 'name': 'Homer', 'email':'home@simpsons.com', 'phone':'555-222-1244' },
{ 'username': 'msimpson', 'name': 'Marge', 'email':'marge@simpsons.com', 'phone':'555-222-1254' }
]},
proxy: {
@mteece
mteece / backspace.js
Created July 16, 2012 14:40
Prevent BACKSPACE (requires jQuery).
// Prevent BACKSPACE
$(document).keydown(function(e) {
if (e.target.type !== 'textarea') {
var code = e.keyCode || e.which;
if (code === 8) { //BACKSPACE keycode
//e.cancelBubble is supported by IE - this will kill the bubbling process.
e.cancelBubble = true;
e.returnValue = false;