Skills wanted

Here is the technology stack I came up with:

HTML
Bootstrap Framework
JavaScript
JQuery
PHP
MySQL
Oracle (PL/SQL)
Ruby on Rails
NodeJS
MongoDB
AngularJS

 

 

 

Posted in Coding | Leave a comment

Amazon MWS feed

Found that information about Amazon’s MWS is pretty hard to find and pretty scattered.  Took me awhile to even find a link to ORDER_ACKNOWLEDGEMENT, ORDER_FULFILLMENT sample that Amazon provides.

sellercentral.amazon.com/help/merchant_documents/XSD/samples/OrderAcknowledgement_sample.xml

If you are fulfilling multiple orders in one XML you want to repeat everything in the <Message>


<?xml version="1.0" encoding="iso-8859-1"?>
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
  <Header>
    <DocumentVersion>1.01</DocumentVersion>
    <MerchantIdentifier></MerchantIdentifier>
  </Header>
  <MessageType>OrderAcknowledgement</MessageType>
  <Message>
    <MessageID>1</MessageID>
    <OrderAcknowledgement>
      <AmazonOrderID></AmazonOrderID>
      <MerchantOrderID></MerchantOrderID>
      <StatusCode>Success</StatusCode>
      <Item>
        <AmazonOrderItemCode></AmazonOrderItemCode>
        <MerchantOrderItemID></MerchantOrderItemID>
      </Item>
    </OrderAcknowledgement>
  </Message>
  <Message>
    <MessageID>2</MessageID>
    <OrderAcknowledgement>
      <AmazonOrderID></AmazonOrderID>
      <MerchantOrderID></MerchantOrderID>
      <StatusCode>Success</StatusCode>
      <Item>
        <AmazonOrderItemCode></AmazonOrderItemCode>
        <MerchantOrderItemID></MerchantOrderItemID>
      </Item>
    </OrderAcknowledgement>
  </Message>
  <Message>
    <MessageID>3</MessageID>
    <OrderAcknowledgement>
      <AmazonOrderID></AmazonOrderID>
      <MerchantOrderID></MerchantOrderID>
      <StatusCode>Success</StatusCode>
      <Item>
        <AmazonOrderItemCode></AmazonOrderItemCode>
        <MerchantOrderItemID></MerchantOrderItemID>
      </Item>
      <Item>
        <AmazonOrderItemCode></AmazonOrderItemCode>
        <MerchantOrderItemID></MerchantOrderItemID>
      </Item>
    </OrderAcknowledgement>
  </Message>
</AmazonEnvelope>

 

Link to solution

Posted in Uncategorized | Tagged , , , , | Leave a comment

PHP SAP RFC Function call input not working

This is the first time I used PHP to call a SAP function.  Ran into this problem that I couldn’t figure until someone with experience helped me.

The SAP function SAP_FUNCTION had one input that expects a length of 10.

I did not realize that that meant that the input has to be a length of 10.  The examples the SAP analyst gave me had inputs with 9 and I kept trying it with 9 and was not getting anything back.

In PHP, a fellow developer told me I had to pad the input so the length is 10.

str_pad($vartopad, 10,”0″, STR_PAD_LEFT)

Spent most of the morning trying to figure out the problem and never found anything online about the need for padding.  Maybe it’s a problem with the SAP function but either way maybe it’ll help someone with input errors using PHP to connect to SAP.

Posted in Web | Tagged , , , , , | Leave a comment

Apache paths (default)

Had to look this up multiple times now:

access log (sudo):

/var/log/apache2/access.log

apache2.conf:

/etc/apache2/apache2.conf

props if figured out what I’m doing

Posted in Linux | Tagged , , , , , , , | Leave a comment

Rails Association

Spent a day learning how about associations.  Realized that has_and belongs to and the necessary join table isn’t as easy to use as creating a regular join model table and use has_many :through.

Join Table = create_join_table

Join Model Table = create_table

Following Railscast, it promoted to use join model along with has_many :through.  Part of the issue I had was that I wanted additional information in the join table like the timestamp information.  Especially for Many to Many relationships.

—–

Originally I planned on using Rails migration to create all my tables.  After creating only 7 of them I feel like it is a bit overkill. Much easier to write my own sql script that creates a table and then just use the rake db:schema:dump.

If you want to use scaffold following the dump

rails g model ModelName –skip-migration

 

 

 

Posted in RoR | Tagged , , | Leave a comment

Helpful Rails 4 commands

When creating a table and limiting a column string size

rails g scaffold users email:string{50}

To set columns in a table to not nullable or set the default value, after the migration file is created, manually open the file and edit the column you want.

t.string :column1, null:false, default: ‘ABC’

For Join tables via migration

rails g migration CreateJoinTable[Model1Model2] Model1 Model2

The above creates a table with two column model1_id and model2_id.  I’ve experienced that the table name will be Model1_Model2. Rails documentation seems to say different but that’s what I got.

If you want to redo your last migration

rake db:migrate:redo

rake db:migrate:redo STEP=2  # redo last two steps

This was helpful because I had deleted a table rails created and couldn’t figure out how to recreate it until I cam across this

If you created a migration you want to delete

rails db:migrate:status

Find the version before the one you want to delete

rake db:migrate VERSION=XXXXX

Manually delete the migration you don’t want

 

References:

http://stackoverflow.com/questions/14886156/rails-generate-scaffold-with-table-options

http://www.packtpub.com/article/Working-with-Rails-ActiveRecord-Migrations-Models-Scaffolding-and-Database-Completion 

 

Posted in Uncategorized | Tagged , | Leave a comment

Rails here we go

Finally moving forward to redoing a website that is all DB driven to a Rails platform.  Designing DB schema and models. woot.  Wish I could bring in a Rails consultant though

Posted in RoR | Tagged | Leave a comment

Sublime Shortcuts

Man just found out a shortcut in Sublime that probably everybody but me knew.

I can type div then ‘tab’ and it will add in the html brackets and closing bracket (<div></div>)

Dam wished I would’ve known earlier.

Posted in Coding, Productivity | Tagged , | 2 Comments

MongoDB: importing dev data

My data exists in a file as a giant JSON array.
[ {DOC1},{DOC2},{DOC3} ]
I’m changing parameters and data as I develop so needed a way to import data that would also drop whatever data was in the collection already. And wa la:


mongoimport --jsonArray --collection [COLLECTION] --file [DATAFILE.JSON] --db [DBNAME] --drop

Understanding how to import MongoDB Date type data via json was hard to find too.
Easiest way to learn is to create a document in mongoDB with a Date type. Export it to a json file and then look at the result.
Commands:
mongoexport –db [DATABASE] –collection [COLLECTION] –out [FILENAME]

{
“name”: “test name”,
“birthdate”: { “$date” : -1051635600000 }
}

So if you creating a json file importing to MongoDB and want to make it a date type you have to make your document look the same. Took me awhile to figure that out. I’ve never used the date type before actually. If you migrating data from MySQL to MongoDB for example to convert MySQL date type to MongoDB via a PHP script you need to use

$date = array();
$temp = new MongoDate(strtotime([MYSQLDATEVALUE]));
$date['$date'] = $temp->sec * 1000;

*not sure why I have to multiple by 1000 but that is what i noticed when comparing dates from mongo and the strtotime(). Difference of 3 zeros. Probably doing something wrong but given up why.
that will return the secs time.

References:

Posted in MongoDB | Tagged , , , | Leave a comment

MongoDB: Query an Array of Documents

Felt that it wasn’t very apparent how to do to do a query of array of objects (documents). Maybe because I used the wrong terminology when searching. I searched an array of object as oppose to array of documents.

{
    "firstName": "joe",
    "lastName": "smith",
    "products": [
        {
            "title": "The Power of Habit",
            "isbn10": "081298160X"
        },
        {
            "title": "The Intelligent Investor",
            "isbn10": "0060555661"
        }
    ],
    "tags": [
        "investing",
        "habit"
    ]
}
{
    "firstName": "jane",
    "lastName": "doe",
    "products": [
        {
            "title": "Divergent",
            "isbn10": "9780062024039"
        },
        {
            "title": "Wonder",
            "isbn10": "9780375869020"
        }
    ],
    "tags": [
        "teen"
    ]
}

To search for tags

db.[COLLECTION].find( {[FIELD]: "[SEARCHTERM]"} )
db.users.find( {tags: "teen"} )

To search for product title:

db.[COLLECTION].find( {[OUTERFIELD]: { $elemMatch: { [INNERFIELD]: "[SEARCHTERM]" } } } )
db.users.find( {products: { $elemMatch: { title: "Divergent" } } } )

Regular expression search

db.[COLLECTION].find( {[OUTERFIELD]: { $elemMatch: { [INNERFIELD]: { $regex: '[SEARCHTERM]', $options: 'i' } } } } )
db.users.find( {products: { $elemMatch: { title: { $regex: 'int', $options: 'i' } } } } )

returns 1st document with Intelligent Investor as title

Try it out from command line:
mongo ds039507.mongolab.com:39507/wishlist -u mfcoding -p password
db.users.find( {tags: "teen"} )
db.users.find( {products: { $elemMatch: { title: "Divergent" } } } )
db.users.find( {products: { $elemMatch: { title: { $regex: 'int', $options: 'i' } } } } )

Posted in MongoDB | Tagged , , , , | Leave a comment