Skip to content

Instantly share code, notes, and snippets.

Text payload

Roundtrips of 64 B text payloads: node-0.7.12 6% faster
Roundtrips of 16 kB text payloads: node-0.7.12 26% faster
Roundtrips of 128 kB text payloads: node-0.7.12 34% faster
Roundtrips of 1 MB text payloads: node-0.7.12 35% faster

Binary payload

Roundtrips of 64 B binary payloads: node-0.7.12 4% faster

@einaros
einaros / gist:1452218
Created December 9, 2011 16:24
ws server example
var WebSocketServer = require('ws').Server
, wss = new WebSocketServer({port: 8080});
wss.on('connection', function(ws) {
ws.on('message', function(message) {
console.log('received: %s', message);
});
ws.send('something');
});
@einaros
einaros / gist:1452010
Created December 9, 2011 15:35
wscat example
$ npm install -g ws
$ wscat -c ws://echo.websocket.org -p 8
connected (press CTRL+C to quit)
> hi there
< hi there
> are you a happy parrot?
< are you a happy parrot?
var WebSocket = require('ws')
, ws = new WebSocket('ws://www.host.com/path');
ws.on('open', function() {
ws.send('something');
});
ws.on('message', function(message) {
console.log('received: %s', message);
});
var circleCenterPt = new paper.Point(150, 300);
var circleRadius = 75;
var sineWaveLength = 300;
var cosineWaveLength = 300;
paper.setup($('canvas')[0]);
var sineWaveStep = sineWaveLength/360;
var cosineWaveStep = cosineWaveLength/360;
var angle = 0;
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance Title="Portfolios"
OnQuickLaunch="TRUE"
TemplateType="10001"
FeatureId="59abaf93-f315-4c64-a7e3-e6402e05191c"
Url="Lists/Portfolios"
Description="List containing the available project portfolios">
<Data>
<Rows>
// A user with the privileges / ability to ...
// - upload a file to a single document library
// - edit one shared page, to add a silverlight webpart
// - lure an administrator to visit said page
// .. can, using this Silverlight app, steal all (document library) files on
// the SharePoint server, and post them to some nasty location.
var q = new CamlQuery { ViewXml = "<View Scope='Recursive'/>" };
IEnumerable<List> lists =
ClientContext.Current.LoadQuery(
class Program
{
static void Main(string[] args)
{
Console.Out.WriteLine("Baking cookies");
BakeCookies();
Console.Out.WriteLine("Cookies baked");
Console.ReadLine();
}
string xml = @"
<root xmlns='http://www.w3.org/TR/html4/' xmlns:h='http://www.w3.org/TR/html4/' xmlns:f='http://www.w3schools.com/furniture'>
<h:table><h:tr><h:td>Apples</h:td><h:td>Bananas</h:td></h:tr></h:table><f:table><f:name>African Coffee Table</f:name>
<f:width>80</f:width><f:length>120</f:length></f:table></root>";
XElement x = XElement.Parse(xml);
(from node in x.DescendantsAndSelf()
where node is XElement
from attr in node.Attributes()
where attr.IsNamespaceDeclaration && attr.Name.LocalName == "xmlns"
select attr).All(attr => { attr.Remove(); return true; });
var mock = new Mock<MemoryStream>();
mock
.Setup(x => x.Read(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()))
.Callback((byte[] array, int offset, int length) => Console.Out.WriteLine(array == null));
mock.Object.Read(new byte[1], 1, 2);