Skip to content

Instantly share code, notes, and snippets.

Avatar

Emelia Smith ThisIsMissEm

View GitHub Profile
View buildHTML utility.js
// my little html string builder
buildHTML = function(tag, html, attrs) {
// you can skip html param
var h = document.createElement(tag);
var attrs = attrs || {};
if (arguments.length == 2 && !((html) instanceof HTMLElement) && typeof(html) == "object") {
attrs = html;
html = null;
}
@ThisIsMissEm
ThisIsMissEm / naf.js
Created July 2, 2012 19:07 — forked from getify/naf.js
requestNextAnimationFrame() and cancelNextAnimationFrame()
View naf.js
// requires raf.js (polyfil)
(function(){
var ids = {};
function requestId(){
var id;
while (!id || ids.hasOwnProperty(id)){
id = Math.floor(Math.random() * 1E9);
};
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://fb.me/react-0.14.3.js"></script>
<script src="http://fb.me/react-dom-0.14.3.js"></script>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style id="jsbin-css">
.item, .item-selected {
@ThisIsMissEm
ThisIsMissEm / requireDir.js
Created July 4, 2012 14:42 — forked from TheDeveloper/requireDir.js
Node.js require directory
View requireDir.js
var fs = require('fs');
var Path = require('path');
function requireDir(dir){
var modules = {};
fs.readdirSync(dir).map(function(name){
return Path.join(dir, name);
}).filter(function(path){
return fs.statSync(path).isFile();
@ThisIsMissEm
ThisIsMissEm / domTrees.js
Created April 28, 2011 09:01 — forked from jed/bookmarklet.js
dom tree caching performance: array v. linked list
View domTrees.js
function Node1(node) {
this.node = node;
var children = node.childNodes,
i = this.length = children.length;
while (i--) this[i] = new Node1(children[i]);
}
Node1.prototype.count = function() {
@ThisIsMissEm
ThisIsMissEm / slow.js
Created January 27, 2011 03:52 — forked from ry/slow.js
View slow.js
var fs = require('fs');
fs.unlinkSync('/tmp/__blah');
var s = fs.WriteStream("/tmp/__blah");
for (var i = 0; i < 1024 * 1024; i++) {
s.write("a");
}
View stream.js
this.Server.prototype.stream = function (pathname, files, buffer, res, callback) {
(function streamFile(files, offset) {
var file = files.shift();
if (file) {
// Stream the file to the client
fs.createReadStream(path.join(pathname || '.', file), {
flags: 'r',
encoding: 'binary',
View gist:650822

[Placeholder]

We’re very happy to announce today the Async CTP for Visual Basic and C#.

Async CTP homepage: http://msdn.com/vstudio/async
Installer: http://go.microsoft.com/fwlink/?LinkId=203690
Async discussion forums: http://social.msdn.microsoft.com/Forums/en-US/async/threads
Asynchronous programming is something that helps make your UI more responsive, especially in applications that interact with databases or network or disk. It’s also used to make ASP servers scale better.

Until now, asynchronous programming has also been prohibitively hard, “not worth the investment”-hard. But with the Async CTP we’ve made asynchronous programming easy enough that developers should routinely consider asynchrony for most of their applications.

View gist:604007
// HOWTO: load LABjs itself dynamically!
// inline this code in your page to load LABjs itself dynamically, if you're so inclined.
(function (global, oDOC, handler) {
var head = document.getElementsByTagName("head")
, sOnLoad = "onload"
, sReadyState = "readyState"
, sDomContentLoaded = "DOMContentLoaded"
, sLoaded = "loaded"
, sComplete = "complete"
View gist:525784
var sys = require("sys")
, fs = require("fs")
, path = require("path")
, http = require("http")
, ws = require('../lib/ws');
var server = http.createServer(function(req, res){
if( req.url.indexOf("favicon") > -1 ){
sys.log("HTTP: "+req.socket.remotePort+", inbound request, served nothing, (favicon)");