This file contains hidden or 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
| ### | |
| Usage: | |
| * add model.name property that will be used as a namespace in the json request | |
| * put this code before your Backbone app code | |
| * use toJSON() as usual (so there is no namespacing in your templates) | |
| * your model's data will be sent under model.name key when calling save() | |
| ### | |
| # save reference to Backbone.sync | |
| Backbone.oldSync = Backbone.sync |
This file contains hidden or 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 V1Controller < ApplicationController | |
| before_filter :check_some | |
| def index | |
| response_hash = {:a => [1,2,3], :status => "OK"} | |
| respond_to do |format| | |
| format.xml { render :xml => response_hash.to_xml(:root => "response", :dasherize => false, :skip_types => true) } | |
| format.json { render :json => response_hash, :callback => params[:callback] } | |
| end |
This file contains hidden or 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
| SHELL = /bin/sh | |
| #### Start of system configuration section. #### | |
| srcdir = ../../../../ext/skypekit4ruby | |
| topdir = /home/leo/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1 | |
| hdrdir = /home/leo/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1 | |
| arch_hdrdir = /home/leo/.rvm/rubies/ruby-1.9.2-p180/include/ruby-1.9.1/$(arch) | |
| VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby |
This file contains hidden or 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
| prefix_test=# create table tags ( | |
| prefix_test(# tag text primary key, | |
| prefix_test(# name text not null, | |
| prefix_test(# shortname text, | |
| prefix_test(# status char default 'S', | |
| prefix_test(# | |
| prefix_test(# check( status in ('S', 'R') ) | |
| prefix_test(# ); | |
| NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "tags_pkey" for table "tags" | |
| CREATE TABLE |
This file contains hidden or 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
| select a || ' from (select ' || quote_literal(a) || b || ', ' || quote_literal(b) || '::text as b) as quine' from (select 'select a || '' from (select '' || quote_literal(a) || b || '', '' || quote_literal(b) || ''::text as b) as quine'''::text as a, '::text as a'::text as b) as quine; |
This file contains hidden or 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
| CREATE OR REPLACE FUNCTION luhn_verify(int8) RETURNS BOOLEAN AS $$ | |
| -- Take the sum of the | |
| -- doubled digits and the even-numbered undoubled digits, and see if | |
| -- the sum is evenly divisible by zero. | |
| SELECT | |
| -- Doubled digits might in turn be two digits. In that case, | |
| -- we must add each digit individually rather than adding the | |
| -- doubled digit value to the sum. Ie if the original digit was | |
| -- `6' the doubled result was `12' and we must add `1+2' to the | |
| -- sum rather than `12'. |
This file contains hidden or 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
| CREATE OR REPLACE FUNCTION random(numeric, numeric) | |
| RETURNS numeric AS | |
| $$ | |
| SELECT ($1 + ($2 - $1) * random())::numeric; | |
| $$ LANGUAGE 'sql' VOLATILE; |
This file contains hidden or 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
| CREATE OR REPLACE FUNCTION ret_def(text,text,text) RETURNS text AS $$ | |
| SELECT | |
| COLUMNS.column_default::text | |
| FROM | |
| information_schema.COLUMNS | |
| WHERE table_name = $2 | |
| AND table_schema = $1 | |
| AND column_name = $3 | |
| $$ LANGUAGE sql IMMUTABLE; |
This file contains hidden or 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
| CREATE LANGUAGE plpgsql; | |
| CREATE FUNCTION count_estimate(query text) RETURNS integer AS $$ | |
| DECLARE | |
| rec record; | |
| rows integer; | |
| BEGIN | |
| FOR rec IN EXECUTE 'EXPLAIN ' || query LOOP | |
| rows := substring(rec."QUERY PLAN" FROM ' rows=([[:digit:]]+)'); | |
| EXIT WHEN rows IS NOT NULL; | |
| END LOOP; |
This file contains hidden or 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
| SELECT nspname || '.' || relname AS "relation", | |
| pg_size_pretty(pg_total_relation_size(C.oid)) AS "total_size" | |
| FROM pg_class C | |
| LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace) | |
| WHERE nspname NOT IN ('pg_catalog', 'information_schema') | |
| AND C.relkind <> 'i' | |
| AND nspname !~ '^pg_toast' | |
| ORDER BY pg_total_relation_size(C.oid) DESC | |
| LIMIT 20; |