Κυλλήνη

InterPals missing chats conjurer add-on

InterPals Missing Chats Conjurer I’ve been using Interpals for a couple of years now (as a website, not mobile app) and I must admit it’s been pretty useful, yet full of annoying bugs and glitches. One of the most irritating was never disappearing +1 notification. Other users also complained about it.

Eventually, I wrote this plugin, that is available for Firefox and Chrome to mitigate the problem. So if you are facing the same issue, I encourage you to try it.

Disclaimer: This is an NOT an official InterPals software.

Read more →

DIY quantum random number generator, part2

So after nine long years the time has come for part two. Speaking of procrastination, huh.

This is a report on this project I’ve been working on as well as my cheat sheet for related utilities, so it won’t be brief or particularly clear, sorry.

I’ve been doing some research on this topic, and I found, to my surprise, that such devices can actually be called quantum RNGs! So I will be calling it exclusively ‘quantum’ from now on, mwahaha!

For years, I wanted to measure the output of this device and get some actual numbers from it. Therefore, the goal this time is to write some code for data gathering and analysis. It would be really nice to understand how much data the device in question might generate, find out data distributions, data patterns, and so on and so forth. Generated random sequences will be fed to ent and dieharder test suites for verification.

Read more →

Vacuuming Postgres database with a little disk space left

When you are low on disk space, the regular --all --full vacuuming might fail. It is worth trying to free up space gradually.

Order by table size:

#!/bin/sh
DATABASE=mydatabasename

psql -tc "SELECT concat(table_schema, '.', table_name) FROM (SELECT nspname AS table_schema, relname AS table_name, pg_total_relation_size(c.oid) AS total_bytes FROM pg_class c LEFT JOIN pg_namespace n ON n.oid = c.relnamespace WHERE relkind = 'r') as sq ORDER BY total_bytes;" "${DATABASE}" | grep -v -e '^$' | while read tblname; do vacuumdb --full -e -j1 -d "${DATABASE}" -v -z -t "${tblname}"; done

Or order by the amount of dead tuples:

#!/bin/sh
DATABASE=mydatabasename

psql -tc 'SELECT ObjectName FROM (SELECT relname AS ObjectName ,pg_stat_get_live_tuples(c.oid) AS LiveTuples ,pg_stat_get_dead_tuples(c.oid) AS DeadTuples FROM pg_class c order by 3) as sq;' "${DATABASE}" postgres | while read tblname; do vacuumdb --full -e -j1 -d "${DATABASE}" -v -z -t "${tblname}"; done
Read more →

Hate OS

Got fed up with Windows

  • Almost impossible to move user home dir. Not recommended by vendor.
  • Some software installs wherever it wants to (right now it’s SteelSeries Engine being installed to C: in spite of lack of space there and a 2TB D: drive present in the system).
  • No native workspace switcher.
  • No native support for software RAID (in Ultimate only, with limited functionality).
  • Forces you to use remote login if you want to upgrade hardware.
  • Multiple concurrent user sessions — impossible.
  • Locally bought but with English interface — Ultimate only.
Read more →

Speed up integration tests 10 times: MySQL on ramdisk, Windows development rig

For the most part, tests in the project I’m currently participating in are end-to-end integration tests; therefore, the database is being repeatedly accessed causing high disk I/O, which eventually becomes a bottleneck. Multiple improvement options had been suggested and discussed by the team prior to picking a final solution:

  • Rewrite all tests so that actual writing/reading would be tested only for StorageService. We’d need to mock large amounts of data for other tests. Time consuming, tough, but seems to be the most correct way.
  • Use ENGINE = MEMORY in database. I’ve experimented with this option for some time, and it turned out to have some pitfalls: replacing the engine for the testing environment only, but keeping the production environment intact was a non-trivial task in this project because of the limitations introduced by architecture. A lot of tests were broken (presumably because MEMORY engine does not support transactions). MEMORY cannot store text and blob fields that are used in some tables.
  • A quick end easy option: use a database entirely stored in memory, since persistence is not really critical for tests. Pros: execution time reduces from 25-40 minutes to 3 minutes. The database engine remains unchanged; therefore the database behavior corresponds to the production environment. Cons: It’s necessary to install drivers and set up configs (a one-time task, but must be repeated for each workplace). A developer also has to keep in mind that he needs to switch between MySQL configurations before, and after, the tests (each time). Load tests might start giving unexpected results, as the performance would be affected. Finally, it is a kludge.
  • Repeatedly delete and re-create data creating snapshots in-between the tests.

The imdisk mentioned above has a few more drawbacks: one should remember all the other software that shares the same MySQL instance or run it as a second instance bounded to another port, but it would require altering the configs.

Read more →

Java, custom annotation, AspectJ, Maven: minimalist example

Goal: some code must be executed before/after a method annotated with custom annotation. We need a custom annotation first:

package yourpackage;
 
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
 
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface MyCustomAnnotation {
    public boolean isRun() default true;
}

An aspect:

package yourpackage;
 
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
 
@Aspect
public class MyCustomAspect {
    @Before("execution(* *.*(..)) && @annotation(MyCustomAnnotation)")
    public void advice(JoinPoint joinPoint) {
        System.out.printf("BINGO! advice() called before '%s'%n", joinPoint);
    }
}
Read more →

Dummy SMTP server

Решение автора JOTN, отсюда

#!/usr/bin/perl -w
use Net::SMTP::Server;
use Net::SMTP::Server::Client;

$server = new Net::SMTP::Server('localhost', 25) || die("$!\n");

while($conn = $server->accept()) {
	my $client = new Net::SMTP::Server::Client($conn) ||
	die("Unable to handle client connection: $!\n");
	$client->process || next;

	# Here's where you can write it out or just dump it. Set $filename to
	# where you want to write it
	$filename = './collected_mail.txt';
	open(MAIL,">> $filename") || die "$filename: $1";
	print(MAIL "$client->{MSG}\n");
	close(MAIL);
}

/etc/ssmtp/ssmtp.conf:

root=postmaster
mailhub=localhost
#rewriteDomain=
hostname=localhost
FromLineOverride=YES

Под Ubuntu необходимые пакеты называются libnet-smtp-server-perl и ssmtp.

Read more →

A1185, A1322: inside a MacBook battery

Батарейка/аккумулятор MacBook A1185 внутри Образовалась у меня парочка вздувшихся и непригодных более к применению аккумуляторов от MacBook (совсем старого и просто старого — модели 2005 и 2010 годов). Выдачи поисковиков на запросы, аналогичные «батарейка MacBook внутри» и «разобранный аккумулятор MacBook», оказались весьма скудны. Естественно, разбирать аккумуляторы крайне не рекомендуется, но любопытство зашкаливало. Фото под катом.

Read more →

Repost: Сказка о криворуких ебланах

Каждый вечер, когда солнце прячется за верхушки сосен, на небе зажигаются звезды, а где-то в лесу неподалеку начинает ухать сова, которую мы уже два месяца не можем поймать, чтобы сварить из нее суп, – так вот: каждый раз, когда на нашу свалку опускается темнота, вся детвора собирается вокруг ржавого чайника в пустой нефтяной цистерне на западной окраине, чтобы попить кипятка, съесть по кусочку сахара и послушать сказку на ночь.

Урчит, закипая, чайник. Ухает сова. Восемь носов выжидательно пошмыгивают. Восемь пар глаз внимательно следят за мной.

Read more →

Быстрый генератор случайных имён-фамилий для базы данных

Относительно быстрый генератор псевдослучайного списка имён-фамилий и рандомных данных в базу. Фокус заключается в записи группы сгенерированных данных сперва во временную таблицу в памяти, потом блокировке основной таблицы и переносе данных туда из временной, после чего блокировка снимается, а цикл повторяется необходимое количество раз.

Read more →

Зелёный слоник

(Стук в дверь) — Войдите!
— Товарищ капитан, звали?
— Вызывал! Прибыли тут двое.
— Оформить?
— Оформить как надо.
— Понял.
— Понял?
— Да.
— Ну давай, свободен!
— Фуф.
— Слушай, а… сколько сейчас времени, ты не знаешь? Так, примерно, можешь почувствовать?

Read more →

1/72 Stug

1/72 Stug В паре с Хетцером была собрана модель Stug 40 ausf.G от Revell. Без привязки к историческому прототипу, без тщательного изучения матчасти и почти из коробки.

Read more →

1/72 Tiger I

Tiger I Набор 5002 от «Звезды», предназначенный для сборки без клея. Собран с использованием клея, нарушением предписанного инструкцией порядка сборки и тонной матов на стадии окраски полусотни катков и сборки ломких хрупких гусениц.

Read more →