Solving mongodb's user creation problem

I have been test driving mongodb with some serious projects. I have always had difficulty in creating users in any database. Mongodb was no surprise.Here is the working command for me. Error 2016-02-16T01:28:27.570+0000 Error: couldn’t add user: User “[email protected]” already exists at src/mongo/shell/db.js:1004 First add the user: mongo localhost:12346> use admin> db.createUser({ user: "test1", pwd: "test", roles:[ { role: "readWrite", db: "isimibul-dev" }]}) Now connect by using the user:mongo localhost:12346/mydb-dev -u test1 -p testOne side note: If you are having difficulties with connecting to the DB, you can change auth mechanism to MONGODB-CR, this is the old system used back in the days of v2.4; now SHA is used for auth, if you are using an updated version like v3, just use SHA as auth mechanism.

Python regular expression '-' specialness

note to selfUse - instead of - in python regular expressions$ pythonimport’([-\w]*)’, ‘www.hakanu-net’)

Solving Google App Engine users API problem - raise NotAllowedError

Error thrown: <class 'google.appengine.api.users.NotAllowedError'>: Traceback (most recent call last): File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/", line 324, in <module> main() File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/", line 320, in main util.run_bare_wsgi_app(app) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/", line 116, in run_bare_wsgi_app result = application(env, _start_response) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/appstats/", line 308, in __call__ users.create_login_url(os.getenv('PATH_INFO', '')))]) File "/base/python_runtime/python_lib/versions/1/google/appengine/api/", line 256, in create_login_url raise NotAllowedErrorCode:from google.appengine.api import usersself.redirect(users.create_login_url(self.request.uri))Steps to solve: Go to

Solving mongodb auth problem - pymongo.errors.OperationFailure auth failed

Error thrown:pymongo.errors.OperationFailure: command SON([('authenticate', 1), ('user', u'root'), ('nonce', u''), ('key', u'')]) failed: auth failedSteps to solve: If using global pymongo, update it. sudo pip install pymongo --upgrade If using pymongo from lib folder Fix the version in requirements.txt, as of today, latest version is 3.0.3, you can check it out from here. pymongo==3.0.3 Upgrade the packages: sudo pip install -r requirements.txt -t lib/ --upgrade Redeploy. This will hopefully fix your heroku and Google App Engine deployment with pymongo.

Solving Sqlite's python Unicode string problem with non UTF8 data

Error it throws:sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.Solution was easy; add this line for assigning text_factory. It converts strings into unicode objects.conn = GetSqliteConnection(db_path)conn.text_factory = lambda x: unicode(x, 'utf-8', 'ignore')Thanks to SO again. (PS that post is extremely useful for python encoding/decoding.)


Yet another problem that made me lose 3-4 hours.Well, I usually use the same code across my application, I have my basic scaffolding. It only gets better in time. However, sometimes I forget to change the package names, XML namespace definitions etc while copy/pasting. I thought this is also same problem. But I couldn’t find anything.Surprisingly, this occurs after you submit the application to the play store.While application X is installed, Google Play Store does not let another application with the same provider to get installed.Error it throws:"Some application" can not be installed. Try again, and if the problem continues, get help troubleshooting. (Error code: -505)Troubleshooting did not help me, in product forums they only recommended cleaning up cache of google play store app etc. But this problem is not related to neither your phone nor your play store application. It persists in different operating systems and different phone models. What you need to do is simple, follow...

Solving Disqus comment problem on Jekyll - same comments everywhere

I have been using Disqus in order to handle blog comments for a long time. I was also using it when I was with Ghost. It’s a great and good looking way to handle comments. It makes your blog more mobile. It has one downside which is that the comment box is iframe so I don’t think it’s good for SEO.Disqus’s own help center: Why are the same comments showing up on multiple pages? JavaScript configuration variables With this light here is my disqus snippet in my jekyll code:<div id="disqus_thread"></div><script type="text/rocketscript"> var disqus_shortname = 'YOUR_USERNAME'; var disqus_identifier = '/jekyll/2015/08/24/jekyll-disqus-same-comment-everywhere/'; var disqus_url = '\{\{ site.url \}\}\{\{ page.url \}\}'; var disqus_title = '\{\{ page.title \}\}'; var disqus_category_id = '\{\{ post.category \}\}';Trick is assigning a unique identifier to the disqus_identifier javascript variable. In our case page.url is pretty unique. And also we are not s...

PgAdmin in my face - Ubuntu Bug (or maybe feature?)

Today, PgAdmin is frozen as usual. I’m not blaming it of course, it’s because my Rasberry Pis are so slow, they can not handle some broad SQL queries after some point they become responseless and PgAdmin becomes frozen.Today it happened again; so normal up until now; I went to the Task Manager of Ubuntu to kill that bad boy but see what I saw:IN YOUR FACE

Solving Android "java.lang.NoClassDefFoundError attr" for pre-Lollipop devices

This secret recipe makes your apps work on pre-lollipop devices. You may be developing on Android 5.0+ and you would not realize that your app is breaking at the start for other versions of Android which are lower than Lollipop.Trick is that Apps with lots of dependencies (well they don’t have to a lot but if you have google play services as dependency which is needed for admob, you should apply this method) need multidex enabled for building. Otherwise they work fine on L devices and fails at the startup for pre-L devices.[Android Twitter Crashes with Appcompat v7 on API 19 and lower] Apps with Over 65K Methods am I still getting java.lang.NoClassDefFoundError:

Migrated my blog from Ghost to Github pages

Thanks to heroku beta pricing. mkdir blog cd blog git init sudo gem install jekyll sudo gem install github-pages sudo gem install bundlerFor development, live refresh etc sudo gem install pygments.rb sudo gem install listenCreate the project jekyll new . jekyll build --watch # Auto reload. Go to http://localhost:4000Import posts from self hosted Ghost blog Go to Export json file with all of your posts. sudo gem install jekyll_ghost_importer jekyll_ghost_importer GhostBackup.json # This will create _posts folder and _draft folder.Play with the settings vim _config.yml permalink: pretty paginate: 10 paginate_path: "/page/page:num/"Add paginationI have ~400 posts so need to paginate in order to show in the main page.Used this recepi: To create a new post you can use github’s UI and preview mode which is cool but not as cool as Ghost of course.

subscribe via RSS