Skip to content

Instantly share code, notes, and snippets.

View walter's full-sized avatar

Walter McGinnis walter

View GitHub Profile
def replace_value_for(extended_field_element_name, value, field = nil)
logger.debug("what is extended_content: " + self.extended_content.inspect)
# Fetch the existing data from XML
sandpit_data = structured_extended_content
logger.debug("what is sandpit_data: " + sandpit_data.inspect)
# Replace the value we're changing
# The value needs to be nested to form an array if necessary, since we ALWAYS pass in an array.
if field.is_a_choice? && !value.is_a?(Array)
def replace_value_for(extended_field_element_name, value, field = nil)
logger.debug("what is extended_content: " + self.extended_content.inspect)
# Fetch the existing data from XML
sandpit_data = structured_extended_content
logger.debug("what is sandpit_data: " + sandpit_data.inspect)
# Replace the value we're changing
# The value needs to be nested to form an array if necessary, since we ALWAYS pass in an array.
if field.is_a_choice? && !value.is_a?(Array)
def replace_value_for(extended_field_element_name, value, field = nil)
logger.debug("what is extended_content: " + self.extended_content.inspect)
# Fetch the existing data from XML
sandpit_data = structured_extended_content
logger.debug("what is sandpit_data: " + sandpit_data.inspect)
# Replace the value we're changing
# The value needs to be nested to form an array if necessary, since we ALWAYS pass in an array.
if field.is_a_choice? && !value.is_a?(Array)
$ script/console # put the word production after this if you are normally running in production mode
...
>> require 'net/http'
>> require 'uri'
>> require 'socket'
>> url = URI.parse("http://no.wikipedia.org/wiki/Valentin_F%C3%BCrst")
>> headers = Object.const_defined?('SITE_URL') ? { "User-Agent" => "#{SITE_URL} link checking mechanism via Ruby Net/HTTP" } : { "User-Agent" => "Ruby Net/HTTp used for link checking mechanism" }
>> http = Net::HTTP.new(url.host, (url.scheme == 'https') ? 443 : 80)
>> response = http.request_head(url.path, headers) # copy and paste what this returns back into ticket
>> response = http.request_get(url.path, headers) {|r|} # copy and paste what this returns back into ticket
<اراء_الاخرين xml_element_name=\"dc:subject\">a</اراء_الاخرين>
...
<رعاة_الحدث xml_element_name=\"dc:subject\">b</رعاة_الحدث>
>> ef1 = ExtendedField.find_by_label("اراء الاخرين")
ef1 = ExtendedField.find_by_label("اراء الاخرين")
=> #<ExtendedField id: 23, label: "اراء الاخرين ", xml_element_name: "dc:subject", xsi_type: nil, multiple: false, description: nil, created_at: "2010-08-18 17:45:08", updated_at: "2010-08-18 17:45:14", import_synonyms: nil, example: nil, ftype: "text", user_choice_addition: nil, dont_link_choice_values: nil>
>> ef1.label_for_params
ef1.label_for_params
=> "اراء_الاخرين_"
@walter
walter / kete-2011-02-18-working-gems
Created February 17, 2011 22:46
list of working gems compatible with Kete
$ gem list
*** LOCAL GEMS ***
actionmailer (2.3.5)
actionpack (2.3.5)
activerecord (2.3.5)
activeresource (2.3.5)
activesupport (2.3.5)
addressable (2.2.4)
@walter
walter / draft_1_media_selector.js
Created March 1, 2011 01:43
broken refactoring for DRYness of updateResultsFor to be bound
(function($) {
var app = $.sammy('#main', function() {
this.use(Sammy.Handlebars, 'hb');
// this.use('Template');
// get providers
// append provider title
// create ul
// render each of the sources of each provider as li
// use the correct template for the source type
@walter
walter / working refactoring for DRYness for updateResultsFor and updateProviderWith
Created March 13, 2011 23:16
Partial refactoring to DRY things up and prepare for upcoming routes.
(function($) {
var app = $.sammy('#main', function() {
this.use(Sammy.Handlebars, 'hb');
this.around(function(callback) {
var context = this;
this.load('data/providers.json')
.then(function(providers) {
context.providers = providers;
@walter
walter / _gmaps4rails.html.erb
Created August 21, 2011 22:24
Rails 2.3 override of gmaps4rails partial
<% #thanks to enable_css, user can avoid this css to be loaded
if enable_css == true %>
<% content_for :head do %>
<%= stylesheet_link_tag 'gmaps4rails' %>
<% end %>
<% end %>
<% content_for :scripts do %>
<% if enable_js == true %>
<% @provider = options['map_options'] && options['map_options']['provider'] ? options['map_options']['provider'] : nil -%>
<% case @provider