Archive for category Linux

My favourite quotes.

“A vital ingredient of success is not knowing that what you’re attempting can’t be done.” ~ Terry Pratchett

“When it comes to the future, there are three kinds of people: those who let it happen, those who make it happen, and those who wonder what happened.” ~ John M. Richardson, Jr.

“When I hear the word «impossible», I smell a good business idea” ~ Yrjö Ojasaar

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Mandatory training for every new startup – Preparing, Testing and Executing – Yrjö Ojasaar

Yrjö is one of the best experts of startups is Baltic region who I have seen personally and who keeps on speaking on different conferences. I believe that the training session what I am describing here should be wort several hundered EUR at least but this is totally free. You can skip this training only if you have launched at least one successful startup and even then it is worth repeating the basics. I am only gonna write very brief overview, to udnerstand further take your time to see these videos.

Part 1 Preparing. How to generate business idea? Is there competition and how people can survive without your invention. How to setup product hyphothesis. How to perform risk analysis. How valuable ideas can you get on toilet?
Reseources needed: people, time, motivation, money.

Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Facebook login on multiple subdomains with one app id

If you add Facebook authentication on your website then you need to enable “Website with Facebook Login” and set value for “Site URL:” . You can only set single site url and if you want to use same Facebook app in different domains then you might get error:

An error occurred. Please try again later.
API Error Code: 191
API Error Description: The specified URL is not owned by the application
Error Message: Invalid redirect_uri: Given URL is not allowed by the Application configuration.

Fortunately it is possible to enable login for multiple subdomains if you configure “App Domains:”. In this case Site URL dows not have to match with acutal redirecturl domain exactly.

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

mysqldump export rows cli in sql format

Sometimes I need to export a set of data from staging or testing database to production. Usually it is related to configuration settings It is best to export the data in SQL format so it is possible to import it easily in other machine.

Follow this template

mysqldump -p -uusername  -w "where query" databasename tablename

For example

mysqldump -p -uroot  -w "id < 10" website settings
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

How to download ca certificate chain

It might happen that some machine has missing CA chain certificates and you get error

OpenSSL: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure
 Unable to establish SSL connection.

If accessing the specific URL in browser works without warning then you can export and download CA certificate chain

In Firefox right-click > View Page Info > Security > View Certificate > Details . There you see Certificate hierarchy and can export each certificate in chain individually.  Depending on OS you need to add these certificate in PEM format ti /etc/pki/tls/cert.pem or similar.

See more useful tricks about SSL here.

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Application code deployment from SVN with fast and simple rollback

Most important thing in every new release is the rollback procedure. Once you discover issues in new version then you need to be able to swithc back to previous version until you work on a fix. I have developed shell script to handle the automated deployment process and which allows quick and simple rollbacks if there are no database changes that dont allow easy rollback. Main idea is to

  • download code from SVN, GIT or similar
  • copy all code to new folder
  • replace all configuration with environment related conf
  • use symlink to switch between code versions

Here is example script that handles the automated deployment for you  Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Access virtualbox shared folders from Ubuntu and fix ruined ubuntu installation.

If you are running Ubuntu virtualbox guest then you cannot access the shared folder under /media/shared with regular user. However you can fix this by adding your user to vboxsf additional group.

Important! make sure you append the additional group so that other groups are not removed! Run te command below as exactly as seen and replace you username. If the permission is not applied immediately then reboot.

usermod -a -G vboxsf username

In case you forgot flag -a then it is bad but not hopeless :) Read the rest of this entry »

Share on TumblrSubmit to StumbleUponhttp://marguspala.com/wp-includes/images/smilies/icon_smile.gifDigg ThisSubmit to reddit

Recover virtualbox guest from failing snapshot

When making snapshot of running virtualmachine guest the process got stuck and left below traces in logfile. I had to kill hte snapshot process and reboot machine to continue.

vboxmanage snapshot mymachine take initial
00:00:14.576 PCNet#0: The link is back up again after the restore.
00:03:47.980 Changing the VM state from 'RUNNING' to 'RUNNING_LS'.
00:03:48.014 
00:03:48.014 !!R0-Assertion Failed!!
00:03:48.014 Expression: <NULL>
00:03:48.014 Location  : /build/buildd/virtualbox-4.1.12-dfsg/src/VBox/VMM/VMMAll/PGMAllBth.h(1458) void pgmR0BthEPTProtSyncPageWorkerTrackDeref(PVMCPU, PPGMPOOLPAGE, RTHCPHYS, uint16_t, RTGCPHYS)
00:03:48.014 HCPhys=00000000d5a37000 wasn't found!

After  reboot i see:

# vboxmanage list vms
"<inaccessible>" {d1d42d8a-38ed-4d6d-95a1-356d2896ff26}

Read the rest of this entry »

Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

sh: 2: Syntax error: newline unexpected

Error happened when running perl script on Ubuntu machine after coping it from another.

Issue must have been caused by different encodings and was resolved by removing newline in the middle of the command.

        # Monthly Backup
        system("$MYSQLDUMP --user=$DB_USER --password='$DB_PASS' $db_name >
$BACKUP_DIR/$db/${db}_monthly_$datestamp.sql");

Changed to

         # Monthly Backup
         system("$MYSQLDUMP --user=$DB_USER --password='$DB_PASS' $db_name > $BACKUP_DIR/$db/${db}_weekly_$datestamp.sql");
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit

Creating VM-s via CLI using VBoxManage

If you happen to setup virtual machines to remote server then you might not have good access to graphical interface to use the VirtualBox graphical interface but you have to be able to manage using CLI. This gives you even more flexibility but needs some time until you can figure out what and how to do.

First create virtualmachine and register it with virtualbox.

VBoxManage createvm --name myvirtmachine --register

Create harddisk for this virtualmachine

VBoxManage createhd --filename myvirtmachinedisk --size 100000

Set some useful params for tis virtual machine

VBoxManage modifyvm myvirtmachine--ostype Ubuntu_64 --memory 2048 --cpuhotplug on --cpus 2 --nic1 bridged --bridgeadapter1 eth0

Create storage controller for virtual machine

VBoxManage storagectl myvirtmachine --name myvirtmachinestoragectl --add sata

Attach installation media into DVD drive to this storage controller. In this case i have downloaded previously the ubuntu isntaller CD

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 0 --type dvddrive --medium ../ubuntu-12.04-server-amd64.iso

Attach HDD to this storage controller

VBoxManage storageattach myvirtmachine --storagectl myvirtmachinestoragectl --port 1 --type hdd --medium myvirtmachinedisk.vdi

Now you are ready to start the VM. First command is without vnc access, another has vnc access and you can get the access to console by opening vnc session to host machine.

VBoxHeadless -startvm myvirtmachine --vrde off
VBoxHeadless -startvm myvirtmachine --vnc --vncpass 12345
Share on TumblrSubmit to StumbleUponSave on DeliciousDigg ThisSubmit to reddit