Skip to content

Instantly share code, notes, and snippets.

Einar Otto Stangvik einaros

Block or report user

Report or block einaros

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:2956187

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 / gist:1452218
Created Dec 9, 2011
ws server example
View gist:1452218
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);
View gist:1452010
$ npm install -g ws
$ wscat -c ws:// -p 8
connected (press CTRL+C to quit)
> hi there
< hi there
> are you a happy parrot?
< are you a happy parrot?
View gist:1431539
var WebSocket = require('ws')
, ws = new WebSocket('ws://');
ws.on('open', function() {
ws.on('message', function(message) {
console.log('received: %s', message);
View gist:1269763
var circleCenterPt = new paper.Point(150, 300);
var circleRadius = 75;
var sineWaveLength = 300;
var cosineWaveLength = 300;
var sineWaveStep = sineWaveLength/360;
var cosineWaveStep = cosineWaveLength/360;
var angle = 0;
View gist:733263
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="">
<ListInstance Title="Portfolios"
Description="List containing the available project portfolios">
View gist:672570
// 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 =
View gist:653358
class Program
static void Main(string[] args)
Console.Out.WriteLine("Baking cookies");
Console.Out.WriteLine("Cookies baked");
View gist:653306
string xml = @"
<root xmlns='' xmlns:h='' xmlns:f=''>
<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>
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; });
View gist:640422
var mock = new Mock<MemoryStream>();
.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);
You can’t perform that action at this time.