Skip to content

Instantly share code, notes, and snippets.

#upload the file
put(File.read("/tmp/#{dbname}-snapshot.sql.bz2"), "/tmp/#{dbname}-snapshot.sql.bz2", :mode => 0666)
#import the database
run "bzcat /tmp/#{dbname}-snapshot.sql.bz2 | mysql -u #{dbuser} -p #{dbname}" do |ch, stream, out |
ch.send_data "#{dbpass}\n" if out=~ /Enter password:/
end
SELECT root_node.id, lookup_progresses.children_total, GROUP_CONCAT(children.id) as child_ids
FROM contents as root_node
LEFT JOIN lookup_progresses ON root_node.id = lookup_progresses.content_id
LEFT JOIN contents as children on root_node.id = children.parent_id
WHERE root_node.content_type_id = 2 AND (SELECT count(id) FROM contents WHERE parent_id = root_node.id AND content_type_id = 6) > 0
GROUP BY root_node.id;
EXPLAIN SELECT root_node.id, GROUP_CONCAT(children.id) as child_ids
FROM contents as root_node
LEFT JOIN contents as children ON root_node.id = children.parent_id AND children.parent_id = root_node.id AND children.content_type_id =6
WHERE root_node.content_type_id = 2
GROUP BY root_node.id;
EXPLAIN SELECT root_node.id, GROUP_CONCAT(children.id) as child_ids
FROM contents as root_node
RIGHT JOIN contents as children ON root_node.id = children.parent_id AND children.parent_id = root_node.id AND children.content_type_id = 6
WHERE root_node.content_type_id = 2
GROUP BY root_node.id;
+----+-------------+-----------+--------+---------------+---------+---------+------------------------------------------+-------+----------------------------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+-------------+-----------+--------+---------------+---------+---------+------------------------------------------+-------+----------------------------------------------+
| 1 | SIMPLE | children | ALL | NULL | NULL | NULL | NULL | 12354 | Using where; Using temporary; Using filesort |
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
mouseChildren="false" useHandCursor="true" buttonMode="true"
click="launchPage()" creationComplete="init()"
implements="com.candlecafe.view.component.renderers.IItemViewerRenderer">
<mx:Script>
<![CDATA[
import mx.events.EffectEvent;
import com.candlecafe.model.PressImage;
import mx.effects.easing.*;
@camwest
camwest / gist:79541
Created March 15, 2009 21:27
Example of toElement in Prototype
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Using Prototype to Inject Classes into the DOM</title>
<meta name="generator" content="TextMate http://macromates.com/">
<meta name="author" content="Cameron Westland">
<!-- Date: 2009-03-15 -->
var Tweet = Class.create({
initialize: function(data) {
this.date = data.created_at;
this.fromUser = data.from_user;
this.text = data.text;
this.imageSource = data.profile_image_url;
this.id = data.id;
},
toElement: function() {
<script type="text/javascript" charset="utf-8" src="http://search.twitter.com/search.json?callback=callback&q=maxcameron"></script>
<script type="text/javascript" charset="utf-8">
function callback(data) {
data.results.each(function(result){
$('results').insert(new Tweet(result));
});
}
</script>
require File.expand_path(File.dirname(__FILE__) + '../../../spec_helper')
module Reports
describe ReportCardsController do
describe "GET index" do
it "exposes course statuses as @course_statuses" do
get :show
end
class Reports::ReportCardsController < ApplicationController
def show
render :text => "Test"
end
end