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
require 'spec_helper' | |
describe Book do | |
it "has same join behavior for logically equivalent subqueries" do | |
author = Author.create | |
book = Book.create!(cost: 100, author: author) | |
2.times { Chapter.create!(book: book) } | |
sub_query1 = Book.arel_table[:author_id].in([author.id]) | |
sub_query2 = Book.arel_table[:author_id].in( |
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
set nocompatible | |
set viminfo='20,\"500 " Keep a .viminfo file. | |
" When editing a file, always jump to the last cursor position | |
autocmd BufReadPost * | |
\ if ! exists("g:leave_my_cursor_position_alone") | | |
\ if line("'\"") > 0 && line ("'\"") <= line("$") | | |
\ exe "normal g'\"" | | |
\ endif | |
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
# search markdown links and convert | |
# [do some cool thing](#fn-infer) => <a name="do-some-cool-thing"></a>[do some cool thing](#do-some-cool-thing) | |
def transform(line) | |
fn_name = 'fn-infer' | |
md_regex = %r{[^`]?\[(.*)\]\(##{fn_name}\)} | |
name_regex = %r{##{fn_name}} | |
a_regex = %r{\[} | |
p line | |
if (line =~ md_regex) |
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
function onOpen() { | |
var sheet = SpreadsheetApp.getActiveSpreadsheet(); | |
var entries = [{ | |
name : "Export Events", | |
functionName : "exportEvents" | |
}]; | |
sheet.addMenu("Calendar Actions", entries); | |
}; | |
function return1() { |
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 AnyOldClass | |
attr_accessor :array_attr | |
def initialize | |
self.array_attr = [] | |
this_is_fine | |
self.array_attr = [] | |
this_also_fine |
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
// based on https://github.com/mapbox/geo-googledocs | |
// install the script and run the geocode once to set the api and key | |
// in the script window, set up a trigger in `Resources > Current Project triggers` | |
// run geocodeFromCache once a minute | |
// | |
// Global variables | |
var ss = SpreadsheetApp.getActiveSpreadsheet(), | |
sheet = ss.getActiveSheet(), | |
activeRange = ss.getActiveRange(), | |
settings = {}; |
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
curl -v $CKAN_BASE_URL/api/action/resource_create \ | |
--form name="Complaints" \ | |
--form id="$resource_id" \ | |
--form package_id="$package_id" \ | |
--form format="csv" \ | |
--form url="http://104.131.23.252/datastore/dump/$resource_id" \ | |
-H "Authorization: $CKAN_API_KEY" | |
sleep 5 |
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
CKAN_BASE_URL=http://www.civicdata.com | |
CKAN_API_KEY=from-ckan-users-profile-page | |
resource_id='2691aff1-e555-48d3-9188-aebf1fa8323e' | |
fields='[{"id":"ID","type":"integer"},{"id":"Date","type":"date"},{"id":"Address","type":"text"},{"id":"Suite","type":"text"},{"id":"PermitType","type":"text"},{"id":"ConstructionCost","type":"integer"},{"id":"OwnerName","type":"text"},{"id":"Contractor","type":"text"},{"id":"parcelId","type":"text"},{"id":"lat","type":"float"},{"id":"lng","type":"float"}]' | |
curl -v $CKAN_BASE_URL/api/3/action/datastore_create \ | |
-d '{"resource_id": "'$resource_id'", "fields": '$fields', "primary_key":"ID", "force":"true"}' \ | |
-H "Authorization: $CKAN_API_KEY" |
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
def format_leaf_collection(geo_json) | |
esri_formatted = JSON.parse(geo_json) | |
features = esri_formatted['features'].map do |feature| | |
properties = feature['attributes'] | |
title = "Hello! Leaf collection status in your area is now '#{properties['Status']}'." | |
title += " Collection dates are #{properties['Dates']}" if properties['Dates'] | |
{ | |
type: "Feature", | |
id: properties['OBJECTID'], |
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
other_subaccount_sid= | |
other_phone_sid= | |
citygram_subaccount_sid= | |
master_account_sid= | |
master_account_auth_token= | |
curl -XPOST "https://api.twilio.com/2010-04-01/Accounts/$other_subaccount_sid.json" \ | |
-d "Status=closed" \ | |
-u "$master_account_sid:$master_account_auth_token" |
OlderNewer