Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:lang="http://www.springframework.org/schema/lang"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.0.xsd">
<bean id="myPrototypeBean" scope="prototype" class="net.ceilingfish.Session">
<property name="register">
<!-- This class is a prototype, i.e. a new one will be requested every time you read this from the ApplicationContext -->
class Mash < Hash
def method_missing(method_name, *args, &block)
self[method_name]
end
end
module Configuration
def self.attributes
# subsect an array into a fixed length subsections
# Eg. [1,2,3,4,5].chunk(2) => [[1,2],[3,4],[5]]
class Array
def chunk(size=2)
pieces = (self.length / size)
chunks = []
0.upto(pieces) do |i|
start = i * size
finish = start + size
chunks << self[start..finish] || []
@ceilingfish
ceilingfish / LoggingTest.cs
Created May 23, 2011 08:03
A basic unit test to compare trace, trace with autoflush off, and appending to a queue
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System.Diagnostics;
using System.Collections.Concurrent;
namespace DotNetTesting
{
@ceilingfish
ceilingfish / gist:1127577
Created August 5, 2011 13:54
AsyncSocketServer
public void Start()
{
Thread listenerThread = new Thread(ListenForConnections);
listenerThread.IsBackground = true;
listenerThread.Start();
}
private void ListenForConnections()
{
TcpListener listener = new TcpListener(IPAddress.Any, ServerPort);
try
{
throw new Exception("an error");
}
catch
{
//do something with e
throw;
}
finally
{
fieldLabel: 'The Field label',
xtype: 'box',
autoEl: {
tag: 'a'
href: 'test.php',
html: 'This is a link that can be placed inside a form.',
target: '_blank'
}
}
@ceilingfish
ceilingfish / RewindEventHub.linq
Created December 4, 2019 08:28
Rewinding azure event hub offsets
async Task Main()
{
var connectionString = "Endpoint=sb://my-namespace.servicebus.windows.net/;SharedAccessKeyName=ReadEvents;SharedAccessKey=MySecretKey;EntityPath=hub";
Console.WriteLine("Rewinding event hub...");
var eventProcessorHost = new EventProcessorHost(
"reporting",
PartitionReceiver.DefaultConsumerGroupName,
connectionString,
"UseDevelopmentStorage=true",
@ceilingfish
ceilingfish / Martian Rovers.linq
Created April 1, 2020 15:36
Tom's answer to april 1st dev hour
<Query Kind="Program" />
void Main()
{
var input = @"5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM";
<div class="ee_dropzone"><table cellpadding="0" cellspacing="0" width="100%" class="ee_customedit ee_couponcode ee_element" ee-type="container" data-title="Coupon code"><tbody><tr><td valign="top" class="ee_couponcodecontent element-pad element-bord col-font-reset root-element-pad"></td></tr></tbody></table>