Packages are a way of structuring Python’s module namespace by using “dotted module names”. For example, the module name A.B designates a submodule named B in a package named A. Just like the use of modules saves the authors of different modules from having to worry about each other’s global variable names, the use of … Continue reading Python packages and the purpose of __init__.py file
Computing
Redis Quick Start on ubuntu
Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of … Continue reading Redis Quick Start on ubuntu
Active Record Validations
Creating and saving a new record will send an SQL INSERT operation to the database. Updating an existing record will send an SQL UPDATE operation instead. Validations are typically run before these commands are sent to the database. If any validations fail, the object will be marked as invalid and Active Record will not perform … Continue reading Active Record Validations
Real-Time Rails: Implementing WebSockets in Rails 5 with Action Cable
Recent years have seen the rise of "the real-time web." Web apps we use every day rely on real-time features—the sort of features that let you see new posts magically appearing at the top of your feeds without having to lift a finger. While we may take those features for granted, they represent a significant … Continue reading Real-Time Rails: Implementing WebSockets in Rails 5 with Action Cable
Install PostgreSQL on ubuntu
Introduction PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license.[1] PostgreSQL contains many advanced features, is very fast and standards compliant. PostgreSQL has bindings for many programming languages such as C, C++, Python, Java, PHP, Ruby... It can be used to power anything from simple web applications to massive databases … Continue reading Install PostgreSQL on ubuntu
helper_method in Rails
The method helper_method is to explicitly share some methods defined in the controller to make them available for the view. This is used for any method that you need to access from both controllers and helpers/views (standard helper methods are not available in controllers). e.g. common use case: #application_controller.rb def current_user @current_user ||= User.find_by_id!(session[:user_id]) end … Continue reading helper_method in Rails
an OCR Engine in JavaScript
Tesseract.js is a javascript library that gets words in almost any language out of images. Below is an example tested with Node.js (local file system). Note that your will need to download the trained language data for the language here. Unzip the file and put it somewhere in your solution. Then the call to Tesseract … Continue reading an OCR Engine in JavaScript
Why use Bower when there is npm?
In almost all cases, it's more appropriate to use Browserify and npm over Bower. It is simply a better packaging solution for front-end apps than Bower is. At Spotify, we use npm to package entire web modules (html, css, js) and it works very well. Bower brands itself as the package manager for the web. … Continue reading Why use Bower when there is npm?
Sublime Text reindent, autoindent, and autocomplete
You can find it in Edit>>Line>>Reindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu Preferences - Keybindings-User, then add there (the config file takes as a JSON format): [ { "keys": ["f12"], "command": "reindent"} ] (example of using the F12 key for that functionality) … Continue reading Sublime Text reindent, autoindent, and autocomplete
Getting Started with Node.js for the Rails Developer
Introduction In this article we are going to do a quick introduction to Node.js for Ruby on Rails minded developers. From Ruby to Node You’ve likely heard in the past few months that some big companies are starting to deploy Node applications in production and at scale. Walmart is running their entire mobile site on Node, … Continue reading Getting Started with Node.js for the Rails Developer