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
Ajax.Responders.register({ | |
onCreate: function(a) { | |
if(a.method != 'get'){ | |
a['parameters']['authenticity_token'] = encodeURIComponent('#{form_authenticity_token}'); | |
} | |
} | |
}); |
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 encrypt(string, key) | |
Base64.encode64(aes(key, string)).gsub /\s/, '' | |
end | |
def decrypt(string, key) | |
aes_decrypt(key, Base64.decode64(string)) | |
end | |
def aes(key,string) | |
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc") |
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
# our multi_group http://rails.lighthouseapp.com/projects/8994/tickets/120-patch-activerecord-calculations-only-accept-one-grouping-field# | |
# isn't updated for 2.2 yet. In the meantime, this poor man's version gives you the same results with some delimitter tom foolery. | |
# | |
# note: be careful to ensure that your group_by do not use the delimitter | |
# usage: | |
# self.multi_count(:id, :distinct => true, :group => [:symptom_id, :treatment_id]) | |
# [[["138", "1018"], 187], [["138", "427"], 373], [["6", "1018"], 197], [["6", "427"], 393]] | |
class ActiveRecord::Base | |
def self.multi_count(field, opts = {}) | |
fq_field_name = "#{table_name}.#{field}" |
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
pg_restore: [archiver (db)] could not execute query: ERROR: must be member of role "postgres" | |
Command was: ALTER SCHEMA multum OWNER TO postgres; | |
pg_restore: [archiver (db)] Error from TOC entry 1217; 2612 200456859 PROCEDURAL LANGUAGE plpgsql postgres | |
pg_restore: [archiver (db)] could not execute query: ERROR: must be owner of database plmwebsite | |
Command was: CREATE PROCEDURAL LANGUAGE plpgsql; | |
pg_restore: [archiver (db)] could not execute query: ERROR: language "plpgsql" does not exist | |
Command was: ALTER PROCEDURAL LANGUAGE plpgsql OWNER TO postgres; | |
pg_restore: [archiver (db)] Error from TOC entry 21; 1255 422525031 FUNCTION _group_concat(text, text) postgres | |
pg_restore: [archiver (db)] could not execute query: ERROR: must be member of role "postgres" | |
Command was: ALTER FUNCTION public._group_concat(text, text) OWNER TO postgres; |
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
# MavMark v 0.1 | |
######################### | |
# Indent a messed up ruby file. | |
# Goal: | |
#def excluded_description | |
# excludes_that_exist = @report.excludes.inject({}) do |memo, (dim,excludes)| | |
# swap_unrep = (@report.original_dim_labels[dim.to_sym] || []).map{|l| l.blank? ? 'Unreported' : l} | |
# memo[dim] = excludes & swap_unrep | |
# memo |
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
[alias] | |
co = checkout | |
br = branch | |
mav = !afplay -v .3 -t 12 '/Users/jdwyah/Music/iTunes/iTunes Music/Kenny Loggins/Top Gun/Danger Zone.mp3' &\ngit rebase -i | |
panic = !tar cvf ../git_panic.tar * |
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
ree-1.8.7-2011.03 :002 > Array("aa\nbb") | |
=> ["aan", "bb"] | |
ruby-1.9.2-p180 :008 > Array("aa\nbb") | |
=> ["aanbb"] |
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
WITH | |
target as ( | |
select * from users where id = 12345 | |
), | |
similarities as ( | |
select | |
users.id as user_id, | |
10 * array_upper(users.condition_ids & target.condition_ids,1) / array_upper(users.condition_ids | target.condition_ids,1) as comorbidity_match, | |
15 * case when users.condition_ids[1] = target.condition_ids[1] then 1 else 0 end as primary_condition_match, | |
5 * case when users.birth_date is null then 0 else float8larger(float8(0), 40 - (abs(extract(years from age(users.birth_date, target.birth_date))))) / 40 end as age_match, |
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
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ("Unrecognized field "hubspotUserId" (class com.hubspot.socialmonitoring.StreamItemAction), not marked as ignorable (8 known properties: , "streamItemActionsGuid", "userId", "type", "createdAt", "text", "streamItemId", "updatedAt", "url"]) at [Source: org.eclipse.jetty.server.HttpInput@60356eb0; line: 1, column: 92] (through reference chain: com.hubspot.socialmonitoring.StreamItemAction["hubspotUserId"])") ? at line -1 | |
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ? in from at line 79 | |
com.fasterxml.jackson.databind.DeserializationContext ? in reportUnknownProperty at line 579 | |
com.fasterxml.jackson.databind.deser.std.StdDeserializer ? in handleUnknownProperty at line 672 | |
com.fasterxml.jackson.databind.deser.BeanDeserializerBase ? in handleUnknownProperty at line 906 | |
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in deserializeFromObject at line 328 | |
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in d |
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
Caused by: com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ("Unrecognized field "hubspotUserId" (class com.hubspot.socialmonitoring.StreamItemAction), not marked as ignorable (8 known properties: , "streamItemActionsGuid", "userId", "type", "createdAt", "text", "streamItemId", "updatedAt", "url"]) at [Source: org.eclipse.jetty.server.HttpInput@541d511a; line: 1, column: 92] (through reference chain: com.hubspot.socialmonitoring.StreamItemAction["hubspotUserId"])") ? at line -1 | |
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException ? in from at line 79 | |
com.fasterxml.jackson.databind.DeserializationContext ? in reportUnknownProperty at line 579 | |
com.fasterxml.jackson.databind.deser.std.StdDeserializer ? in handleUnknownProperty at line 672 | |
com.fasterxml.jackson.databind.deser.BeanDeserializerBase ? in handleUnknownProperty at line 906 | |
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in deserializeFromObject at line 328 | |
com.fasterxml.jackson.databind.deser.BeanDeserializer ? in d |
OlderNewer