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 ps( msg ) | |
if Rails.env == 'development' | |
puts '-' * msg.length | |
puts msg | |
end | |
end |
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
// view file | |
= f.input :use_metadata_fields, :label => "Choose one...", :as => :select, :collection => [["Fill in detailed metadata fields","1"], ["Use a default profile","0"]], :input_html => {:id => :use_metadata_fields, :class => 'input-small'} | |
#default_fields // a hash sign is the haml for div id | |
= f.input :default_fields, :as => :select, :collection => @defaults, :method_label => :description | |
#metadata_fields | |
= f.input :price | |
= f.input :pub_date | |
= f.input :imprint | |
= f.input :category |
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
{ | |
"current_page": 1, | |
"per_page": 35, | |
"total_pages": 1, | |
"works": [ | |
{ | |
"work": { | |
"books": [ | |
{ | |
"book": { |
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
# Frontlist Variable Page Layout Catalogue XML from Bibliocloud | |
<?xml version="1.0"?> | |
<catalogue> | |
<section> | |
<section_title>Snowbooks 2014: January to April</section_title> | |
<half_page_book> | |
<category>General non-fiction</category> | |
<month>January</month> | |
<imprint>Snowbooks</imprint> |
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
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<BK xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xsl:version="1.0"> | |
<xsl:for-each select="ONIXMessage/Product"> | |
<Book> | |
<xsl:variable name="form" select="ProductFormDetail"/> | |
<xsl:variable name="date" select="PublicationDate"/> | |
<xsl:variable name="isbn" select="ProductIdentifier[ProductIDType = '15']/IDValue"/> | |
<image href="file:///{$isbn}.jpg" /> | |
<year><xsl:value-of select="concat(substring($date,7,2), '/',substring($date,5,2), '/',substring($date,1,4))"/></year> | |
<productid><xsl:value-of select="$isbn"/></productid> |
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
Dim strXPath1 As String | |
strXPath1 = "/ONIXMessage/Product/ProductIdentifier[ProductIDType='03']/IDValue" | |
ActiveDocument.ContentControls(1).XMLMapping.SetMapping strXPath1 | |
Dim strXPath2 As String | |
strXPath2 = "/ONIXMessage/Product/BICMainSubject" | |
ActiveDocument.ContentControls(2).XMLMapping.SetMapping strXPath2 | |
Dim strXPath3 As String | |
strXPath3 = “/ONIXMessage/Product/Title[TitleType='01']/TitleText" |
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
my_name = '{ "firstname": "Emma" , | |
"lastname" : "Barnes" | |
}' |
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_names = '[{"firstname": "Emma", | |
"lastname" : "Barnes"}, | |
{"firstname": "David", | |
"lastname" :"Aldridge"}, | |
{"firstname": "Rob", | |
"lastname" :"Jones" | |
}]' |
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
# Use the Ruby JSON gem to parse data in the JSON format | |
json = JSON.parse(our_names) | |
# Get the first person's firstname. Ruby counts from 0, not 1! | |
json[0]["firstname"] | |
=> "Emma" | |
# Get the second person's firstname | |
json[1]["firstname"] | |
=> "David" | |
# Get each bit of the JSON data... |
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 Book | |
def initialize(name:, jacket: :draft) | |
@name = name | |
@jacket = jacket | |
end | |
def name | |
@name | |
end |
OlderNewer