Skip to content

Instantly share code, notes, and snippets.

@casparkleijne
casparkleijne / revmodpat.js
Created May 27, 2010 10:02
rev.mod.pat sample for jquery implementation
/* ------------------------------------------------------------------------------------
author information:
caspar kleijne
cekleijne@gmail.com
http://twitter.com/caspar_kleijne
desc; use the jQuery in a pattern, Good for readability.
------------------------------------------------------------------------------------- */
"use strict";
/* declare the "namespace" */
/*global
$,
window,
document
*/
/** toggles between classes Normal & Hover on any element that has one of those classes
it is a replacement for the :hover pseudo-class (so quite useless nowadays ;) **/
$(".Normal, .Hover").bind("mouseenter mouseleave", function ()
$(this).toggleClass("Hover Normal");
});
@casparkleijne
casparkleijne / 960.TT
Created June 6, 2010 07:53
Variable Grid System Generated Stylesheet
<#@ template language="C#" #>
<#@ output extension=".css" #>
/*
Variable Grid System Generated Stylesheet
v.0.1 alpha
Author: Caspar Kleijne
Contact: twitter.com/caspar_kleijne
Converted for TT from 960 Grid System - http://960.gs/
Via ~ http://www.spry-soft.com/grids/
/** som reregexes */
var simple_dutch_postcode: ^[1-9][0-9]{3}\s?[a-zA-Z]|[S]{2}$
...........................//
geschattebesparing : function () {
var p, l, j, v, t, result;
/* using single char vars to keep the calculation short */
p = config.jaarlijkseprijsstijgingelektriciteit;
l = config.levensduurpanelen;
j = helpers.jaarlijkseopbrengst();
v = helpers.vermogenpanelen();
t = config.prijsperkWh;
result = ((Math.pow((1 + p), l) - 1) / p) * (t * j);
/** call it like **/
protected void Page_Load(object sender, EventArgs e)
{
Uri uri = new Uri("http://gmcdn.goldmail.com/robin/gmtiming.xml");
Presentation presentation = Rdn.Bll.PresentationController.LoadFromXML(uri);
}
using System;
using Rdn.Bll.Bo;
// string xml = "<presentation />"; //<----- string that is your xml
public T Deserialize(string xml)
{
T obj = default(T);
using (TextReader textreader = new StringReader(xml))
{
using (XmlReader reader = XmlReader.Create(textreader))
{
XmlSerializer serialzier = new XmlSerializer(typeof(T));
obj = (T)serialzier.Deserialize(reader);
Response.Clear();
Response.ContentType = "image/jpeg";
string raw = File.ReadAllText("e:\\cybersecuritychallenge.txt");
byte[] imageBytes = Convert.FromBase64String(raw);
Response.BinaryWrite(imageBytes);
Response.End();
class Program
{
private static Random r = new Random(DateTime.Now.Millisecond);
// names of the "moves"
private static string[] rps = { "PAPER", "ROCK", "SCISSORS"};
// result feedback string to be formatted
private static string[] feedback = { "{1} Beats {0}, You Loose!","{0} Equals {1}, Draw!", "{0} Beats {1}, You Win!" };
// solution matrix ( 0 = loose ; 1 = draw ; 2 = win // array1: for paper; array2: for rock; array3: for scissors; )
private static int[,] solution = {{1, 2, 0},{0, 1, 2},{2, 0, 1}};