node-mongodb-native example code vs docs code? which to use? - mongodb

I just wrote my first nodejs program using the node-mongodb-native driver. I used the documentation code from the github page, i.e.:
var mongodb = require("mongodb"),
mongoserver = new mongodb.Server('localhost', 6574),
dbConnector = new mongodb.Db('test', mongoserver);
dbConnector.open(function(err, db){
if(err)
console.log('oh shit! connector.open error!');
else{
...
However, upon looking at some example code on the github page, I discovered that the set up code looks very different from what I used. Does anybody know if there's any real difference between the different methods? I'm completely new to all this stuff and can't really tell if there's any reason to use one over the other. The code I wrote seems to run fine, but if the creator of the driver is using different code, I figured it would be worth checking if there are any reasons for that.
Thanks in advance for any replies!
Sami

Hi I'm the creator and no there is no particular reason you can't use your style. As when it comes to docs I usually tell people to start with the integration tests as there are many examples on how to do stuff. Unfortunately due to having a fulltime job the docs are not kept up to date at the pace I would like to.
I'm hoping to do something with that come late september but right now I'm trying to just get the driver up to the expected features of mongodb including making it work with 1.9.X and higher.
I'll accept any docs pull requests happily as the more the community help me the more it helps itself :)

Related

iTextSharp and ZUGFeRD Basic profile

I am creating ZUGFeRD PDF files with iTextSharp 5.5.9 which works fine so far. The only thing which is currently not working is the setting with the Conformance-Level.
writer = PdfAWriter.GetInstance(document, New FileStream(strFilenameOut, FileMode.Create), PdfAConformanceLevel.ZUGFeRDBasic)
or
writer.SetPDFXConformance(PdfAConformanceLevel.ZUGFeRDBasic)
won't work for me. The Metadata contains %s instead of BASIC as shown in the screenshot below.
I guess that I missed something to set. Maybe someone had the same issue and can help me to solve this issue.
Regards
Jochen
ZUGFeRD is based on the PDF/A-3 standard. You are using a method to set PDF/X conformance. PDF/A and PDF/X are two very different standards. You shouldn't set the PDF/X conformance.
Please take a look at the official documentation. I have written a book about ZUGFeRD. You can download this book as an eBook if you fill out this form: http://pages.itextpdf.com/ZUGFeRD.html
For the Basic profile, you need to take a look at Chapter 5. There are many examples available online.
This is how it's done in Java:
PdfAWriter writer = PdfAWriter.getInstance(document,
new FileOutputStream(dest), PdfAConformanceLevel.ZUGFeRDBasic);
In C#, you'll have:
PdfAWriter writer = PdfAWriter.GetInstance(document,
New FileStream(strFilenameOut, FileMode.Create), PdfAConformanceLevel.ZUGFeRDBasic)
All the examples work in Java, but recently there was a problem detected with the C# port. Maybe you are experiencing the same problem. As far as I know, this problem has been fixed in the current development version.
If you are a customer, you should ask your account manager to get a hotfix that solves this problem.

RESTFUL API : new Iron Router version this.request.body not working anymore

I had my API fully functional and everything was working like a charm but with the last updates of Iron Router (Meteor update could impact?) my command
this.request.body
doesn't render nothing when I have a POST call on my API (all calls work good and I have no problem with GET this.params), I took a look at the docs and I don't see nothing talking about this, does anyone have an idea?
Thanks for your help =)
PS : I tried to replace it (without success obviously) by :
this.params.query.body
this.request.query.body
When I try to do a JSON.stringify on this.request it is empty so I guess it has been moved somewhere...
As asked here https://github.com/EventedMind/iron-router/issues/1003, just add:
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({extended: false}))
in your Meteor.startup

ZF2 Album tutorial using stored procedures

Please also suggest which namespace to use. I am new to zend and MVC.
module.php
public function getServiceConfig()
{
// what code here?
}
**Album\Model\Album.php**
{
//what code here?
}
**Album\Model\AlbumTable.php**
{
//what code here?
//do we have to use this class or a different class?
}
I can understand the sudden confusion when starting out with ZF2. However, the manual has really done a good job at helping those who are just starting out. You can find the most up-to-date information here : http://zf2.readthedocs.org/en/latest/user-guide/overview.html
Once you've got the Skeleton Application working I believe some of your confusion will be relieved. If not, come back and ask more specific questions OR you could even join the FreeNode IRC channel at #zftalk.
But to also help answer some of what you've asked here:
getServiceConfig() is where you will interact with the ServiceManager. Try to stay away from closures and work with Factories.
Album.php is sort of like the Hydrator. You don't have to use a Hydrator but for example purposes it was put here. It can make like easier in the long run.
AlbumTable.php is the Database Table you will be interacting with.
The namespace which is used in the tutorial is called Album. The Skeleton application comes packaged with a namespace called Application to start with.
You can manually download ZF2 here: https://packages.zendframework.com/
The latest skeleton application can be found here: https://github.com/zendframework/ZendSkeletonApplication
You may also choose to use Composer to install your entire application which tends to make the installation process much easier for those just starting out, so in your situation I'm going to recommend you use that. You can find instructions on how to use Composer here: http://zf2.readthedocs.org/en/latest/user-guide/skeleton-application.html

Collecting GitHub project issues statistics programmatically?

I'm collecting GitHub issue statistics over time on our project: total number of issues, number of issues with a particular label, number of issues in a given state (open/closed). Right now, I have a Python script to parse the project webpage with the desired labeling/state for the info I want, e.g., http://github.com/<projectname>/issues?label=<label_of_interest>&state=<state_of_interest>
However, parsing the HTML is fragile since if the GitHub API changes, more often than not, my code fails.
Does someone describe how to use the GitHub API (or barring that, know of some other way, preferably in Python) to collect these statistics without relying on the underlying HTML?
May I be so forward as to suggest that you use my wrapper around the GitHub API for this? With github3.py, you can do the following:
import github3
github = github3.login("braymp", "braymp's super secret password")
repo = github.repository("owner", "reponame")
open_issues = [i for i in repo.iter_issues()]
closed_issues = [i for i in repo.iter_issues(state='closed')]
A call to refresh may be necessary because I don't honestly recall if GitHub sends all of the issue information upon the iteration like that (e.g., replace i.refresh() for i in <generator> as the body of the list comprehensions above).
With those, you can iterate over the two lists and you will be able to use the labels attribute on each issue to figure out which labels are on an issue. If you decide to merge the two lists, you can always check the status of the issue with the is_closed method.
I suspect the actual statistics you can do yourself. :)
The documentation for github3.py can be found on ReadTheDocs and you'll be particularly interested in Issue and Repository objects.
You can also ask further questions about github3.py by adding the tag for it in your StackOverflow question.
Cheers!
I'd take a look at Octokit. Which doesn't support Python currently, but does provide a supported interface to the GitHub API for Ruby.
https://github.com/blog/1517-introducing-octokit
Although this doesn't fully meet your specifications (the "preferably Python" part), Octokit is a fantastic (and official - it's developed by GitHub) way of interacting with the GitHub API. You wrote you'd like to get Issues data. It's as easy as installing, requiring the library, and getting the data (no need for authentication if the project is public).
Install:
gem install octokit
Add this to your Ruby file to require the Octokit library:
require 'octokit'
Although there are a lot of things you can get from Octokit::Client::Issues, you may want to get a paginated list of all the issues in a repository:
Octokit.list_issues('octokit/octokit.rb')
# => [Array<Sawyer::Resource>] A list of issues for a repository.
If you're really keen on using Python, you might want to have a look at the GitHub API docs for Issues. Really, it's as easy as getting a URL like: https://api.github.com/repos/octokit/octokit.rb/issues and get the JSON data (although I'm not familiar with Python, I'm sure these some JSON parsing library); no need for authentication for public repos.

Programs and downloads for a serverside mongo-dart DB

I have been programming with dart for a while now and after I tried LocalStorage, I wanted to start with a server-side mongo-dart app. So my question is:
What do I need as far as programs and downloads beside the Darteditor and Chromium?
I would be very happy about an answer.
Thanks in advance!
Karl
There is no official MongoDB driver for Dart language mentiond on MongoDB site http://docs.mongodb.org/ecosystem/drivers/.
However you can find a driver on GitHub by vadimtsushko:
https://github.com/vadimtsushko/mongo_dart
He also wrote tutorial http://blog.dartwatch.com/2012/03/building-client-server-dart-app-part-2.html
Hope it gives you something to start with.
Here is a blog post I wrote awhile back that does a full stack example using mongodb and dart
http://financecoding.github.com/blog/2013/01/16/darting-a-full-stack/
The server side is still light, I'd suggest experimenting stream from rikulo http://rikulo.org/projects/stream Might be a cleaner solution then rolling your own web server.
Have fun!