MediaWiki extension EmailDiff: notification emails improved
One of the nice things about MediaWiki is the ability to use
extensions to extend the core functionality in many ways. I’ve just released a
new version of an extension I wrote called EmailDiff that helps provide a much needed
function. When one is using a MediaWiki site, and a page is on your
watchlist—or your username is inside
the ‘UsersNotifiedOnAllChanges’ array—you will receive an email whenever a page
is changed. However, this email simply gives you the editor’s summary and states
“the page has been changed, here’s some links if you want to see exactly what”.
With the EmailDiff extension enabled, a full diff of what exactly has changed is sent
in the email itself. This is extremely valuable because you can quickly see exactly what has
changed, without leaving your email client to open a browser (and potentially have to login),
and without breaking your flow.
Normally, a MediaWiki notification email for a page change will look something like this:
Subject: MediaWiki page Project:Sandbox requirements has been changed by Zimmerman
Dear Turnstep,
The MediaWiki page Project:Sandbox requirements has been changed on
16 November 2015 by …mediawiki
Strict typing fun example — Free Monads in Haskell
From time to time I’ve got a chance to discuss different programming paradigms with colleagues. Very often I like steering the discussion into the programming languages realm as it’s something that interests me a lot.
Looking at the most popular languages list on GitHub, published last August, we can see that in the most popular five, we only have one that is “statically typed”. https://github.com/blog/2047-language-trends-on-github
The most popular languages on GitHub as of August 2015:
- JavaScript
- Java
- Ruby
- PHP
- Python
The dynamic typing approach gives great flexibility. It very often empowers teams to be more productive. There are use cases for static type systems I feel that many people are not aware of though. I view this post as an experiment. I’d like to present you with a pattern that’s being used in Haskell and Scala worlds (among others). The pattern is especially helpful in these contexts as both Haskell and Scala have extremely advanced type systems (comparing to e. g. Java or C++ and not to mention Ruby or Python).
My goal is not to explain in detail all the subtleties of the code I’m going to present. The learning curve for both languages can be pretty dramatic. The …
functional-programming haskell programming
Story telling with Cesium
Let me tell you about my own town
I was born in Yekaterinburg. It’s a middle-sized town in Russia.
Most likely you don’t know where it is. So let me show you:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Hello World!</title>
<script src="/cesium/Build/Cesium/Cesium.js"></script>
<link rel="stylesheet" href="layout.css"></link>
</head>
<body>
<div id="cesiumContainer"></div>
<script>
var viewer = new Cesium.Viewer('cesiumContainer');
(function(){
var ekb = viewer.entities.add({
name : 'Yekaterinburg',
// Lon, Lat coordinates
position : Cesium.Cartesian3.fromDegrees(60.6054, 56.8389),
// Styled geometry
point : {
pixelSize : 5,
color : Cesium.Color.RED
},
// Labeling
label : {
text : 'Yekaterinburg',
font : '16pt monospace',
style: Cesium.LabelStyle.FILL_AND_OUTLINE,
outlineWidth : 2,
verticalOrigin : Cesium.VerticalOrigin.BOTTOM, …angular cesium javascript kamelopard maps kml
Loading JSON Files Into PostgreSQL 9.5
In the previous posts I have described a simple database table for storing JSON values, and a way to unpack nested JSON attributes into simple database views. This time I will show how to write a very simple query (thanks to PostgreSQL 9.5) to load the JSON files
Here’s a simple Python script to load the database.
This script is made for PostgreSQL 9.4 (in fact it should work for 9.5 too, but is not using a nice new 9.5 feature described below).
#!/usr/bin/env python
import os
import sys
import logging
try:
import psycopg2 as pg
import psycopg2.extras
except:
print "Install psycopg2"
exit(123)
try:
import progressbar
except:
print "Install progressbar2"
exit(123)
import json
import logging
logger = logging.getLogger()
PG_CONN_STRING = "dbname='blogpost' port='5433'"
data_dir = "data"
dbconn = pg.connect(PG_CONN_STRING)
logger.info("Loading data from '{}'".format(data_dir))
cursor = dbconn.cursor()
counter = 0
empty_files = []
class ProgressInfo:
def __init__(self, dir):
files_no = 0
for root, dirs, files in os.walk(dir):
for file in files: …postgres
Converting JSON to PostgreSQL values, simply
In the previous post I showed a simple PostgreSQL table for storing JSON data. Let’s talk about making the JSON data easier to use.
One of the requirements was to store the JSON from the files unchanged. However using the JSON operators for deep attributes is a little bit unpleasant. In the example JSON there is attribute country inside metadata. To access this field, we need to write:
SELECT data->'metadata'->>'country' FROM stats_data;The native SQL version would rather look like:
SELECT country FROM stats;So let’s do something to be able to write the queries like this. We need to repack the data to have the nice SQL types, and hide all the nested JSON operators.
I’ve made a simple view for this:
CREATE VIEW stats AS
SELECT
id AS id,
created_at AS created_at,
to_timestamp((data->>'start_ts')::double precision) AS start_ts,
to_timestamp((data->>'end_ts')::double precision) AS end_ts,
tstzrange(
to_timestamp((data->>'start_ts')::double precision),
to_timestamp((data->>'end_ts' …postgres
Storing Statistics JSON Data in PostgreSQL
We have plenty of Liquid Galaxy systems, where we write statistical information in json files. This is quite a nice solution. However we end with a bunch of files on a bunch of machines.
Inside we have a structure like:
{
"end_ts": 1438630833,
"resets": [],
"metadata": {
"country": "USA",
"installation": "FIRST"
},
"sessions": [
{
"application": "first",
"end_ts": 1438629089,
"start_ts": 1438629058
},
{
"application": "second",
"end_ts": 1438629143,
"start_ts": 1438629123
},
{
"application": "third",
"end_ts": 1438629476,
"start_ts": 1438629236
}
],
"start_ts": 1438629033,
"status": "on"
}And the files are named like “{start_ts}.json”. The number of files is different on each system. For January we had from 11k to 17k files.
The fields in the json mean:
- start_ts/end_ts - timestamps for start/end …
postgres
Migrating to Devise in a Legacy Rails App
I’ve recently started working in a Rails 4 application that has accrued a lot of technical debt since it began life on Rails 1. To avoid spending the next few months tip-toeing around the code base, scared to bump something or step on a boobie-trapped brick, I pitched the client for a slice of budget to pay down some of that debt and write some tests. I got the thumbs up.
I decided to tackle the app’s home-grown user authentication. The encryption it was using wasn’t up to industry standards any more, and there were a few bugs with the flash messages it set. I went with the obvious choice of using the Devise gem and backed the whole thing with some simple integration tests using the Cucumber gem. I didn’t want to annoy the users by making them reset their password when we deployed, so I came up with a way to migrate users’ passwords with no manual intervention or interruption to their workflow.
I ran the Devise generator and trimmed down the generated migration to set up only the database_authenticatable module.
[phunk@work ]$ rails generate devise:install
# db/migrate/20160121005233_add_devise_to_users.rb
class AddDeviseToUsers < ActiveRecord::Migration
def self.up …rails ruby testing
Grammy Awards at Musica Russica
I was excited to learn this week about a Grammy Award recently awarded in connection with one of End Point’s valued customers, Musica Russica. Musica Russica is a specialized e-commerce website selling Russian choral sheet music as well as choral music recordings.
Last week’s Grammy-Award-winning (Best Choral Performance) recording by the Kansas City/Phoenix Chorales, conducted by Charles Bruffy, is featured at Musica Russica. Take a moment and listen to samples of Rachmaninoff’s All-Night Vigil.
This is the third Grammy award for best choral recordings won with music published by Musica Russica, adding to their awards from 2007 and 2015.
Musica Russica is the largest publisher of Russian choral music outside of Russia. Musica Russica’s business is built on a large collection of choral music which the founder, Dr. Vladimir Morosan, collected in his home country. Vladimir was passionate about this historical music and was concerned that it would not be properly preserved. In the 1980s he collected sheet music from libraries and churches in the former Soviet Union bringing the collection to the United States.
Not only did Vladimir collect music and develop a business to …
clients piggybak rails


