Skip to content

Instantly share code, notes, and snippets.

@markdaws
markdaws / gist:1812229
Created February 13, 2012 00:41
Default connection pool behaviour
var http = require('http');
var concurrentServerRequests = 0;
var totalServerRequests = 0;
var PORT_BASE = 1337;
function createServer(host, port) {
http.createServer(function (req, res) {
++concurrentServerRequests;
++totalServerRequests;
function runTestCase2() {
createServer('127.0.0.1', 1337);
http.globalAgent.maxSockets = 10;
for(var i=0; i<100; ++i) {
http.request({
host: '127.0.0.1',
port: 1337,
method: 'GET'
function runTestCase3() {
createServer('127.0.0.1', PORT_BASE);
createServer('127.0.0.1', PORT_BASE + 1);
http.globalAgent.maxSockets = 10;
for(var i=0;i<100; ++i) {
http.request({
host: '127.0.0.1',
port: PORT_BASE,
@markdaws
markdaws / gist:1920065
Created February 27, 2012 00:21
File Upload Example
<html>
<head>
<title>
File Upload Example
</title>
</head>
<body>
<form>
<input type="file" name="userPhoto" />
<html>
<head>
<title>Upload Example</title>
</head>
<body>
<form id="uploadForm"
enctype="multipart/form-data"
action="/api/photos"
method="post">
$(document).ready(function() {
status('Choose a file :)');
// Check to see when a user has selected a file
var timerId;
timerId = setInterval(function() {
if($('#userPhotoInput').val() !== '') {
clearInterval(timerId);
app.post('/api/photos', function(req, res) {
var serverPath = '/images/' + req.files.userPhoto.name;
require('fs').rename(
req.files.userPhoto.path,
'/Users/mark/code/examples/file-upload/upload-example-app/public' + serverPath,
function(error) {
if(error) {
res.send({
s$(this).ajaxSubmit({
error: function(xhr) {
status('Error: ' + xhr.status);
},
success: function(response) {
if(response.error) {
status('Opps, something bad happened');
NSString *path = [[NSBundle mainBundle] pathForResource:@"Assets.scnassets/vangoghroom/vg" ofType:@"obj"];
NSURL *url = [NSURL fileURLWithPath:path];
MDLAsset *asset = [[MDLAsset alloc] initWithURL:url];
MDLObject *obj = [asset objectAtIndex:0];
SCNNode *n = [SCNNode nodeWithMDLObject:obj];
@markdaws
markdaws / CapturedImageSampler.swift
Created November 11, 2019 23:46 — forked from JoshuaSullivan/CapturedImageSampler.swift
The source code for an object that helps you sample RGB values from ARFrames.
//
// CapturedImageSampler.swift
// ARKitTest
//
// Created by Joshua Sullivan on 9/22/17.
// Copyright © 2017 Joshua Sullivan. All rights reserved.
//
import UIKit
import ARKit