Sunday, 12 January 2014

Bitkoino vertė

Užmačiau keletą žmonių sakančių, kad bitkonai neturi vertės, niekas jų vertės nekontroliuoja, ir taip toliau ir panašiai. Manau tokie argumentai kyla tiesiog iš to, kad žmonės kalba nepaskaitę ar nesupratę. Aš šiek tiek paskaičiau ir sudėliojau keletą argumentų, kodėl bitkoinai turi vertę.
Bitkoinais yra vadinami bent du skirtingi dalykai. Pirma, tai yra tai apie ką daugelis kalba - priemonė mainams arba valiuta.
Šios valiutos neįmanoma padirbti. Atkreipiu dėmesį - tai nereiškia, kad valiutą sunku padirbti ir turime institucijas, kurios rūpinasi, kad niekas jos nepadirbtų. Ne. Bitkoino neįmanoma padirbti pagal sumanymą. Tiesiog nėra tokios galimybes.
Pervedimai į bet kurį pasaulio kraštą užtrunka sekundes. Nesvarbu ar pervedimas vykdomas žmogui stovinčiam šalia tavęs ar pervedimas keliauja į Nabijią.
Valiutą ypatingai lengva integruoti su kompiuterinėmis programomis. Vienas vakinas iš Australijos sukūrė kazino Minecraft pasaulyje kuriame lošimai vyksta naudojant bitkoinus. Jis suprogramavo bitkoinų atsiskaitymus per pusdienį. Jam nereikėjo gauti leidimų ar licenzijų. Sugalvoji - suprogramuoji - leidi visiems naudotis.
Argi nors ir vien tik tokias funkcijas turinti valiuta neturi vertės? Argi nėra nei vieno kuris norėtų tokia valiuta naudotis ir teiktų būtent tokiai valiutai pirmėnybę virš popierinių banknotų?
Kitas žvėriukas, kuris slepiasi po žodžiu bitkoinas yra infrastruktūra ant kurios sukonstruota bitkoino valiuta. Tačiau ši infratruktūra gali būti panaudota ne tik valiutai.
Viena iš šios infrastruktūros dalių yra bitkoinų blokų grandinė. Bet kas, kas ten padedama yra grupuojama į blokus, hašuojama su paskutiniu bloku ir prilipdoma prie grandinės galo. Kadangi blokų tūriniai yra susiję tarpusavyje, gauname grandinę į kurią ką nors padėjus tampa neįmanoma to vėliau pakeisti. Šiuo metu ten dedami bitkoinų valiutos pervedimai. Tačiau ten galime dėti bet ką, kas turi ateityje likti įrodomai nepasikeitę.
Paprasčiausias pavyzdys kam dar galime panaudoti šią grandinę būtų “atspėk skaičių” žaidimas. Sugalvoji skaičių jį užšifruoji raktu ir padedi į blokų grandinę. Po kiek laiko, kai žaidėjai suregistruoja savo spėjimus, padedi į grandinę raktą, su kuriuo galima atšifruoti sugalvotą skaičių. Taip paprastai galima sukurti įrodomai sąžiningą azartinį žaidimą. Pasinaudodami blokų grandine užtikrinome, kad sugalvotas skaičius nebus pakeistas gavus žaidėjų spėjimus.
Dar viena iš daugėlio bitkoinų infrastruktūros funkcijų yra “m iš n pervedimas”. Tai bitkoinų pervedimo tipas, kur reikia m sutikimų iš n, kad pervedimas įvyktų. Taip mes gauname arbitražo funkciją. Pavyzdžiui Jonas perka mašiną iš Petro. Tačiau paprašo Eglės pabūti arbitru jeigu tektų spręsti ginčą. Taigi Jonas Petras ir Eglė visi kartu sukuria pervedimą, kur Jonas pasižada pervesti pinigus Petrui. Pervedimas neįvykdomas, kol bent du žmonės iš trijų šio pervedimo nepasirašo (2 iš 3 pervedimas). Jeigu Jonui mašina tinka, tada Jonas ir Petras pasirašo pervedimą ir pinigai nukeliauja Petrui. Jeigu Jonas galvoja, kad mašina ne tokia, apie kurią pasakojo Petras, tada jis kreipiasi į Eglę, kuri nusprendžia kas yra teisus ir su juo pasirašo arba nepasirašo pervedimo. Tai ne teoretinis pasvaisčiojimas. Jau dabar yra turgelių, kur įvairiausi arbitrai siūlo savo paslaugos ir m iš n pervedimai gulasi į blokų grandinę.
Tikrai visų bitkoinų funkcijų čia neaptariau ir darbai juda kuriant naujas funkcijas blokų grandinėje. Čia tik pradžia. Tačiau argi tokia bitkoinų infrastruktūra neišsprendžia tam tikros dalies iki šiol turėtų problemų elegantiškai, saugiai ir užtikrintai? Iš čia ir kyla bitkoino vertė.
Taigi bet kuris, kuris sako, kad bitkoino valiuta ar infrastruktūra neturi vertės tegu patyli, nes jis visiškai nenutuokia apie ką kalba.

Saturday, 30 June 2012

Visualizing SVN workflow using github-like network graphs

Recently I found a need to visualize the way our team works with the SVN repository. I really like github network graphs, so I started looking for a way to draw custom ones.

Luckily i found a raphaeljs (JavaScript library for vector graphics) demo which did exactly what I wanted. I had to tweak it a bit, like making labels show all the time, and making custom commits.

The result looks like this:

SVN workflow visualized as a github-like network graph
You can find the changes I made here. You can also find the source code of the original raphaeljs github demo here.

Thursday, 26 August 2010

Appliance control using a mobile phone and SMS messages, part 1

Hey, how are you doing? (: Since there was a week between the end of the GSoC and the start of my studies, I decided to do some hobby hacking.

I have some remote (50 km away) appliances (electric heater) that I would like to control from wherever I am. The SMS service is a very compelling solution for this kind of problem. The main challenge is to figure out how to make a mobile phone to a relay that can switch on and off things.

I found a nice tutorial here which tells how to control a 12V car relay with a vibrator signal from the phone (no firmware modification is involved there). This gave me a good jump start. I picked up my old Nokia 3310 for this job. One nice thing about this phone is that it has a thermometer that is mounted in the battery (only original batteries have these). The thermometer will tell what is the current temperature around the phone. The phone will use this information to decide whether to turn on or off the heater in order to keep the same temperature in the room. SMS messages will be used to notify me if something goes wrong or to change the preferred temperature. This can be used during winters when you want to preheat the place before arriving there. Another advantage of this phone is that there is a marvellous open source tool called NokiX, that allows to modify phone's original firmware.

First of all I modified the phone's F/W which turns vibra on and off according to the environment and preferred temperature. You develop these patches using C or Rexx. There is quite a lot phone functionality exposed already. My application does the following things:

  • turns the vibra on or off according to the temperature readings
  • you can give a ping to the phone (call the phone for one signal and then hang up), and then the phone will send you the current temperature
  • the phone will send you a message when temperature drops down below a certain limit

After that came the hardware part.
Don't mind the labels in the picture above. I wanted to place all the components in a quite an optimal way, so I created a PCB design first. It is quite compact but I still could not get rid of one wire going on the non-component side of the PCB.

You can notice a misturned transistor in the pictures above. Thankfully my dad noticed it before I plugged this thing on. After I completed soldering this board a time came for the modification of my good old Nokia 3310. What I needed to do was just take that mobile phone apart, take that vibra motor away and solder two wires in its place.

Then I needed to make a little hole in the plastic frame so these two wires can get out. I did all of this following pictures from the link mentioned in the beginning of this post. After I put everything back together I measured the voltage of the vibra motor. According to the site it should be around 3.75, and so it was.
So far so good. But there was one problem when I connected the phone, power supply and relay to the board. Relay was always on disregarding the vibra power of the phone. I measured the voltage on the relay and it gave me 6V when vibra was completely turned off. Well I am not that good in radioelectronics so I asked my dad for some help while debugging the situation.

After couple of voltage measurements we decided to put a 68ohm resistor between the base and the emitter of the transistor. This helped. When the vbra power was off the transistor was completely off and relay voltage measured 0V. When the vibra was on full power transistor was completely on and relay voltage measured near 12V. This modification was needed because we used a different kind of relay than the one mentioned in the article.

This left us with a working bunch of wires and components on the board. Tomorrow I will try to put everything into a nice box. See you then.

Sunday, 15 August 2010

GSoC 2010 Week #12 report

Hello everyone,

well it has come to the end. This is my last GSoC 2010 weekly report. First of all I would like to say that it was an unbelievable experience to work whole summer on the open source project such as phpMyAdmin.

Well talking about my initial proposal to phpMyAdmin not everything that was written there is implemented. Two out of the three main goals are completed. Now any user can see and create charts out of their data and I believe that I did quite a good job giving future developers a way to expand chart implementation with different chart renderers.

One thing that was in my proposal and I left it out is JS chart implementation. I dropped it because image charts looked so nice and I was able to add some interactivity (tooltips) to them which are probably the most used feature of JS charts.

I spent the last week rewriting comments so that phpdoc can understand them. I also added some documentation and linked wiki to the FAQ section of the documentation. So any user that has a problem while drawing a chart can seek help there.

Well I haven't had a blog before GSoC, but I will try to keep on posting what is happening around me. See you some time later!

Sunday, 8 August 2010

GSoC 2010 Week #11 report

Hello everyone,

well not much code was added this week. However I have tried to install my PMA fork to as many machines with as many configurations as possible. By doing so, I have found few bugs and made some fixes which will help with the compatibility.

Who would have ever thought that I would find a machine with no JSON capability. After this not usual encounter I added check for JSON functions and if there are not any, then tooltips are disabled.

Next week is the last week of GSoC and I will work on documentation, more testing and fixing bugs if any.

Saturday, 31 July 2010

GSoC 2010 Week #10 report

Hello,

well I spent this week fixing various bugs and polishing some details. One of the more significant achievement was more sophisticated tooltip generation. Now it should work on any pie chart. Even on one with only one piece.

I have solved the base64 image length problem that I described in my last post. I decided to slice the chart image vertically into as many as 20 parts. In such way one part of a very big chart is under the limit of the base64 image length so it is displayed properly. This added some difficulties for the user when saving the chart to the hard disk. Therefore I have also added an option which allows to output a chart in one single piece.

I have tested various trivial cases for tables and checked if query results work on them. There was some tweaking to be done for these cases.

I also documented some work I have done in the wiki. You can find it here. There is also a format documented that is accepted for query results charts. You can see the preparations that need to be done for your data if you want to put it to the chart.

I have also merged master to my fork. There was only one minor conflict. This actually means that I am not changing PMA code much. I am just adding some new.

Next week I will continue polishing and fixing bugs if any.

Thursday, 22 July 2010

GSoC 2010 Week #8-#9 report

Hello,

first of all sorry I missed the report of the week #7, but I was ill that week so nothing much happened. This week I have started adding JS to the charts. So this is how it went.

The PHP library that I use (pChart) for chart generation has some ImageMap functionality. What it basically does is return some data to JS where a tooltip must be shown. That data is only coordinates of two points. That script allows to show tooltips only above rectangles. Well, pie charts and radars charts consist of not only rectangles but we want tooltips on them too.

So I started this week by writing some PHP code which calculates the areas where a tooltip should be on a chart and then JS had to be improved to cope with more complicated figures. There was some interesting math involved in this. Now we have tooltips over pie and radar maps too.

Well with JS sometimes comes compatibility issues. So when I started writing JS I also have started testing my work on other browsers. Only now I have noticed that IE 8 (I haven't even tested it on older ones) does not always show base64 encoded images. Some images which have long base64 strings are not shown. This is a little show stopper because I have no idea how to fix this without scrapping base64 images.

Talking about charts (: I was thinking about and looking at flot library for charts. It is not really suitable for this. It does better job while rendering plots than charts. pChart does render really good looking charts and no other library can do it better. I am not sure if PMA needs another implementation (JS) for charts. I think now I will do my best to add some convenience JS functionality and it will be much better than completely different JS charts implementation.

Now I am going back to tinker around with details and some bugs that are still there.

BTW. You can test out the chart functionality here. Just go the the status page and you will see nice looking pie chart. It is harder to test query results charts because you need some data which script does understand.