понедельник, 4 июля 2016 г.

Freelance: mine field or smooth ride

I'd been working in corporate sector of IT as full-time employee for 6 years until one day I was offered a contractor position. This offer required me to leave the steady job and enter the world of freelance and contractor work. And from then on I didn't look back.

Of course working in large companies has a lot of advantages: regular working hours, guaranteed salary and often - future in the company. Freelance can't and will never be able to guarantee that.
But large teams also have common downsides: one person is responsible only for small part of the project meaning it's difficult to overview the whole system and to analyse what's best for the customer; also it's hard to introduce new technologies due to legacy issues and also the value of one particular engineer is not very significant.

Freelance gives the freedom that corporate job can never provide: the freedom to choose clients, working hours, technologies, office (home/coworking/personal office rent), even your rate. All this at the cost of stability. You always need to be in search of new clients and projects when you see that current one is going to end. Be ready that your contract is closed and you need to move on. To be up-to-date with the technologies and trends. And also be ready for interviews, lots of them. This may be stressful but it pays back.

Field of freelance can be stressful for the employers too. How can I be sure that this engineer is really qualified and reliable? And if I need a whole team of them (often you do need more than one). I need to make sure they are experienced enough to understand my goals and the vision of the project. All this is hard to achieve with freelance contractors whom you don't know. You have to have your own team of HR and senior developers to handle interviews with candidates. And if you don't all is left is rely on their portfolio and their communication which is rather risky.

That's where Toptal comes in. It's a service uniting top 3% on freelances thoughtfully selected to match any challenging task and customers in search of skilled and reliable engineers. The main difference between Toptal and other recruiting services it that a developer should undergo a series of tests (communication, tech, test project, etc.) only to be registered within the system. Which increases the value of each Toptal member and customers can be sure to be satisfied with the results.

I personally look forward to this amazing opportunity to be a part of such great team!

четверг, 7 апреля 2016 г.

Some thoughts on registration


Recently while working on my screenshot sharing tool Fileshare I came across a service to upload and share images called puush.

It required to create account in order to get API key for image upload. Registration is very simple: just enter email and a password. What you may expect is that you'll need to prove that email belongs to you. But no. Your account is already active: you may use any email to register.

Btw they do send you an email after the registration with the following contents:
Welcome to puush! 
You are now ready to login to your puush app(s) using your new account. Your username is your email address. 
Sincerely,
The puush Team 
(If you didn't request this, simply ignore this email and we won't contact you again)

(original image by Anastasia Lemova, https://new.vk.com/komks)

четверг, 2 октября 2014 г.

Mind the spaces

Often developers forget about possible spaces in file and directory names, which can lead to any kind of trouble from corrupted awk parsing to terrible consequences like removing important stuff. We'll consider the latter issue. E.g. when we find files we often need to perform some operations on them. So, this command
find . -name "*.log" | xargs rm -f
will remove all log files recursively...or maybe won't? The case is that 'find' produces output of one file (row) at a time and if the file path contains spaces it will be split by shell into several 'files' which 'rm' will try to delete. Consider the following project structure:
--> tree
.
├── test
├── testdir
│   └── remove.log
└── test dir2
    └── remove2.log

2 directories, 3 files
So lets remove logs:
--> find . -name "*.log" | xargs rm -f
and see what we have now:
--> tree
.
├── testdir
└── test dir2
    └── remove2.log

2 directories, 1 file
Oooops.... Where is the 'test' file? And why the 'remove2.log' is still here? Let's see what happens. I'll revert back to the original structure before the 'rm' and we'll run harmless 'ls' to see what xargs is getting:
--> find . -name "*.log"              
./testdir/remove.log
./test dir2/remove2.log
--> find . -name "*.log" | xargs ls -l      
ls: cannot access dir2/remove2.log: No such file or directory
-rw-rw-r-- 1 aikikode aikikode  9 Oct  2 16:17 ./test
-rw-rw-r-- 1 aikikode aikikode 13 Oct  2 16:18 ./testdir/remove.log
So shell is passing 3 files:

  • ./testdir/remove.log
  • ./test
  • dir2/remove2.log
instead of original two. And all because of spaces in the directory name. And it happens (actually it was intentional) so that we have a file 'test' with same name as 'test dir2' directory first name part if split by space. That's why we get wrong files as a result of 'find'. There're 2 options here:
  1. set IFS variable before executing the command:
    IFS="$(printf '\n\t')"
    you should be aware that syntax and usage of IFS might differ from shell you are using
  2. Use -exec option in find:
    --> tree
    .
    ├── test
    ├── testdir
    │   └── remove.log
    └── test dir2
        └── remove2.log
    
    2 directories, 3 files
    --> find . -name "*.log" -exec rm -f {} \;
    --> tree
    .
    ├── test
    ├── testdir
    └── test dir2
    
    2 directories, 1 file
    

вторник, 4 марта 2014 г.

Debian IPsec tunnel

Assume we have two servers in different subnets that we want to connect through IPsec.
# Alice
206.36.46.56
10.20.10.10  # local IP
# Bob
207.37.47.57
10.20.20.10  # local IP

понедельник, 24 февраля 2014 г.

Ubuntu - install Sun Java and browser plugin

Install Java

Since Oracle Java is no longer currently available in a supported Ubuntu repository, one should go to Java download page and download tgz archive. Currently the latest version is 7 update 51.
Assuming you downloaded it to ~/Download/jre-7u51-linux-x64.tar.gz:
sudo mkdir -p /usr/lib/jdk/
cd /usr/lib/jdk/
sudo tar xzf ~/Download/jre-7u51-linux-x64.tar.gz
sudo update-alternatives --install "/usr/bin/java"   "java"   "/usr/lib/jdk/jdk1.7.0_51/bin/java"   0
sudo update-alternatives --install "/usr/bin/javac"  "javac"  "/usr/lib/jdk/jdk1.7.0_51/bin/javac"  0
sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jdk/jdk1.7.0_51/bin/javaws" 0
You may also need to configure java alternatives (in case you have several java versions installed):
sudo update-alternatives --config java
sudo update-alternatives --config javac
sudo update-alternatives --config javaws

Install browser (chrome) plugin

See official page for up-to-date instructions or perform these commands:
  1. Become the root user by running the su command and then enter the super-user password.
    sudo -s
  2. Create a directory called plugins if you do not have it.
    mkdir -p /opt/google/chrome/plugins
  3. Go to Google chrome plugins directory before you make the symbolic link.
    cd /opt/google/chrome/plugins
  4. Create a symbolic link.
    ln -s /usr/lib/jdk/jdk1.7.0_51/jre/lib/amd64/libnpjp2.so .
  5. Restart your browser and test Java

Open jnlp files from webpages with javaws

Go to the webpage with jnlp application. Start the application and the browser will download the jnlp file. Click the arrow next to the file button in the downloads bar and select "Always open files of this type". Start the application again to see the effect.

среда, 11 сентября 2013 г.

Extract audio with silence from video with ffmpeg

Usually excracting audio track from video file is not a problem and can be done using ffmpeg:
ffmpeg -i video.avi -vn result_audio_track.wav
But if you have video where audio track has silent parts, the command above will extract and concatenate only the parts where audio is not silent. So the result audio track will be shorter than the original. To overcome this the additional parameters should be set:
ffmpeg -i video.avi -vn -af \
    aresample=min_comp=0.001:min_hard_comp=0.100000 \
    result_audio_track.wav
These options prevent ffmpeg from dropping silent parts of audio track:
  • aresample resamples the input audio to the specified parameters.
  • min_comp sets the minimum difference between timestamps and audio data (in seconds) to trigger stretching/squeezing/filling or trimming of the data to make it match the timestamps.
  • min_hard_comp sets the minimum difference between timestamps and audio data (in seconds) to trigger adding/dropping samples to make it match the timestamps.

среда, 28 августа 2013 г.

Multiline regex

The simplest solution would be to use pcregrep, that is grep using the pcre library. Use the flag -M for multiline search:
pcregrep -M 'expression1\nexpression2' filename
if you'd like more 'native' solution without installing additional packages, there's a Python one-liner that will do the job:
alias mlgrep='python -c '\''import re, sys; \
    sys.exit("Usage: mlgrep PATTERN") if len(sys.argv) != 2 else True; \
    match = re.findall(r".*" + sys.argv[1] + r".*", sys.stdin.read().strip(), re.MULTILINE); \
    print("\n".join([x.strip() for x in match])) if match else sys.exit(1)'\'''
add this line to your ~/.bashrc file and use it as:
cat filename | mlgrep "expression1\nexpression2"