Skip to content

Instantly share code, notes, and snippets.

View jjulian's full-sized avatar

Jonathan Julian jjulian

  • MD
  • 21:20 (UTC -04:00)
View GitHub Profile
require 'spec_helper'
describe Base58 do
it "should handle creating encoded strings over 2 characters long" do
(1..100000).each do |i|
i.should encode_and_decode_to(i)
end
end
end
<html>
<head>
<link rel="stylesheet" href="ext-3.1.1/resources/css/ext-all.css" />
<script src="ext-3.1.1/adapter/ext/ext-base.js"></script>
<script src="ext-3.1.1/ext-all-debug.js"></script>
<script>
Ext.BLANK_IMAGE_URL = 'ext-3.1.1/resources/images/default/s.gif';
Ext.onReady(function(){
var personStore = new Ext.data.ArrayStore({
fields: ['id', 'name', 'image', 'city', 'country'],
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
mysql_select_db('myapp_development');
$query = empty($_GET['query']) ? '' : $_GET['query'];
$rows = mysql_query("SELECT * FROM users where username like '%$query%' ORDER BY created_at DESC");
def handle_approved(handle)
allowed = YAML::load_file('/var/www/allowed.yml')
allowed.include?(handle.downcase)
end
# in the action, after the twitter handle is pulled from oauth
if !handle_approved(handle)
reset_session
flash[:notice] = 'Sorry, your username is not allowed'
logger.error "denied access for #{handle}"
#!/usr/bin/env ruby
require 'cgi'
# EDIT ME! PATH TO YOUR jslint.js file
lint = `java org.mozilla.javascript.tools.shell.Main ~/Library/JSLint/jslint.js "$TM_FILEPATH"`
lint.gsub!(/^(Lint at.+?:)(.+?)\n(?:(.+?)\n\n)?/m) do
"<p><strong>#{CGI.escapeHTML($1)}</strong>#{CGI.escapeHTML($2)}</p>" <<
($3 ? "<pre>#{CGI.escapeHTML($3)}</pre>" : '')
end
<div class="editable">
<p>Several things to notice here:</p>
<p>First, if the browser supports .addEventListener(..) we need to do a little extra work to support mouseenter/mouseleave.</p>
<p>But (and I can't stress this enough), this concept is absolutely flawed! We're assuming that if the browser supports .addEventListener(..) then it must not support mouseenter/mouseleave.</p>
<h1 class="nubbin_wrapper">Hello!</h1>
<p>While this happens to be true at present (to the best of my knowledge) it's unwise to assume that this will always be the case. The problem is, there is no (highly reliable) way to determine whether or not a browser supports a particular event (at least not that I know of). I'm okay with this approach for now, only because we're writing the code in such a way, that even if a browser did support mouseenter/mouseleave, our custom implementation of it shouldn't cause any major problems.</p>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js" type="text
make: *** [rdoc] Abort trap
[2010-08-26 23:56:31] make
/Users/jjulian/.rvm/gems/ruby-1.8.7-p160/gems/rdoc-2.4.3/lib/rdoc/rdoc.rb:51: warning: already initialized constant GENERATORS
error loading "/Users/jjulian/.rvm/gems/ruby-1.8.7-p160/gems/sdoc-0.2.20/lib/rdoc/discover.rb": superclass mismatch for class Paragraph (TypeError)
/Users/jjulian/.rvm/gems/ruby-1.8.7-p160/gems/rdoc-2.4.3/lib/rdoc/rdoc.rb:51: warning: already initialized constant GENERATORS
/Users/jjulian/.rvm/gems/ruby-1.8.7-p160/gems/json-1.4.3/lib/json/common.rb:66: [BUG] unknown type 0x22 (0xc given)
ruby 1.9.2p0 (2010-08-18 revision 29036) [x86_64-darwin10.4.0]
@jjulian
jjulian / enough_design_to_be_dangerous.html
Created February 9, 2011 15:24
Example html/css as seen in "Enough Design to be Dangerous" at Bmore on Rails, Feb 8, 2011
<html>
<head>
<style>
body { background-color:#fff; color:#333; font-family: sans-serif; font-size: 36px; margin: 50px 50px; }
p { margin: 10px; }
hr { margin:50px 0; }
.colors { width:100%; }
.colors .c { float:left; padding:5px 10px; line-height: 50px; width: 90px; height: 50px; margin: 5px; text-transform:uppercase; }
.textcolor h1 { color: #000; margin-bottom: 5px; }
.textcolor p { color: #666; }
@jjulian
jjulian / WTF.js
Created February 21, 2011 11:09 — forked from scottmessinger/WTF.js
Helping Scott M with $.ajax
// We all overlooked the fact that there was no "callback" for the response
// Ajax is asynchronous
$.ajax({
url : '/plans.json',
success: function(json, status, xhr) {
console.log("request is complete");
console.log(json[0].plan.created_at);
}
});
@jjulian
jjulian / cmd_line_script.rb
Created June 15, 2011 15:06
A sample script that uses OptionParser and Logger. A great template to start with! Shown off at @bmoreonrails on June 14, 2011
# A sample script that uses OptionParser and Logger
# http://www.ruby-doc.org/stdlib/libdoc/optparse/rdoc/classes/OptionParser.html
require 'optparse'
require 'logger'
# Defaults. This hash will hold all of the options
# parsed from the command-line by
# OptionParser.
options = {
:verbose => false,