Skip to content

Instantly share code, notes, and snippets.

@tkh44
tkh44 / netsuite.php
Created January 30, 2012 15:10
Working PHP connect to Netsuite.
<?php
extract($_POST);
$url = 'https://forms.netsuite.com/app/site/hosting/scriptlet.nl';
$fields = array(
'firstname' => urlencode($firstname),
'lastname' => urlencode($lastname),
'email' => urlencode($email),
@tkh44
tkh44 / resize.js
Created February 16, 2012 22:09
resize function
library = function() {
var elements = {};
var values = {
searchHeight: null,
logoHeight: null,
selected: 'selected',
category: 'category',
open: 'open',
catSelected: 'cat-selected',
var table = [
["Person", "Age", "City"],
["Sue", 22, "San Francisco"],
["Joe", 45, "Halifax"]
];
for(var row = 0; row < table.length; row++){
var rowText = "";
for(var column = 0; column < table[row].length; column++){
if(c != table[column].length-1){
/** Shortcuts**/
.center{
margin: 0 auto;
}
.shortcut{
min-width: 192px;
min-height: 192px;
max-width: 192px;
max-height: 192px;
text-align: center;
var subs = YAHOO.util.Dom.getElementsByClassName('sub', 'ul');
for(var i = 0; i < subs.length; i++){
var subListChildren = YAHOO.util.Dom.getChildren(subs[i]);
for(var k = 1; k < subListChildren.length + 1; k=k+2){
YAHOO.util.Dom.addClass(subListChildren[k], 'even');
}
}
@tkh44
tkh44 / handleKey.js
Created April 10, 2012 20:02
handle key
function keyHandle(keyCode){
var categories = elements.categories;
var shownPages = SELECT.query("ul.sub li:not(.hide)");
var selectedPage = DOM.getElementsByClassName('selected')[0];
var pageIndex = shownPages.indexOf(selectedPage);
if(keyCode === keys.down){
console.log(selectedPage);
//if no items are selected we highlight the first item
//if we are at the end of the list loop back around
if(pageIndex === -1 || pageIndex+1 >= shownPages.length) {//if no items are selected we highlight the first item
@tkh44
tkh44 / delgate.js
Created April 19, 2012 22:59
YUI delegate
EVENT.delegate(elements.list, 'click', doExpandCollapse, 'li.category .categoryHeader .actionIcon'); //expand/collapse category event
function doExpandCollapse(event, matchedEl, container) {
var parentCategory = matchedEl.parentNode.parentNode;
if (DOM.hasClass(parentCategory, 'open')) {
collapseCategory(parentCategory, true);
} else {
expandCategory(parentCategory, true);
}
}
@tkh44
tkh44 / diff.xml
Created May 2, 2012 19:44
diff colors for themes
<dict>
<key>name</key>
<string>diff.header</string>
<key>scope</key>
<string>meta.diff.header</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#ffffff</string>
<key>background</key>
@tkh44
tkh44 / what?.tmpl
Created May 17, 2012 21:15
TT for array of array of hashes
[% FOREACH showcased_features IN data.feature_collection -%]
[% FOREACH feature IN showcased_features -%]
<p>[% feature.name -%]</p>
<p>[% feature.recommended -%]</p>
<p>[% feature.helpurl -%]</p>
[% END -%]
[% END -%]
@tkh44
tkh44 / scroll.js
Created June 6, 2012 18:47
absolute - fixed scroller
$(document).ready(function() {
var nav = $('.compare_nav.fix_right');
nav.css({'position': 'absolute', 'right': '0px', 'top': '115px'});
$(window).scroll(function(e){
if($(this).scrollTop() > 200 && nav.css('position') != 'fixed') {
var wrapperLocation = $('#wrapper').offset()['left'];
var rightLocation = $('#wrapper').outerWidth() + wrapperLocation;
nav.css({'position': 'fixed', 'top': '115px', 'left': rightLocation - 200 + 'px'});
}