The model:
class Content < ActiveRecord::Base
acts_as_taggable
end
created with:
package main | |
import ( | |
"bufio" | |
"fmt" | |
"math/rand" | |
"os" | |
"sort" | |
"strconv" | |
"strings" |
┌───────────────────┐ ┌────────────────────────┐ | |
┌────────────────────│ Clearing │──────┘ ┌───────────────┐ │ | |
│ └───────────────────┘ │ Up a Tree │ │ | |
│ ║ │ └───────────────┘ │ | |
│ Down │ │ │ ┌────────────────────────┐ | |
│ ║ │ ┌──────────────────┘ ┌────────┘ │ │ | |
│ │ │ Up/Down │ │ │ | |
│ │ │ ▼ ▼ ┌─────────────────────┐ | |
┌──────────────┐ ┌──────────────────────┐ ┌─────────────────────────┐ │ Forest 3 │ | |
│ │───────────│ Forest Path │────────│ Forest 2 │───────────│impassible mountains │ |
<!DOCTYPE html> | |
<html> | |
<head> | |
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | |
<title>twitter link gen</title> | |
<script> | |
$(function() { | |
$("#twtgen").submit(function() { |
-- Get a network of members for a given member with a seperation distance. | |
-- In this example I've named the degree of seperation depth. | |
-- pid: petition_id | |
-- mid: member_id | |
-- in the real world there there woudl be a unique constraint on (pid,mid) | |
CREATE TABLE signatures (pid integer, mid integer); | |
-- populate some signatures |
class Node | |
attr_accessor :id, :name, :parent, :children | |
def initialize(opts = {}) | |
@id = opts[:id] | |
@name = opts[:name] | |
@parent = opts[:parent] | |
# add children if passed an array or initialize as an empty array | |
@children = opts[:children].is_a?(Array) ? opts[:children] : [] |
The model:
class Content < ActiveRecord::Base
acts_as_taggable
end
created with:
-- select public.verify_index_exists('index','schema',true); | |
CREATE OR REPLACE FUNCTION public.verify_index_exists(IN _index VARCHAR, IN _schema VARCHAR, IN _throws_error BOOLEAN DEFAULT TRUE) | |
RETURNS BOOLEAN AS | |
$$ | |
BEGIN | |
IF NOT EXISTS (SELECT relname FROM pg_class c, pg_namespace n WHERE c.relnamespace = n.oid AND relname = $1 AND nspname = $2 AND relkind = 'i') THEN | |
IF $3 THEN | |
RAISE 'no such index % on schema %', $1, $2; | |
ELSE | |
RETURN FALSE; |
worker_processes 4; | |
daemon off; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent "$http_referer" ' |
SCHEMA_NAMES = %w(foo bar) | |
namespace :db do | |
task :create do | |
config = Rails.configuration.database_configuration[Rails.env].merge!({'schema_search_path' => 'public'}) | |
ActiveRecord::Base.establish_connection(config) | |
SCHEMA_NAMES.each do |schema| | |
ActiveRecord::Base.connection.execute("CREATE SCHEMA #{schema}") | |
end | |
end | |
end |
#!/usr/bin/env perl | |
use Dancer; | |
hook 'before'=> sub { | |
header('Content-Type' => 'text/plain'); | |
my $throwmap= { | |
rock => { scissors => 'rock smashes scissors', | |
lizard => 'rock crushes lizard'}, | |
paper => { rock => 'paper covers rock', | |
spock => 'paper disproves spock'}, |