Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
ryanflorence / static_server.js
Last active July 21, 2024 12:43
Node.JS static file web server. Put it in your path to fire up servers in any directory, takes an optional port argument.
var http = require("http"),
url = require("url"),
path = require("path"),
fs = require("fs")
port = process.argv[2] || 8888;
http.createServer(function(request, response) {
var uri = url.parse(request.url).pathname
, filename = path.join(process.cwd(), uri);
@140bytes
140bytes / LICENSE.txt
Created May 9, 2011 16:13
140byt.es -- Click ↑↑ fork ↑↑ to play!
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@leegao
leegao / Rationale.md
Created July 9, 2011 02:30
JIT for dummies: JIT compiling RPN in python

If you don't care about the explanation, scroll down to find the code, it's 50 some odd lines and written by someone who doesn't know any better. You have been warned.

What it does

This is a very simple proof of concept jitting RPN calculator implemented in python. Basically, it takes the source code, tokenizes it via whitespace, and asks itself one simple question: am I looking at a number or not?

First, let's talk about the underlying program flow. Pretend that you are a shoe connoisseur with a tiny desk. You may only have two individual shoes on that desk at any one time, but should you ever purchase a new one or get harassed by an unruly shoe salesman without realizing that you have the power to say no (or even maybe?), you can always sweep aside one of the two shoes on the desk (the one on the right, because you're a lefty and you feel that the left side is always superior) onto the messy floor, put the other shoe on the right hand side, and then place your newly acquired shoe in

@scottbw
scottbw / jquery.oauth.js
Created November 6, 2011 00:23 — forked from andyedinborough/jquery.oauth.js
Introduces $.oauth() to make using OAuth from jQuery as easy as using $.ajax()
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
@wilsonpage
wilsonpage / reqUrl.js
Created November 25, 2011 14:38
A function I made that wraps the node http.request function to make it a little more friendly. In my case I am using it for API route testing.
// module dependencies
var http = require('http'),
url = require('url');
/**
* UrlReq - Wraps the http.request function making it nice for unit testing APIs.
*
* @param {string} reqUrl The required url in any form
* @param {object} options An options object (this is optional)
@jfmercer
jfmercer / prime_numbers.js
Created December 6, 2011 03:55
Simple Prime Number Test in node.js and express
//
// Created by John F. Mercer on Monday, December 5, 2011
// john.f.mercer@gmail.com
//
// tested on node 0.6.4 and express 2.5.1
//
var express = require('express'),
app = express.createServer();
app.use(express.logger());
@ramsesoriginal
ramsesoriginal / index.php
Created March 9, 2012 10:59
PJAX-PHP: Untested Code, just as a sample how one coudl theoretically implement PJAX with PHP
<?php
$render_template=true;
if ($_SERVER["HTTP_X_PJAX"])
{
$render_template=false;
}
?>
<?php
if ($render_template) {
@ir-g
ir-g / index.php
Created June 10, 2012 16:44
Lite_CMS Paging system.
<html>
<head>
<title>Pages</title>
<script type="text/javascript">
WebFontConfig = {
google: { families: [ 'Ubuntu:300:latin' ] }
};
(function() {
var wf = document.createElement('script');
wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
@ir-g
ir-g / index.php
Created October 28, 2012 11:03
Oink CMS-A basic web framework.
<?php include("latest-stable-handler.php"); launch_site(); ?>
@ir-g
ir-g / app.xml
Created November 24, 2012 19:26
An example app page.
<app>
<meta>
<app:title>Title</app:title>
<app:icon type="47px-47px">icon-47-47.png</app:icon>
</meta>
<page name="home">
<h1>Home</h1>
<a href="page:example">Want another page?</a>
</page>
<page name="example">