Skip to content

Instantly share code, notes, and snippets.

View dcgithub's full-sized avatar
💭
for those about to rock!..

dcgithub

💭
for those about to rock!..
  • None
  • Brisbane
View GitHub Profile
// this example script uses a user-submitted script to modify image
// data from a canvas in which the user drew art
var sandbox = new JSandbox(),
userArt = document.getElementById("userArt").getContext("2d"),
imageData = userArt.getImageData(0, 0, userArt.width, userArt.height);
sandbox.load("user-submitted-script.js", function () { // onload
this.eval("doStuffWithImageData(input)", function (modifiedImageData) {
userArt.putImageData(modifiedImageData, 0, 0);
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Over and Out test page</title>
<link rel="stylesheet" type="text/css" media="all" href="shCore.css" />
<link rel="stylesheet" type="text/css" media="all" href="shThemeFadeToGrey.css" />
<style>
.deco {
padding: 5px;
<!--
My "generic" HTML structure (used in benalman.com and others)
An array of main sections:
page = [ { header: [] }, { content:[] }, ... ];
Bodies are pushed onto each of those, which are all iterated over
to form this structure:
<h1>Demo code for "Extreme JavaScript Performance" @ JSConf.eu</h1>
<script>
var benchmark = function(m,i){
var d1 = new Date, d2, r;
while(i--) r = m();
d2 = new Date;
console.log(d2.getTime()-d1.getTime());
// if(r) console.log(r);
}
Public Function GetSwapNumber(ByVal session As ISession, ByVal instrument As Instrument) As String
Dim swapNumber As String = String.Empty
Dim crit As DetachedCriteria = DeCrit.UniqueSwapAssignmentByInstrumentId(instrument)
Dim swapAssignments As IList(Of SwapAssignment)
Dim newSession As ISession = session.GetSession(EntityMode.Poco)
swapAssignments = crit.GetExecutableCriteria(newSession).List(Of SwapAssignment)()
For Each swap As SwapAssignment In swapAssignments
If (swap.Swap IsNot Nothing) Then
@jbevain
jbevain / Image.cs
Created December 8, 2009 16:38
A class to test whether a file is a PE file and a managed assembly
//
// Image.cs
//
// Author:
// Jb Evain ([email protected])
//
// WARNING: code now lives in http://github.com/jbevain/mono.reflection
//
// (C) 2009 Novell, Inc. (http://www.novell.com)
//
@paulirish
paulirish / README.md
Created January 4, 2010 02:38
imagesLoaded() jquery plugin
-# Don't display new assets on form redisplay
- unless (form.object.new_record? && form.object.data.dirty?)
%li
= form.object.name if form.object.data?
= form.file_field :data if form.object.new_record?
= form.text_field :title
= remove_link(form, t('assets.actions.remove')).html_safe!
@nanto
nanto / convertToHTMLString.js
Created February 5, 2010 00:09
covertToHTMLString
// Original code by Constellation
// http://d.hatena.ne.jp/Constellation/20100203/1265207970
function convertToHTMLString(source, safe) {
if (!source || (source.getRangeAt && source.isCollapsed)) return '';
var range = source.getRangeAt ? source.getRangeAt(0) : null;
var node = range ? range.cloneContents() : source.cloneNode(true);
if (safe) {
var root = range && range.commonAncestorContainer.cloneNode(false)
if (!root || root.nodeType !== root.ELEMENT_NODE)
@defunkt
defunkt / gist:308086
Created February 18, 2010 21:24
Case insensitive jQuery :Contains filter
// Case insensitive jQuery :Contains filter
jQuery.expr[':'].Contains = function(a,i,m) {
return (a.textContent || a.innerText || "").toLowerCase()
.indexOf(m[3].toLowerCase()) >=0 ;
}