Skip to content

Instantly share code, notes, and snippets.

View voxxit's full-sized avatar

Josh Delsman voxxit

View GitHub Profile
# This will render the partial to the browser, then return nothing to Ruby.
def controller_action
render("partial") and return
end
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Hello World</title>
<link rel="stylesheet" href="/stylesheets/application.css" type="text/css" />
</head>
<body>
<div id="container">
...
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$("button").hover(
function(){ $(this).addClass("hover"); },
function(){ $(this).removeClass("hover"); }
)
});
</script>
server {
listen 80;
server_name openvbx.local;
root /u/apps/openvbx;
access_log /var/log/nginx/openvbx.local.access.log;
error_log /var/log/nginx/openvbx.local.error.log;
index index.php;
if ($request_filename !~ (js|css|jpg|png|gif|robots\.txt|index\.php.*) ) {
rewrite ^(.*)$ /index.php?vbxsite=$1 last;
require 'cpanel'
# Create a new instance of a server
server = Cpanel::Server.new(
:url => "http://server.url.com:2086/",
:key => "API_KEY",
:timepout => 100, # defaults to 300
:api => "xml" # defaults to "json"
)
require 'memcached'
require 'memcache'
# encoding: utf-8
class Currency
CACHE = MemCache.new 'localhost:11211'
class << self
def sterling
"string".html_safe? # false
"string".html_safe.html_safe? # true
("string" + "string".html_safe).html_safe? # false
test = nil
test.html_safe? # false
test.try(:html_safe) # nil
test = test.to_s # ""
test.html_safe? # false
<title>{block:PostSummary}{PostSummary} - {/block:PostSummary}{Title}</title>
T.User.find("voxxit").timeline().first(5).each(function(tweet){
if(tweet.text !== undefined){
var tweet_html = '<div class="tweet">';
var link_regex = /((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi;
tweet_html += tweet.text.replace(link_regex, '<a href="$1">$1</a>');
tweet_html += '<div class="tweet_hours">';
tweet_html += '<a href="http://www.twitter.com/';
tweet_html += 'voxxit/status/' + tweet.id + '">';
tweet_html += '<time>' + time_ago_in_words(tweet.createdAt) + ' ago</time><\/a><\/div>';