This file contains 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 calculator = { | |
add: function (a, b) { | |
return a + b | |
}, | |
subtract: function (a, b) { | |
return a - b | |
}, | |
multiply: function (a, b) { | |
return a * b | |
}, |
This file contains 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
// bookmarklet to introspect the source of current page | |
javascript:(function(d,h){h=d.documentElement.innerHTML;d.open();d.write('<pre>'+('<!DOCTYPE html><html>'+h+'</html>').replace(/[<>]/g,function(m){return{'<':'<','>':'>'}[m]})+'</pre>')})(document); |
This file contains 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
module Idea | |
class Generator | |
def actions | |
@actions ||= %w{read write design contemplate} | |
end | |
def objects | |
@objects ||= ['code', 'books', 'art', 'poetry', 'blogs'] | |
end | |
This file contains 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
window.onload = function () { | |
if (! document.querySelectorAll) { // Quick & Dirty way to tell the good browsers from the bad ones. | |
alert("Please upgrade your browser to view this site."); | |
} | |
}; |
This file contains 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
[/Users/chris/Code/Ruby/gist-550144 (master)] ruby-1.9.2-p0 | |
$ time php php_string.php > /dev/null | |
real 0m0.237s | |
user 0m0.218s | |
sys 0m0.017s | |
[/Users/chris/Code/Ruby/gist-550144 (master)] ruby-1.9.2-p0 | |
$ time php php_array.php > /dev/null | |
real 0m0.249s |
This file contains 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
# Author: Pieter Noordhuis | |
# Description: Simple demo to showcase Redis PubSub with EventMachine | |
# | |
# Requirements: | |
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby | |
# - a browser with WebSocket support | |
# | |
# Usage: | |
# ruby redis_pubsub_demo.rb | |
# |
This file contains 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/sh | |
# Get a website ready to deploy with git | |
REPO_HOST='example.com' | |
REPO_PATH=$HOME/repos | |
# Check that the user has provided a directory to use and it exists | |
if [ ! "$1" ]; then | |
echo "Usage: $0 DIRECTORY" | |
echo "Where DIRECTORY is the folder that you want to contain the working copy" |
This file contains 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 'rubygems' | |
require 'gollum/frontend/app' | |
Precious::App.set(:gollum_path, Dir.pwd) | |
run Precious::App |
This file contains 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
<?php | |
/** | |
* Simple twitter stream function | |
* | |
* Usage: $tweets = userTimeline("hecticjeff"); | |
*/ | |
function userTimeline($screenName) | |
{ | |
// Create a remote connection | |
$twitter = curl_init("http://api.twitter.com/1/statuses/user_timeline.json?screen_name={$screenName}"); |
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> | |
<style type="text/css"> | |
html { height: 100% } | |
body { height: 100%; margin: 0px; padding: 0px } | |
#map_canvas { height: 600px; width: 800px; } | |
.hidden { display: none; } | |
</style> |
OlderNewer