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
Building an e-commerce Website
If you are considering starting out your own e-commerce business, this article is dedicated to you.
After working with clients on multiple different projects—including e-commerce sites—I know that there are aspects that new owners are not aware of before they dive deep. There isn’t as much written about the problems and failures web store owners had before they learnt. This means that one has to learn it all the hard way—very often soon after their development team has already put a lot of work into the e-commerce site.
With this article I’d like to save you some of the hassle and money and present you with a small introduction of what to expect.
Preparations
Apart from thinking about the budget, kinds of products, warehouses etc. you’ll most probably want to know how to put it all out there for the public to see. You’ve seen other web stores and intuition may tell you that you just need a “website” with some backend functionality to manage products and see the orders. You may have heard about some “free” stacks you could use or some online hassle-free platforms where you could just pay monthly and have your web store in almost no time.
All this is to some extent true—but in …
ecommerce
Creating Composite Docker Containers with Docker Compose
Composite Docker Containers
Docker is an application container system which allows logical isolation and automation of software components into isolated instances similar in some ways to a virtual server. This model is quite powerful for creating new instances of a given application rapidly, and creating automated system stacks from high-availability to high-performance clusters. Even though there is no technical limitation, the idea behind this model is that these containers should be in a 1:1 relationship with each application component. If you deploy a Docker image for Apache Tomcat, the container will contain Tomcat, and only Tomcat and its core dependencies. If you needed a Tomcat application server, and a PostgreSQL database to go with that application server; in general you would need to create two separate containers, one with the Tomcat image and the other with the PostgreSQL image. This can lead to an undesirable situation with complexity where you must manage both containers separately, even though they are both part of the same stack. In order to solve this problem, recently the Docker team developed Docker Compose to allow these complex applications to all live inside …
containers docker sysadmin

