Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

average = (50.0 + 75.0 + 90.0) / 3.0 => 71.66666666666667 (14 decimal places)
average = ratings.average(:rating).to_f => 71.6666666666667 (13 decimal places)
:rating is a double in postgres.
{
"query": {
"filtered": {
"filter": {
"and": [
{
"and": [
{
"or": [
{
foo_plan:
FOO_ID: 1
bar_group:
FOO_ID: foo_plan #doesn't work
FOO: foo_plan #doesn't work
FOO_ID: 1 #works but not ideal
Rails.application.eager_load! #ensure all controllers are loaded
ApplicationController.descendants.each do |controller|
puts "#{controller.name}"
end
class ApplicationController < ActionController::Base
@@page_title = nil
def self.set_title(page_title)
@@page_title = page_title
end
def page_title
ignore_for = %w{sessions devise}
:template{id: "foo"}
.this
.that.somethingelse
%h1 Title
.body
some text {{foo}}
Jennifer: Thank you for contacting ThinkGeek! My name is Jennifer. How can I help you today?
David Herman: Trying to determine if I order something if it will make it by the 25th and what shipping method I can chose
David Herman: *choose
David Herman: order number is 64eaf9c02
David Herman: hello?
Jennifer: Hi sorry to keep you waiting. Let me check on that.
David Herman: that's ok, I'm guessing you guys are a tad busy ;)
Jennifer: The status is incomplete. Do you want me to complete your order David. Sorry fore the inconvenience.
David Herman: No, I want to know what type of shipping I would need to do to get it here before the 25th
Jennifer: Do you want me to expedite the method?
@dstarh
dstarh / ip.rb
Created February 12, 2009 16:35
get ip via ruby
#!/usr/local/bin/ruby
require 'net/http'
require 'uri'
require 'rubygems'
require 'json'
module JSONIP
def r(a){def i=a.indexOf(48);if(i<0)print a else(('1'..'9')-(0..80).collect{j-> g={(int)it(i)==(int)it(j)};g{it/9}|g{it%9}|g{it/27}&g{it%9/3}?a[j]:'0'}).each{ r(a[0..<i]+it+a[i+1..-1])}}
declare @meal_scale_id int
set @meal_scale_id = 5041
;with order_seq_num(meal_scale_id,recipe_scale_id,sort_value)
as (
Select ms.meal_scale_id, ms.recipe_scale_id, sort_value = row_number() over(partition by meal_scale_id order by sort_value) -1
from ed_diet_meal_scale_recipe_scale_xref ms with(nolock)
--where ms.meal_scale_id in (5389,5391,5393,5041)
)