Skip to content

Instantly share code, notes, and snippets.

@iamnoah
iamnoah / index.js
Created December 1, 2009 23:56
Simple node.js webserver with logging. Serves whatever files are reachable from the directory where node is running.
/*
* Copyright (c) 2010 Noah Sloan <http://noahsloan.com>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
def extract_string_literals( string )
string_literal_pattern = /"([^"\\]|\\.)*"/
string_replacement_token = "___+++STRING_LITERAL+++___"
# Find and extract all the string literals
string_literals = []
string.gsub(string_literal_pattern) {|x| string_literals << x}
# Replace all the string literals with our special placeholder token
string = string.gsub(string_literal_pattern, string_replacement_token)
# Return the modified string and the array of string literals
return [string, string_literals]
@matthiasr
matthiasr / presale-check.sh
Created October 23, 2011 20:52
check if 28C3 presale is online. add this as a cronjob.
#!/bin/sh
URLS="http://presale.events.ccc.de/ https://presale.events.ccc.de/"
MAILTO="foo@example.com bar@example.org"
TIMEOUT=10
for URL in $URLS; do
DONEFILE=${PWD}/.urlcheckdone.$(echo ${URL} | sed -e 's/[^-[:alnum:]_]/_/g')
[ -f ${DONEFILE} ] && continue