Making async http requests with python-aiohttp

In this post I’d like to test limits of python aiohttp and check its performance in terms of requests per minute. Everyone knows that asynchronous code performs better when applied to network operations, but it’s still interesting to check this assumption and understand how exactly it is better and why it’s is better. I’m going … Continue reading Making async http requests with python-aiohttp

Embracing Change: Rails 5.1 Adopts Yarn, Webpack, and the JS Ecosystem

For many years, Ruby on Rails has been the go-to framework for startups, micropreneurs, SMBs, and really for anyone who needed to build and launch a tool quickly. With its opinionated, convention over configuration approach, and Heroku’s brilliant git push to deploy feature, Ruby on Rails made every other solution look barbaric by comparison. But … Continue reading Embracing Change: Rails 5.1 Adopts Yarn, Webpack, and the JS Ecosystem

A short summary of centrality in graph theory

A short summary of mathematics of networks (in particular, centrality). In graph theory and network analysis, indicators of centrality identify the most important vertices within a graph. Applications include identifying the most influential person(s) in a social network, key infrastructure nodes in the Internet or urban networks, and super-spreaders of disease. Centrality concepts were first … Continue reading A short summary of centrality in graph theory

How to rename all files in a folder using Python

let's assume the folder is user_data, relative to the current working directory (where the Python script is in). The code below was tested on Windows. import os for filename in os.listdir("./user_data"):     # print(filename)     cwd = os.path.dirname(os.path.abspath(__file__)) + '\\user_data\\'     if filename.split('.')[1] == 'jpg':         new_filename = filename.split('.')[0] + '_search' + '.jpg'         print(new_filename) … Continue reading How to rename all files in a folder using Python

define_method in Ruby

define_method is a (private) method of the object Class. You are calling it from an instance. define_method(:my_method) do |foo, bar| # or even |*args| # do something end or, you could even use string interpolation in the method name, such as define_method("#{attribute}=") do |unencrypted_password| if unencrypted_password.nil? self.send("#{attribute}_digest=", nil) elsif !unencrypted_password.empty? instance_variable_set("@#{attribute}", unencrypted_password) cost = ActiveModel::SecurePassword.min_cost … Continue reading define_method in Ruby

new update about has_secure_password in Rails 5.2

has_secure_password takes an attribute For many years has_secure_password only allowed a default password attribute. But now you can stash whatever you want in there. Source code Allows configurable attribute name for #has_secure_password. This still defaults to an attribute named 'password', causing no breaking change. Also includes a convenience method #<strong><span style="color:#008000;">regenerate_XXX</span></strong> where +XXX+ is the name … Continue reading new update about has_secure_password in Rails 5.2