Skip to content

Instantly share code, notes, and snippets.

class Example < ActiveRecord::Base
require 'rubygems'
require 'nokogiri'
require 'open-uri'
include Splitter
belongs_to :word, :counter_cache => true
belongs_to :sentence, :dependent => :destroy
@dlynam
dlynam / Code for embedded flashcards iFrame
Created January 4, 2012 00:17
Code for embedded flashcards iFrame
class Embed::EmbedController < ApplicationController
skip_before_filter :save_referer
layout "embed"
protected
def embedded_list
@list = List.find(params[:list_id] ||= params[:id])
if !@list.public
raise "Unable to view this list".inspect unless @list.academic_class_id
class UpdateBlankAsiAndRfiSummaries < ActiveRecord::Migration
def up
ArchitecturalSupplementalInformation.where(:summary => ['',' ']).each do |asi|
asi.skip_notifications = true
asi.summary = '--'
asi.save
end
RequestForInformation.where(:summary => ['',' ']).each do |rfi|
rfi.skip_notifications = true
rfi.summary = '--'
def search
query = params[:query].strip
results = ActiveRecord::Base.connection.select_all("SELECT c.name, addresses.state, addresses.city, scope_of_work_types.label AS tags
FROM companies c
LEFT JOIN addresses on c.id = addresses.owner_id
LEFT JOIN scope_of_work_types on c.id = scope_of_work_types.taggee_id
WHERE c.name ILIKE '%#{query}%' or addresses.city ILIKE '%#{query}%' or
(scope_of_work_types.label ILIKE '%#{query}%' and scope_of_work_types.tagger_id = #{current_company.id})") #private tags
to_extjs(results)
end
def search
query = params[:query].strip
results = ActiveRecord::Base.connection.select_all("SELECT c.name, addresses.state, addresses.city, scope_of_work_types.label AS tags
FROM companies c
LEFT JOIN addresses on c.id = addresses.owner_id
LEFT JOIN scope_of_work_types on c.id = scope_of_work_types.taggee_id
WHERE c.name ILIKE '%#{query}%' or addresses.city ILIKE '%#{query}%' or
(scope_of_work_types.label ILIKE '%#{query}%' and scope_of_work_types.tagger_id = #{current_company.id})") #private tags
to_extjs(results)
end
def search
query = params[:query].strip
results = ActiveRecord::Base.connection.select_all("SELECT c.name, addresses.state, addresses.city, scope_of_work_types.label AS private_tag
FROM companies c
LEFT JOIN addresses on c.id = addresses.owner_id
LEFT JOIN scope_of_work_types on c.id = scope_of_work_types.taggee_id
WHERE c.name ILIKE '%#{query}%' or addresses.city ILIKE '%#{query}%' or
(scope_of_work_types.label ILIKE '%#{query}%' and scope_of_work_types.tagger_id = #{current_company.id})") #private tag
to_extjs(results)
end
def search
query = params[:query].strip
results = ActiveRecord::Base.connection.select_all("SELECT c.name, addresses.state, addresses.city, scope_of_work_types.label AS private_tags
FROM companies c
LEFT JOIN addresses on c.id = addresses.owner_id
LEFT JOIN scope_of_work_types on c.id = scope_of_work_types.taggee_id
WHERE c.name ILIKE '%#{query}%' or addresses.city ILIKE '%#{query}%' or
(scope_of_work_types.label ILIKE '%#{query}%' and scope_of_work_types.tagger_id = #{current_company.id})") #private tag
to_extjs(results)
end
ActiveRecord::Base.connection.select_all("SELECT c.name, tags.label AS private_tag FROM companies c LEFT JOIN tags on c.id = (scope_of_work_types.label ILIKE '%always%' and tags.tagger_id = 117)")
Here's the JSON that gets returned for each of the 3 Mancount Entry POST requests:
{"success":true,"code":200,"data":{"contractor_id":390,"created_at":"2013-03-08T18:43:40Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":176,"overtime_hours_worked":"0.0","overtime_worker_count":0,"photos_count":null,"project_id":39,"total_hours_worked":0.0,"updated_at":"2013-03-08T18:43:40Z","worker_count":0,"worker_type":"Foreman"},"error":""}
{"success":true,"code":200,"data":{"contractor_id":202,"created_at":"2013-03-08T18:43:55Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":177,"overtime_hours_worked":"0.0","overtime_worker_count":0,"photos_count":null,"project_id":39,"total_hours_worked":0.0,"updated_at":"2013-03-08T18:43:55Z","worker_count":0,"worker_type":"Journeyman"},"error":""}
{"success":true,"code":200,"data":{"contractor_id":203,"created_at":"2013-03-08T18:44:06Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":178,"overtime_hours_worked":"0.0"
@dlynam
dlynam / gist:5118824
Created March 8, 2013 18:52
new mancount entry log
Here's the JSON that gets returned for each of the 3 Mancount Entry POST requests:
{"success":true,"code":200,"data":{"contractor_id":390,"created_at":"2013-03-08T18:43:40Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":176,"overtime_hours_worked":"0.0","overtime_worker_count":0,"photos_count":null,"project_id":39,"total_hours_worked":0.0,"updated_at":"2013-03-08T18:43:40Z","worker_count":0,"worker_type":"Foreman"},"error":""}
{"success":true,"code":200,"data":{"contractor_id":202,"created_at":"2013-03-08T18:43:55Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":177,"overtime_hours_worked":"0.0","overtime_worker_count":0,"photos_count":null,"project_id":39,"total_hours_worked":0.0,"updated_at":"2013-03-08T18:43:55Z","worker_count":0,"worker_type":"Journeyman"},"error":""}
{"success":true,"code":200,"data":{"contractor_id":203,"created_at":"2013-03-08T18:44:06Z","created_by_id":null,"daily_report_id":9413,"hours_worked":"0.0","id":178,"overtime_hours_worked":"0.0"