background preloader

Lukemista

Facebook Twitter

ImportError: No module named [projectname] - Google-ryhmät. Things I wish I knew about MongoDB a year ago. I’ve used MongoDB for over a year at scale at both Heyzap and Bugsnag and I’ve found it to be a very capable database. As with all databases, there are some gotchas, and here is a summary of the things I wish someone had told me earlier. Selective counts are slow even if indexed For example, when paginating a users feed of activity, you might see something like, In MongoDB this count can take orders of magnitude longer than you would expect. There is an open ticket and is currently slated for 2.4, so here’s hoping they’ll get it out. Until then you are left aggregating the data yourself. Inconsistent reads in replica sets When you start using replica sets to distribute your reads across a cluster, you can get yourself in a whole world of trouble. This is compounded if you have performance issues that cause the replication lag between a primary and its secondaries to increase to minutes or even hours in some cases.

Range queries are indexed differently Mongo’s BSON ID is awesome Profiler. Setting up authentication for MongoDB on Ubuntu with pymongo example · SkyFox/simplelogs Wiki. Situations when the application and the database server are on the same machine - very rare. By default MongoDB-authentication is disabled and you can not connect from outside. I could not find a concise and clear instructions about how to fix it. It was the reason for this post. We have: Ubuntu Server 12.04 LTS;MongoDB 2.2.3, working as a service;python-script (using pymongo).

Let's check where is config-file: user@ubuntu:/$ ps -ef | grep mongo mongodb 65042 1 0 Feb25 ? In my case it's in /etc/mongodb.conf. User@ubuntu:/$ netstat -a mongod allows connections only from localhost: tcp 0 0 localhost:27017 *:* LISTEN Edit mongodb.conf: uncomment auth = truecomment bind_ip = 127.0.0.1 Completed! User@ubuntu:/$ sudo service mongodb stop mongodb stop/waiting user@ubuntu:/$ sudo service mongodb start mongodb start/running, process 65404 Adding new user to DB: Let's check it from another computer. Result: I hope this article was useful for you. Sublime Text 3 for Python development · Piotr Banaszkiewicz. 24 Aug 2013 I’ve been heavy vim user for a couple of years. I had a very cool configuration, really got all these fancy vim key shortcuts muscle-memorized. But then vim plugins (bundles) started annoying me. Often my configuration became obsolete after an upgrade.

I had to go through documentation and set everything yet again. So I decided to give Sublime Text 2 a try, and then Sublime Text 3. And in August 2013 I switched almost completely. Why switch to Sublime Text 3? For me, these are the reasons: Sublime Text 3 is sooo pretty it’s also so freaking fast, way faster than Sublime Text 2 and has vast range of plugins, and easy configuration.

Not much, you say? Brief history Sublime Text 2 was using Python 2.x as an API interpreter. Since then, Sublime Text 3 (now beta build 3047 or bleeding edge dev build 3052) has come a long way and can be used by everyday programmer. What’s important is that many Sublime Text 2 plugins have been either ported or made Python2/3 compatible.

Configuration Theme. Gentle Introduction to MongoDB using Pymongo. Warning: This is a very old post so comments may not be valid anymore I use mongoDB along with Pymongo for personal projects only (I hope this changes in the near future though) and not very often to be honest. So this post is more of a quick reference for myself and I hope you guys finds it useful too. I am also writing this post in Ipython which I will convert to markdown using nbconvert utility and then push it to my github blog using Jekyll. Fingers crossed it won’t be too difficult. For this tutorial I’ll be using real data from Twitter using the Tweepy package. Before we start let’s see what Wikipedia has to say about MongoDB: “MongoDB (from “humongous”) is an open source document-oriented database system developed and supported by 10gen. 10gen began Development of MongoDB in October 2007.

Done - let’s start! Downloading & Installing MongoDB binaries Kick off the mongodb server: altons@asgard:~/projects$ cd mongodb altons@asgard:~/projects/mongodb$. if you something like: The config file. Getting Started with MongoDB – Part 1. Ready to get in and start learning about MongoDB, one of the coolest technologies for web developers? In this new series, you'll go from beginner to pro and be able to use Mongo just as easily as MySQL in your web apps. But first, let's look at the basics. Why MongoDB? What if you could store the programmatic models almost exactly like you model them?

In object-oriented development, we're encouraged to approach code development through logical models, so that we can more readily conceptualise it in our mind. When we do this, we're better able discern the logical operations used to interact with it and information that it would contain at different times. What if you could store the programmatic models almost exactly like you model them? In this series, we'll be learning everything from the basics of MongoDb, such as creating, updating and deleting databases and records, to being able to perform complex searches for data and elementary data mining with MapReduce. Step 1 : Installing Mongo.

Jon Combe | Code | PHPDate: a jQuery date formatting plugin. How to Center Anything With CSS. Recently, we took a dive into the very core concepts behind CSS layout and explored the differences between absolute and relative positioning. We’re going to follow that up with another CSS layout talk, this time based around a fundamental question that almost every new developer asks: how do you center something? There are a bunch of different types of web elements and layout situations, each calling for a unique solution for centering (both vertically and horizontally).

Today we’ll go over a bunch of these scenarios so you can wrap your mind around how they work and come away with the confidence to center anything! Who’s This For? I’ve gotten a lot of commenter feedback lately from designers who struggle with the basic methods and concepts of layout in CSS. The general consensus among many of those new to CSS is that they simply “fiddle” with the code until everything finally works.

Horizontally Center an Element Things To Keep In Mind Center An Absolutely Positioned Element Centering Text. How To Use Sublime Text For Live Preview of Code Snippets. A web developer may know better about what sublime text is actually capable of. So no need to discuss it here. The one things I kept searching for in Sublime Text or in any similar light weight program was the ability to show the result as soon as you type. But still unable to find it, so the only option left was to use online tools like JsFiddle or JsBin.

But what if we are offline? Alright! >> Run Sublime Text. >> Create a new file and paste this code in it. Import sublime_pluginclass SaveOnModifiedListener(sublime_plugin.EventListener): def on_modified(self, view): view.run_command("save") >> Save it as a .py (python) file. What it actually do is, it saves the file after every keystroke. >> Move this newly created file to, user folder in sublime text directory. C:\Program Files\Sublime Text\Data\Packages\User Installation directory and folder doesn't matter, it could be anywhere. >> Almost done. >> Link your css and javascript to your html file. >> Now to the last magic trick. The Essentials of Writing High Quality JavaScript. Twice a month, we revisit some of our readers’ favorite posts from throughout the history of Nettuts+.

This tutorial was first published in October, 2010. The brilliant Stoyan Stefanov, in promotion of his book, "JavaScript Patterns," was kind enough to contribute an excerpt of the book for our readers, which details the essentials of writing high quality JavaScript, such as avoiding globals, using single var declarations, pre-caching length in loops, following coding conventions, and more. This excerpt also includes some habits not necessarily related to the code itself, but more about the overall code creation process, including writing API documentation, conducting peer reviews, and running JSLint.

These habits and best practices can help you write better, more understandable, and maintainable code—code to be proud of (and be able to figure out) when revisiting it months and years down the road. Software bugs are costly to fix. Maintainable code means code that: Rove. Using Vagrant for repeatable local web development. For the moment, I’ve an idea of use of independent environments, which could be shared between our devs team, which works on Linux and Windows workstations. So, file ressources could be hosted on parent OS and virtual machine contains real development environment, and the logic is porcessed by the virtual machine, which contains the environment, identic to production server.

The dB is shared between all developers, but each developer has it’s own virtual environment, with files which are shared between guest and host. Web developer works in a folder which is shared between Vagrant and his host machine. The files are externalized from virtual machine. So the developer could use tools from main OS to get maximum comfort and productivity. Each developer machine could be accessed from an external location by a web browser. Each vagrant machine of each developer could be managed from an external location by SSH, to provide maximum of automation. VM machine creation and use. Todd Way. Easy local stack management with Vagrant I’m using Vagrant to hand-off complete copies of my local development environment to other members of my team. This is a great way to lower setup time, isolate dependencies and eliminate inconsistencies.

Frontend developers are able to work against a full local environment without wasting time on backend configuration. The following describes how Vagrant can make this possible without any additional provisioning tools. Those tools are powerful and offer even more efficiencies, but we’re leaving them out in the interest of simplicity. A sample environment On my MacBook Pro, I built a VM that runs the entire technology stack for a web application I’m currently working on called Jude. Vagrant, Chef, and the Drupal Vagrant project made most of this configuration automatic, but manual configuration would have worked just as well.

Sample workflow for spinning up a new VM copy Step 1: Package the source VM Step 2: Install the target VM vagrant up. Creating a Custom Vagrant Box from Scratch | Ryan Skoblenick. We begin by understanding what a “.box” file is. A Vagrant “.box” is simply a tarred gzip package containing, at minimum, the VM’s metafiles, disk image(s), and a metadata.json; which identifies the provider the box has been created for. Other optional supporting files, such as a custom Vagrantfile, can be packaged with the box if desired. Sanity check A quick sanity test. The instructions have been generalized and should work with most Hosts and Guests of a similar configuration. Only the below have been tested. So no guarantees explicit or implied. Our Host This article assumes an OS X development environment. Apple OS X Mountain Lion (10.7.5)VirtualBox 4.2.12VMware Fusion 5.0.4Vagrant 1.2.2Vagrant’s VMware Fusion provider 0.6.3 with a valid license.

Potential Guests All tested Guests are 64-bit distributions of Linux. CentOS 6.4Debian 7.0Scientific Linux 6.4Ubuntu 12.10 DesktopUbuntu 12.10 Server Create the Virtual Machine Modify the VM’s settings: Customize the VM’s settings: $ su - $ visudo. A Good Windows Development Environment and Ubuntu Virtualbox | Simon Holywell - Web developer in Brighton. Sun VirtualBox Logo Often Linux just does it better! Often I find myself developing a Windows machine without access to a Linux development server, but I still need to access to some of the Linux binaries and features such as cron jobs, the at command and binaries such as imagemagick, pdftotext, etc.

Some things can be emulated with ported binaries or through Cygwin, but I feel a lot more comfortable developing on a platform that is representative of the live server the web site will run on. I have not removed XAMPP as it is very useful for developing small scripts or sites without the overhead of running a virtual machine.

Therein lies the problem with this solution – it is virtual machine based and that will mean your local development machine will suffer when the virtual machine steals computing time from the CPU or more memory. So whilst I can use XAMPP on my netbook I am not so sure a VM will run smoothly. Setting up a new development environment Configuring our web server For example: Installing Python Pyramid with Apache2 on Ubuntu 11.04. Here's what I have done so far. I have set up Ubuntu 11.04 server in Virtual Box. I enabled OpenSSH and LAMP server during installation.

Nothing else. Now, I want to try out Python Pyramid framework. I will show you the steps I have taken. 1. Install build tools $ sudo apt-get update $ sudo apt-get upgrade $ sudo apt-get install build-essential 2.Install mod_wsgi $ sudo apt-get install libapache2-mod-wsgi 3. . $ sudo apt-get install python-setuptools 4. . $ sudo easy_install virtualenv 5. . $ cd /home/hiro 5. . $ virtualenv --no-site-packages env 6.

. $ cd env $ . 7. . $ . $ .. 8. . $ cd /home/hiro/env $ vi pyramid.wsgi Here is what you need to write from pyramid.paster import get_app application = get_app( '/home/hiro/env/myapp/production.ini', 'main') 9. Chmod 755 pyramid.wsgi 10. $sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/pyramid $sudo vi /etc/apache2/sites-available/pyramid Here is my pyramid file 11. . $ sudo a2ensite pyramid $ sudo a2dissite default $sudo /etc/init.d/apache2 restart. Intro to the Python Framework Pyramid — Six Feet Up, Inc. We prefer Pyramid to Django, Flask, and Bottle due to its flexibility, scalability and speed. It gives us more control than Django and is easy to create a small app that can scale later without being rewritten.

These are many of the same reasons for Why We Choose Python in general. Recently we provided some training on how Pyramid works that was recorded. It provides a great overview of why Pyramid is ideal and how to setup a basic app with scaffolds, routes, and persistence. We also built a ToDo App for a web shootout we organized in Indianapolis through IndyPy. To get a good understanding of the Pyramid framework and see how to implement a basic ToDo app from scratch: Watch our Intro to Pyramid video below (21 min)Play with the ToDo app demo at the step by step instructions in the ToDo app README.md at the official documentation and tutorials at.

How To Use the Pyramid Framework To Build Your Python Web App on Ubuntu. Introduction Web frameworks provide a quick and easy way to jump start a web application. Almost every web framework adheres to the MVC software pattern. MVC stands for model, view, and controller. It is a way of distinguishing and separating the different functions of an application to simplify its design and allow each piece to be changed independently of the other components. Pyramid is a lightweight web framework for Python applications. It allows you to get a basic web application up and running quickly. In this guide, we will introduce you to how to set up Pyramid on your Ubuntu system. Install the Prerequisite Tools Before you begin, you must have some prerequisite packages installed. We will be using Python 3 in this guide. Either way, you should run the following command to install the development header files needed by some Pyramid extensions. Sudo apt-get update sudo apt-get install python3-dev python3-setuptools We will also need the virtualenv package.

Source env/bin/activate. Ryhmät. How To Use the Pyramid Framework To Build Your Python Web App on Ubuntu. Why you (maybe) got denied from BizSpark. Condemil/Gist. Home · kemayo/sublime-text-git Wiki. Getting Started – Git-Flow | Some thoughts, ideas and fun!!! Development Environments the Right Way with Vagrant and Puppet | Andrew Munsell. DevOps - Sovelluskehittäjän roolin evoluutio » Gofore. Palkkaa halauksista « Joonas Kiminki. Vagrant. About Docker - Docker: the Linux container engine.