This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("a.ajax").live('click',function(e) { | |
e.preventDefault(); | |
var $this = $(this); | |
url = $(this).attr('href'); | |
$.get(url,function(data) { | |
if(data) { | |
if( $this.hasClass('addHtmlToParent') ) { | |
$this.parent().append(data); // append return content to parent | |
} else { | |
eval(data); // execute return js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
function highlightDates(date) { | |
for ( var i = 0; i < agenda.length; i++) { | |
var start = agenda[i].substring(0,4) + '-' + num_pad(parseInt(agenda[i].substring(5,7)-1),2,'0') + '-' + agenda[i].substr(8,2); | |
//var start = agenda[i].date; | |
var dateString = date.getFullYear() + '-' + num_pad(date.getMonth(),2,'0') + '-' + num_pad(date.getDate(),2,'0'); | |
if (start == dateString) { | |
return [ true, 'ui-state-active' ]; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$list = array('this','that','theother','andthis'); | |
$evenList = (count($list)%2==0) ? true : false; | |
$listOne = array(); | |
$listTwo = array(); | |
if( $evenList ) { | |
$half = count($list)/2; | |
$listOne = array_slice($list,0,$half); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// initial input addition | |
$(".forum_thumbnail_addThumbnail").live('click',function() { | |
var $this = $(this); | |
$.get('/forum/ajaxGetThumbnailInput',function(data,status) { | |
if( status == 'success' ) { | |
$(data).appendTo($this.parent().parent()); | |
$this.parent().hide(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_attribute(self,attribute_name): | |
try: | |
return self.data[attribute_name] | |
except (KeyError,TypeError): | |
print self.data.__class__ | |
exit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pprint | |
import psycopg2 | |
import psycopg2.extras | |
from psycopg2.extras import DictConnection | |
class pgImport(object): | |
"""Imports data to pg instance""" | |
def __init__(self,dbname='template1',user='postgres',password='postgres',host='localhost'): | |
"""Constructor""" | |
self.db = psycopg2.connect('dbname=%s user=%s host=%s password=%s' % (dbname,user,host,password)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public Dictionary<string,Object> getChildrenRecursive() | |
{ | |
Dictionary<string,Object> categoryDictionary = new Dictionary<string, Object>(); | |
Dictionary<string, Object>[] children; | |
if (this.hasChildren()) | |
{ | |
// Get child nodes | |
Duke.CategoryDataTable ChildTable = this.CategoryAdapter.GetAllByParentCategory(categoryCode); | |
children = new Dictionary<string, Object>[ChildTable.Rows.Count]; | |
for (int i = 0; i < ChildTable.Rows.Count; i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% | |
Action<System.Data.DataTable, int> printCategoriesRecursively = null; | |
printCategoriesRecursively = (System.Data.DataTable categoryRows, int depth) => { | |
if (categoryRows==null || categoryRows.Rows.Count==0) return; | |
%> | |
<ul class="node-list depth-<%=depth%>"> | |
<% | |
foreach (System.Data.DataRow CategoryRow in categoryRows.Rows) { | |
%> | |
<li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.fn.serializeToObject = function() { | |
var serial_array = this.serializeArray(); | |
var serial_object = {}; | |
$(serial_array).each(function() { | |
if( !serial_object[this.name] ) | |
{ | |
serial_object[this.name] = this.value; | |
} | |
}); | |
return serial_object; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// load an image - with a callback on load | |
function loadImageDynamic(image_url,callback,container) { | |
if( container != 'undefined' ) { | |
container = 'body'; | |
} | |
var image_load = 0; | |
$('<img/>') | |
.attr('src',image_url) | |
.load( function(e) { | |
if( image_load < 1 ) { // webkit hack to protect from multiple loads on cached images |
OlderNewer