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
// 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); |
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
<!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; |
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
<!-- | |
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: |
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
<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); | |
} |
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 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 |
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
// | |
// 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) | |
// |
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
-# 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! |
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
// 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) |
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
// Case insensitive jQuery :Contains filter | |
jQuery.expr[':'].Contains = function(a,i,m) { | |
return (a.textContent || a.innerText || "").toLowerCase() | |
.indexOf(m[3].toLowerCase()) >=0 ; | |
} |