Category Archives: programming

git linux

Space efficient source code storage

kernel-zip-src

During implementation of DistTest I faced with necessity of building a lot of different linux kernel versions. As a first solution I chose downloading archives from kernel.org for each used version. But I soon realized that about 1000 versions of sources with size 0.5-1GB each would consume a lot of disk space. It’s also impossible to build kernel with exact commit precision using this approach.
Set of base versions with corresponding patches can save disk space, but uses a lot of random I/O during applying patches, so it’s slow on HDD and consume finite rewrite resource of SSD. Temporary nature of sources leads to conclusion “use tmpfs”. But aufs offers much less RAM consuming method – store in RAM only diffs.

read more »

perl programming

Selfmade dyndns

Dyn.com stopped providing free dyndns hosting some time ago. It were sad news.
However most necessary functionality can be implemented in 70 lines of code.
To dynamically update dns records we must find a way to:

  1. get current ip
  2. update DNS record
  3. schedule script for execution

1. Getting current ip address

Many ISP use NAT for security and money saving reasons. Also NAS used in routers. So, to get your IP address you need to ask your IP address from service located outside your network.
For example internet.yandex.ru web page ask resource http://ipv4.internet.yandex.ru/api/v0/ip to determine IP address. So, let’s use it.

2. Updating DNS record

Yandex provide API for DNS records management for domains parked in yandex. API reference should be located here but link is currently broken :-(. UPD: API reference.
In two words you should send POST request with token in header and data in request’s body to https://pddimp.yandex.ru/api2/admin/dns/edit url.
It should looks like following snippet:

3. Scheduling dns records updating

Use the cron, Luke 🙂 I mean that adding following line to cronjobs would be a simplies way to schedule updating of our dns records:

That’s all. Complete script on github.

programming

Buzz words collection

My collection of programmers buzz words. I think it will be useful for beginner programmers and Software Engineering students. Will be actively replenished.

Bumblebee_Man

Principles

  • Defensive programming
  • KISS – Keep it simple, stupid
  • DRY – Don’t repeat yourself
  • YAGNI – You Ain’t Gonna Need It
  • ACID – Atomicity Consistency Isolation Durability
  • Inversion of control
  • Uniform Access Principle
  • Law of Demeter
  • SOA – Service-oriented architecture
  • GRASP – General Responsibility Assignment Software Patterns
  • SOLID
    • Single responsibility principle
    • Open/closed principle
    • Liskov substitution principle
    • Interface segregation principle
    • Dependency inversion principle

read more »

programming

Some weekend’s madness

I’ve just tried to follow intellij idea’s manual and develop some useless plugin. And now my plugin can display “Hello world” program on perl.
Screenshot from 2013-08-19 00:05:08
You also can view this madness on github.
UPD1. Some new lexical constructions support added.
idea

programming

Link assembly and c

I using nasm to generate object code from assembly source. 3 application required to compile executable:
– nasm
– gcc from gcc--base package (gcc-4.7-base for example)
– ld from binutils package
*package names in ubuntu distribution

To install this packages run following command:

Files contents:

And finaly:

programming

Precision of calculation with floating point numbers

I found some curiosity issues during finding optimal tool for compilation our program. Results of computations be different for different tools and different optimisation flags.
For investigating this issue I write simple code(full sources on github):

In this small test program I can’t reproduce different results for different flags. But 5 different results for so similar programs is enough to demonstrate discovered effect.

Source code and tool Result Computation time, s
Assembler 1.53436944477410652787 3.81
gcc long 1.53436944477462278158 4.4
gcc double 1.53436944477389380914 4.4
icc long 1.53436944477397574360 6.88
icc double 1.53436944477334602510 1.50

p.s. also I found that manually written assembly code 15% faster than code on C in spite of using “-O2” optimisation flag.

programming

Suffering Oriented Programming

Do you suffer greatly without some feature?
We will implement it!

We take into account only the great suffering

backup programming svn vcs

Remote SVN backup with svnsync

Create local svn repository with name “my_local_repo”

prepare local repo

initialize local copy

first run must be interactive to input and save your login and password

write script to run it in cron
backup_svn_script.sh:

it produce files like “svn_2012_09_07_01_34_01.tar.gz” in your backup directory

Now you can add task to cron. Execute:

and add following line to run backup at 4:00 (4 a.m.) every day

This method is not disk space efficient, but very simple.

Sources:
using svnsync
installing subversion server in ubuntu