This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var util = require('sys') // update this at some point | |
, ns = require('node-static') | |
, http = require('http') | |
, fileServer = new ns.Server('./public'); | |
http.createServer(function (request, response) { | |
request.addListener('end', function () { | |
fileServer.serve(request, response, function (err, result) { | |
if (err) { // An error as occurred |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/course/cs053/bin/python3 | |
import os, time | |
import sys | |
""" | |
reruns the given file whenever it changes. | |
usage: python3 run.py myfile.py | |
""" | |
def stat(f): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/course/cs053/bin/python3 | |
import os, time | |
import sys | |
""" | |
reruns the given file whenever it changes. | |
usage: python3 run.py myfile.py | |
""" | |
def stat(f): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>ERR</title> | |
<script type="text/javascript" src="jquery-1.4.2.min.js"></script> | |
<script type="text/javascript" src="pixastic/pixastic.core.js"></script> | |
<script type="text/javascript" src="pixastic/actions/colorhistogram.js"></script> | |
<style type="text/css" media="screen"> | |
#testImage {width:auto;height:auto;} | |
</style> | |
</head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var text = '<!DOCTYPE HTML><html lang="en"><head><title>Woo</title></head><body></body></html>'; | |
var jsdom = require('jsdom').jsdom; | |
var window = jsdom(text).createWindow(); | |
// here's the doctype | |
console.log(window.document.doctype+''); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var rawHtml = '<!DOCTYPE HTML><html lang="en"><head><title>LEtss goo</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><meta http-equiv="Content-Language" content="en-us"><link rel="icon" type="image/png" href="/favicon.png"><link rel="stylesheet" type="text/css" href="css/style.css"><link rel="stylesheet" type="text/css" href="css/jquery.gritter.css"><link rel="stylesheet" type="text/css" href="css/jScrollPane.css"><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script><script type="text/javascript" src="js/lib/jquery.mousewheel.js"></script><script type="text/javascript" src="js/lib/jquery.em.js"></script><script type="text/javascript" src="js/lib/jScrollPane.js"></script><script type="text/javascript" src="js/lib/jquery.autolink.js"></script><script type="text/javascript" src="js/lib/jquery-css-transform.js"></script><script type="text/javascript" src="js/lib/jquery-animate-css-rotate-scale.js"></script><script type="text/javasc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Bitops { | |
// Takes a character and returns the number of ones | |
// contained in its binary representation | |
static int numOnes(char c) { | |
int hex = (int) c; | |
int sum = 0; | |
// we want unsigned comparison | |
// this works fine if java uses 2s complement (it does I think). | |
while (hex > 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require('sys') | |
, url = require('url') | |
, http = require('http') | |
, eyes = require('eyes') | |
, querystring = require('querystring') | |
, io = require(__dirname + '/lib/socket.io-node') | |
, PORT = 80 // MAKE SURE THIS IS SAME AS SOCKET.IO | |
, static = require('node-static') | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var static = require('node-static'); | |
// | |
// Create a node-static server instance to serve the './public' folder | |
// | |
var file = new(static.Server)('./public'); | |
require('http').createServer(function (request, response) { | |
request.addListener('end', function () { | |
// |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Used to run code in a directory and rerun it if any files are changed. | |
// usage: node run.js servercode.js | |
// servercode.js is whatever js file you want to run with node. | |
// Excludes filetypes in the ignoreExtensions array | |
var sys = require('sys'), | |
fs = require('fs'), | |
spawn = require('child_process').spawn, | |
child, // child process which runs the actual code | |
ignoreExtensions = ['.dirtydb', '.db']; // Change this to your liking |