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
// validate all the fields in the form | |
validateForm:function() { | |
this.resetForm(); | |
this.fields.each(function(field) { | |
this.validateField(field); | |
}.bind(this)); | |
return this.hasErrors() ? false : true; | |
}, | |
// validate a specific field |
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
%h1 Heading 2 | |
:javascript | |
console.info | |
%h2 Heading 2 |
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
- cache [@user, @user.posts] do | |
= @user.inspect | |
- @user.posts.each do |post| | |
- cache post do | |
= post.inspect |
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
# Procedure | |
# | |
# From a completely fresh restart, ssh'd into the Pi from my mac and then ran the | |
# sysbench command listed at the top of each section. Copied and pasted the | |
# output, restarted, and ran the next. | |
# | |
# 1000MHz overclock settings: | |
# | |
# arm_freq=1000 | |
# sdram_freq=500 |
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
positron-2:cal_counter_grape rob$ rake jasmine:ci | |
[2015-04-07 11:33:05] INFO WEBrick 1.3.1 | |
[2015-04-07 11:33:05] INFO ruby 2.2.1 (2015-02-26) [x86_64-darwin14] | |
[2015-04-07 11:33:05] INFO WEBrick::HTTPServer#start: pid=21195 port=59830 | |
Waiting for jasmine server on 59830... | |
jasmine server started. | |
F | |
Failures: | |
Entries sorts entries by ate_at, newest first |
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
#!/usr/bin/ruby | |
# This app proves the Birthday Paradox: http://en.wikipedia.org/wiki/Birthday_problem | |
# | |
# The Birthday Paradox is counter-intuitive to common sense - select 23 people at random and | |
# there is a greater than 50% chance that at least two people in the group will have the same | |
# birthday. With 50 random people the probability goes up to 97%. These solutions ignore leap-years. | |
# | |
# People Probability | |
# --------------------- | |
# 10 11.7% |
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
# Generates a random string of letters and numbers | |
letters = ('A'..'Z').to_a | |
print 'Length of random string? '; length_of_string = gets.chomp.to_i | |
print 'How many to make? '; number_to_make = gets.chomp.to_i | |
numbers = [] | |
while numbers.length < number_to_make do | |
output = '' |
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
class Location | |
attr_reader :zip, :city, :state | |
def initialize(values={}) | |
@zip = values[:zip] | |
@city = values[:city] | |
@state = values[:state] | |
end | |
def self.parse(text) |
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
--- | |
layout: post | |
title: Convert a MySQL database to a SQLite3 database | |
--- | |
<span class="intro">I wanted to convert a</span> <a href="http://mysql.org">MySQL</a> database to a <a href="http://sqlite.org">SQLite3</a> database the other day. I did some searching and found a <a href="http://www.sqlite.org/cvstrac/wiki?p=ConverterTools">good script on the SQLite3 site</a> . It didn’t quite work for me, but it was close (left a bunch of random MySQL “set” statements everywhere and used MySQL’s default multiple insert syntax). After some tweaking I got it to create the file without errors. Here’s my version for anyone that needs to do the same thing (requires <em>mysqldump</em> and <em>perl</em> be installed on your system): | |
{% highlight bash %} | |
#!/bin/sh | |
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
class Poller | |
def self.call(env) | |
if env["PATH_INFO"] =~ /^\/poller/ | |
[200, {"Content-Type" => "text/html"}, [Time.now.to_f]] | |
else | |
[404, {"Content-Type" => "text/html"}, ["Not Found"]] | |
end | |
end | |
end |
OlderNewer