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
// One way converter from E4X XML to JSON | |
// 1) turns <body><item>1</item><item>2</item></body> into | |
// body: {item: ["1", "2"]} so that lists are easier to work with | |
// 2) turns things like: <body a="a">whatever</body> into | |
// body: {_a: "a", _: "whatever"} | |
// however <body>whatever</body> becomes simply body: "whatever | |
// - attributes specified by ignored are ignored | |
function E4XtoJSON(xml, ignored) { | |
var r, children = xml.*, attributes = xml.@*, length = children.length(); | |
if(length == 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
export("Cache"); | |
function Cache() { | |
var self = this; | |
this.size = 0; | |
this.map = {}; | |
function wrap(f, name, period, that) { | |
return function () { | |
var t = new Date().getTime(); |
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
(function(){ | |
var url; | |
var links = document.getElementsByTagName("link"); | |
for(var i = 0, l = links.length; i < l; i ++) { | |
var link = links.item(i); | |
if(link.tagName.toLowerCase() == "link") { | |
if(link.getAttribute("type") == "application/rss+xml") { | |
location.href = "http://www.google.com/reader/preview/*/feed/" + | |
"http://fulltextrssfeed.com/" + | |
link.getAttribute("href").substr("http://".length); |
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
const GET = "GET", PUT = "PUT", POST = "POST", DELETE = "DELETE", HEAD = "HEAD"; | |
function generate(base, endpoints) { | |
function camelCase(string) { | |
return string.charAt(0).toUpperCase() + string.substring(1); | |
} | |
function isArgument(component) { | |
return component.indexOf("{") == 0 && | |
(component.indexOf("}") == component.length - 1); | |
} | |
var proxy = {}; |
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
#!/bin/bash | |
echo "status ok ok" | |
arr=$(df -i | grep xvda | tr "\t" "\n") | |
OLD_IFS="$IFS"; | |
IFS=" "; | |
vars=( $arr ); | |
IFS="$OLD_IFS" | |
echo "metric Inodes int" ${vars[1]} | |
echo "metric IUsed int" ${vars[2]} | |
echo "metric IFree int" ${vars[3]} |
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
// data | |
{ | |
text: { | |
index: { | |
title: "Home" | |
} | |
}, | |
posts: [] | |
} |
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
require('fibers'); | |
var http = require('http'); | |
exports.HttpClient = HttpClient; | |
// {method, url, headers, body} | |
// return value is {status:status, headers:{..}, body:[..]} | |
function HttpClient (settings) { | |
if (!(this instanceof HttpClient)) return new HttpClient(settings); | |
this.guts = {}; |
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
/** | |
* @fileoverview Script to package up an existing RingoJS application as a WAR. | |
*/ | |
//require('core/string'); | |
var {join, Path, makeDirectory, move, copy, exists, symbolicLink, base, removeTree} = require('fs'); | |
var engine = require('ringo/engine'); | |
var shell = require('ringo/shell'); | |
var Parser = require('ringo/args').Parser; |
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
#!/bin/bash | |
# reports the combined cpu usage across all processes that include $1 in their name | |
N=0 | |
LINES=$(ps -eo pcpu,args | grep $1) | |
while read -r LINE; do | |
C=$(echo $LINE | cut -d" " -f1) | |
N=$(echo "$N+$C" | bc) | |
done <<< "$LINES" | |
echo "status ok ok" | |
echo "metric cpu float $N" |
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
# install node and node-dev (needed by node-fibers) | |
apt-get install python-software-properties curl -y | |
add-apt-repository ppa:chris-lea/node.js-devel <<EOF | |
EOF | |
apt-get update | |
apt-get install nodejs -y | |
apt-get install build-essential -y | |
apt-get install nodejs-dev -y | |
ln -s /usr/include/nodejs /usr/include/node |
OlderNewer