Multimea numerelor naturale

Te rog sa ti cont de faptul ca blog-ul acesta s-a mutat.

Acum a primit (cadou de Craciun) propriul sau domeniu: mynixworld.info :-)

Daca doresti sa citesti ultimva versiune a acestui articol (lucru recomandat) te rog da click aici si ma ocup eu sa deschid pagina pentru tine.

  1. Metode de rezolvare a problemelor de aritmetica
    1. Metoda figurativa : este o metoda  de rezolvare a problemelor de aritmetica ce consta in reprezentarea printr-un desen a marimilor necunoscute  si fixarea in acest desen a relatiilor dintre ele  si marimile date in problema.
    2. Metoda falsei ipoteze (sau a presupunerii) : este mai putin cunoscuta elevilor. Caracterul neobisnuit al acestei metode, prin gradul sporit de abstractizare, face aplicarea ei aparent dificil . Rezolvarea problemelor prin metoda ipotezelor pregateste pentru intelegerea multor teme de algebra  sau geometrie. Este o initiere in demonstrarea mai tarziu a teoremelor prin metoda reducerii la absurd. Metoda falsei ipoteze consta in a face o ipotez  (presupunere) oarecare (desi de obicei se pleac  de la ipoteza “toate de un fel”) nu in ideea de a “nimeri” raspunsul, ci pentru a vedea din nepotrivirea cu enuntul ce modificari trebuie sa facem asupra ei. Metoda se numeste “a falsei ipoteze” pentru ca avem banuiala ca nu este ipoteza conform  adevarului.   Problemele care se pot rezolva prin metoda falsei ipoteze sunt de dou  tipuri:
      1. cu o ipoteza
      2. cu mai multe ipoteze
    3. Metoda comparatiei (metoda reducerii la acelasi termen de comparatie) : Problemele care se rezolva folosind aceasta metoda se caracterizeaza prin faptul ca se dau doua marimi (care sunt comparate “in acelasi mod”) si legatura care exist  intre ele. Aceste marimi sunt caracterizate prin cate doua valori fiecare si de
      fiecare data se cunoaste legatura dintre ele. Metoda consta in a face ca una din cele doua  marimi sa aib  aceeasi valoare si astfel problema devine mai simpla, avand o singura necunoscut . Din aceast  cauza se numeste “aducerea la acelasi termen de
      comparatie”. Remarca: Metoda comparatiei sta la baza rezolvarii sistemelor de doua ecuatii cu dou  necunoscute prin metoda reducerii.
    4. Metoda mersului invers (retrograda) : este folosita in probleme in care elementul
      necunoscut apare in faza de inceput a sirului de calcule; operatiile se efectueaz  in sens invers actiunii problemei. Aceasta metoda consta in faptul ca enuntul unei probleme trebuie urmarit de la sfarsit spre inceput. Analizand operatiile facute in problema si cele pe care le facem noi in rezolvarea problemei, constatam ca de fiecare data, pentru fiecare etapa, facem operatia inversa celei facute in problema. Deci, nu numai mersul este invers, ci si operatiile pe care le facem pentru rezolvare sunt operatiile inverse celor din problem . Verificarea (proba) se face aplicand asupra rezultatului obtinut operatiile indicate in problema.
    5. Probleme de miscare se clasifica in:
      1. probleme de miscare in acelasi sens (numite probleme de urmarire)
      2. probleme de miscare in sensuri contrare.

      Legea miscarii uniforme, exprimata prin d=v*t (distanta=viteza
      *timp; viteza=distanta/timp, v=d/t; timpul=distanta/viteza, t=d/v), este esentiala in rezolvarea tuturor problemelor carora le zicem “de miscare uniforma”.

    6. Probleme de perspicacitate : Problemele prezentate la aceasta tema se rezolva folosind elemente de logica matematica si nu se incadreaza in nici una din metodele prezentate (figurativa, falsei ipoteze, mersul invers, comparatiei). Ingeniozitatea, spiritul de initiativa, perspicacitatea, deductia sunt calitati care “puse in miscare” duc la solutii surprinz toare.   Rezolvarea acestor probleme e o provocare la un “duel al mintii”: sa alegi solutia prin logica, perspicacitate, perseverenta. (Armand Martinov)
  1. Siruri. Sume
  1. Teorema impartirii cu rest
  1. Puterea cu exponent natural a unui numar natural
  1. Calculul ultimei/penultimei cifre a unui expresii numerice cu puteri, a unui produs
  1. Calculul sumei puterilor consecutive ale unui numar natural
  1. Patrate perfecte. Cuburi perfecte
  1. Sisteme de numeratie
  1. Sistemul de numeratie in baza 10 (zecimal)
  1. Sisteme de numeratie cu alta baza
  1. Criptarium
  1. Principiul lui Dirichlet (principiul cutiei)
Posted in Uncategorized | Leave a comment

mynixworld.wordpress.com is moving at mynixworld.info

Dear Subscriber,

I just want to let you know that my blog, hosted so far at mynixworld.wordpress.com, has got a new house at mynixworld.info.

Starting with 2014-01-12 mynixworld.wordpress.com is automatically redirected at mynixworld.info.

If you have subscribed and/or followed us via Facebook, Twitter, etc please subscribe to follow us again. It’s simple, just click on the corresponding follow/subscribe icons that can be found at mynixworld.info.

Unfortunately I don’t have the possibility to migrate those subscriptions automatically so I thought it would be a good idea to notify you about this change.

What’s New

The new blog has a clean theme that makes the loading/reading easier than before, besides that it’s hosted on a powerful system and that should help too :-).

It uses wordpress.org as framework which means I have full control of it. That allows me to add virtually unlimited functionalities with the aim to improve the visitors experience. That was not possible before, though.

Anyway, I hope you have a good day and if you think that it worths reading my blog then please subscribe again. Sorry for this guys…

Eugen

Posted in Uncategorized | Leave a comment

Table of English tenses

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

I don’t know about you but I had always problems with tenses of English verbs, maybe because I’ve learned English by myself rather than in school. Anyway, English grammar is not impossible to learn if you find a pattern that is easy to follow and remember.  Below I have compiled a table of English tenses.

In English we have only three main tenses along the time axis:

  • past
  • present
  • future

Each of these main tenses is divided in four other subdivisions:

  • simple
  • continuous
  • perfect
  • perfect continuous

The resulted English tenses is just a Cartesian product of these two sets:

tensesWhen to use what? – that’s somewhat obvious:

  • past for events started and finished in the past or that are no longer true at the moment of speaking
  • present for events that happen at the moment of speaking or that are scheduled to happen in the near future
  • future for events that will happen in the future

How are these tenses constructed? Can we find and use a pattern? Yes, we can:

Past Present Future
Simple verb+ed verb+s/es* will+verb
Continuous was/were+verb-ptp am/is/are+verb-pp will+be+verb
Perfect had+verb-ptp has/have+verb-ptp will+have+verb-ptp
Perfect continuous had+been+verb-pp has/have+been+verb-pp will+have+been+verb-pp

where:

  • verb is the verb at infinitive form
  • verb-ptp is the past participle of the verb
  • verb-pp is the present participle of the verb
  • * applies only when used in third person

In addition to the above links examples, one good online resource that I treasure a lot is Seonaid’s website called “Perfect English Grammar“. Seonaid is a British native speaker of English. She has a Master’s degree (M Phil) from Cambridge University in English and Linguistics.

Have fun!

Posted in Uncategorized | Tagged , , , | Leave a comment

How to build a 65W solar panel system with only $80

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

For some time I was interested in testing methods of building a cheap solar panel using cheap solar cells and other things that you might find on the junkyard, so I’ve set up an experiment for this.

My goal was to build a system that would be able to provide the necessary electricity to light up some 8W (500lm) light bulbs, power my 45W laptop and watch my 30W LCD TV. A 65W solar panel will do the job if it’s not used with all the appliances at once. Some people will also look to build solar panels that will last a long period (like 10-15 years) and that’s OK if you actually have decided to build an expensive system which in turn should earn its money (and that takes time). In my case, where I am rather experimenting than make an investment in such a system, I want just to investigate (by trial and error) how much of the cost can be cut. Moreover, I’m sure that the technology will gradually improve such that in the next 5 years I will want to change the panel’s cells with something better, meaning something more efficient (note that the today’s best solar cell tested in laboratory cannot convert more than 44% of the solar light into electrical energy whereas the cheapest polycrystalline cells efficiency varies between 13-16% ).

Note that a similar system (solar panel+charge controller+DC/AC inverter) could be bought from a myriad of providers for just about $300. Can we build it cheaper? – that is the question that my experiment tried to answer.

The project required the following parts:

  • solar cells including tabbing and bus wire, flux pen, junction box and cable
    • polycrystalline are the cheapest (a kit can be bought for $40 with free shipping from eBay) although it’s less efficient while mono-crystalline are better but also pricey
  • an off-the-peg 80W panel would cost $100 + shipping (which could mean more than $50 depending on your location)
  • the panel frame which can be:
    • aluminium L-shaped frame ($38 on eBay)
    • wooden frame (costs just a fraction than the aluminium version)
  • solar cells encapsulation:
    • nothing – the cheapest method but with some side effects (the cells’ welding might corrode)
    • EVA film ($62 for 2.8m2 on eBay); note that you will only need ~0.5m2 for such a panel
    • Epoxy resin ($30 for 400g on eBay); 400g should be enough for such a panel
    • Sylgard® 184 ($50 for 500gr on eBay + shipping)
  • the front and optionally the backside glass sheet (8mm respectively 4mm thick)
  • solar panel charge controller (from $10 on eBay)
  • DC to AC power inverter (from $32 on eBay)
  • a 12V deep-cycle AGM battery (perhaps from $100 and up depending on its storage capacity or other characteristics)
  • electric wires, plugs, adhesive tape,silicone sealant, screws and bolts, etc
  • some tools (drill,saw,pliers,soldering iron,silicone caulk gun, multimeter, etc)

I will go neither through the design or the build steps, instead I would recommend few online resources that you might use to get an insight of the building process:

To build this system I’ve chosen to buy a solar cells kit (cells, tab and bus wire, flux pen, junction box and 1m solar panel cable) where I’ve soldered the cells manually and then I stuck them between two glass layered sandwich which was sealed on a wooden frame with some white silicone sealant.

Solar cells between two layers of glass sheet

Solar cells between two layers of glass sheet

I choose not to encapsulate the cells with EVA/Epoxy but instead to seal the glass sandwich, as I’ve said, on the wooden frame with a silicone sealant and later to extract the air from the sandwich such that the amount of air that is in contact with the solar cells is kept minimal (almost vacuum). Almost vacuum means almost no moisture and no moisture means to prolong the life of the cells and to make sure they run at their full capacity. By doing this I cut also the cost considerably ($30-$60 at least). Note those red plastic tile spacers used to align the cells and also to create a 4mm space between these glass sheets. They are important!

The panel configuration looks like this:

  • 1st layer: a 8mm thick sheet of clear glass exposed directly to the sun light
  • 2nd layer: the photo-voltaic cells aligned by a φ=4mm plastic tile spacers
  • 3rd layer: a 4mm thick sheet of glass/plastic forms the panel’s backside
Panel configuration

Panel configuration

This 3-layered sandwich will be mounted (layer by layer) on a rectangular wooden frame. In order to prevent the moisture entering from the outside into inside we are going to seal the glass sheets and the wooden frame. The only air that still exists around the solar cells (within sandwich) are the air that was trapped when we sealed the frame and the glass’ sheets. Now it’s time to suck that air. We already made a vacuum orifice in the wooden frame so that we can use a vacuum pump (or some kind of handcrafted pump) to extract the air and then immediately stop a cork (or something) which later can even be sealed using silicone sealant. Note that this part is very tricky because we have to move fast (otherwise the air will enter in a mater of milliseconds).

To make sure that this structure will remain in fixed position we fix the panel’s backside on the wooden frame by using some metal corner brace which are in their turn fixed with wood screw.

Learn from my mistakes:

  • make sure you drill the vacuum orifice in the wooden frame before placing/sealing the sandwich; this way is easier and implies no risk in braking neither your glass sheets or the solar cells
  • make sure you drill two small holes in the wooden frame in the place where the positive and negative bus wire cable are soldered
  • the soldering should be done like this:
    • solder the tabbing wire on the negative (the front side) side of each individual cell
    • place the 1st layer of glass sheet (8mm) on the wooden frame
    • place carefully the solar cells over this sheet of glass such that you can access the backside of the solar cell; make sure you align these cells using those plastic tile spacers and also that the negative tabbing wire is arranged over the cell’s positive terminals (on the cell’s backside)
    • solder the cells with each other so that you obtain a straw of series linked cells
    • solder each straw of cells with a bus wire on the next straw of cells
    • solder two pieces of cable at each side of your positive and negative bus wire and make sure that the other ends are inserted through those two holes made earlier
    • test your panel, make sure that your cells add-up to the maximum desired voltage (if you encounter an issue now it would be the time to fix it!)
    • pour a drop of silicone sealant on the back of each solar cell
    • place the 2nd layer of glass sheet (4mm) on the wooden frame just above the solar cells;don’t be afraid, the 2nd layer of glass will not touch the solar cells thanks to the plastic tile spacers
    • make sure you seal the 2nd layer of glass with silicone sealant. Let it a dry properly then fasten the 2nd layer of glass with the metal corner braces; use only wood screw and if necessary drill a hole in place using a small drill bit before using the screw (so that the wood would not crack)
    • turn your panel upside-down and seal now the front sheet of glass using the silicone sealant. Let it dry properly.

At this point your panel should be functional. Below you can find a modest picture gallery of this panel:

panel1 panel2 panel3
panel4 panel5 panel6

Test again your panel, if you’ve checked carefully the panel before you have applied the sealant then everything should works just fine.

To mount your panel on your roof you will need some roof hooks/mounting brackets. The size and shape of those mounting brackets varies with the size and the shape of your tiles (take a look at the picture below):

You have to pay around $50 for 4 pieces of roof hooks. If you want to stay on budget then maybe you can manufacture them by yourself. You could use an iron ring of an old wooden barrel that you don’t need it:

Caption

Wooden barrel ring

I’ve installed the panel on my parent’s house roof where they have Spanish ceramic tile. In my case the Z-shaped hook fitted the best. I’ve taken the measurements, sliced the ring with the help of a disc grinder, straightened each piece with the hammer, welded the base to the hook, drill the necessary holes, polish before painting, apply a thin layer of bronze paint:

hook5 hook6 hook1
hook3 hook4 hook2

At this point you can install the panel on the roof. All you have to do is to connect the panel’s positive/negative wires to the charge controller then you can use the resulted DC current to power on some DC appliances (such as DC bulbs), to store that DC current into a battery and then from battery you can connect a 12 VDC to 220 VAC power inverter that will supply a 110/220 VAC for your light bulbs, laptop and TV (or whatever).

Whether you have an UPS unit that you don’t use it anymore or you just don’t want to spend your money on a 300W power inverter you might “convert” (actually just use directly) your UPS as a power inverter:

  • take out the UPS battery and connect instead the battery’s positive respectively the negative terminals of your charge controller
  • turn on the UPS, it will provide to you 220VAC that can be used by any of your appliances (with respect to voltage and power usage).

If you want to monitor the voltage provided by the solar panel and the instant amperage then you might buy some voltmeter/ammeter then connect them in parallel respectively in series with your circuit (I’m not going through all the technical details here). In order to protect your circuit for over-voltage and/or overconsumption then you should link in series some blow glass fuses.

I’ve used my old 300W UPS unit as power inverter and also I’ve installed some meters, fuses, switches so that I need a custom-made case for this unit (I know, wood is probably the worst solution but it was handy):

ups1 ups2 ups3 ups4
ups6 ups7 ups10 ups5
ups9 ups8

How much does the system costed me:

Part name Origin Price (USD)
Solar cells kit eBay 41.75
Charge controller eBay 8.9
2xGlass sheet Local supplier 15
Silicone sealant Local supplier 4
Fuse holder eBay 1.56
Battery clips (black+red) eBay 2
Ammeter eBay 3
Voltmeter eBay 3.7
TOTAL 80

Note that the wooden frame, mounting hooks, screws, current inverter or battery are not included in the total price since I’ve used some “junks” that I’ve found in the junkyard. If I want to increase the energy production then all I have to pay would be something like $60/panel. Not bad!

This summer I intend to build two more solar panels, both with aluminium frames: one with EVA and the other one with Epoxy encapsulation. Additionally I am going to build a small wind turbine (including the electric generator) so that the whole system will provide electricity for the most appliances my parents have in their house. More details to come…

Posted in Hardware | Tagged , , | Leave a comment

Calculul aproximativ al radacinii patrate

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

Dorim sa aproximam valoarea \sqrt{x}.

Lasand la o parte toate celelalte metode cunoscute de extragere a radacinii patrate dintr-un numar, voi incerca sa va prezint o metoda simpla si eficienta.

Metoda se bazeaza pe ideea de a identifica rapid alte doua numere x1 si x2 aflate in vecinatatea lui x si care sunt patratele a doua numere naturale cunoscute y1 respectiv y2. Radacina patrata a lui x se calculeaza ca fiind \sqrt{x}=y_1 +\frac{y_2-y_1}{x_2-x_1}\cdot(x-x_1) (vezi demonstratie)

Exemplu:

Sa calculam \sqrt{26}

  • un numar mai mic de 26 (adica in vecinatatea stanga a sa) si care este patratul unui numar cunoscut ar fi x1=25 (25 este patratul lui y1=5)
  • un numar mai mare de 26 (adica in vecinatatea dreapta a sa) si care este patratul unui numar cunoscut ar fi x2=36 (36 este patratul lui y2=6)
  • nu cunosc nici un alt numar intre 25 si 36 care sa fie patratul vreunui alt numar natural, asa ca le iau pe acestea de “bune”

Calculez radacina patrata a lui 26 dupa metoda inticata mai sus:

\sqrt{26}=5+\frac{6-5}{36-25}\cdot(26-25)=5+\frac{1}{9}\approx 5.11

Sa vedem ce ne arata calculatorul:

Radacina patrata a lui 26

Radacina patrata a lui 26

Eu zic ca 5.11 este o buna aproximare pentru 5.1, nu credeti?

Putem folosi metoda asta si pentru a extrage radacina patrata dintr-un numar urias precum 756811065 (l-am ales la intamplare). Toata “smecheria” este sa impartim numarul asta la un numar care este putere a lui 100 (caci 100=102 si ne vom folosi de lucrul asta), de exemplu la 1002 sau la 1003 sau 1004 samd astfel incat sa obtinem un numar zecimal cat mai “confortabil”, eventual un numar cu 1 sau 4 digiti maxim (numerele >4 digiti devin iar complicate, nu-i asa?).

Ia sa vedem la ce putere a lui 100 putem imparti numarul nostru astfel incat ceea ce obtinem sa fie un numar a carui parte intreaga o putem incadra intre doua alte patrate a caror radacini sa le cunoastem deja:

  • daca impart la 1001=100 obtin \frac{756811065}{100}=7568110.65 – nu cunosc “din cap” doua numere a caror patrate sa fie invecinate cu acesta (sau chiar daca as putea sa le deduc nu are rost sa ma complic)
  • daca impart la 1002=10000 obtin \frac{756811065}{10000}=75681.1065 – iarasi este un pic prea mare si nu vreau sa lucrez cu numere uriase, nu-i asa?
  • daca impart la 1003=1000000 obtin \frac{756811065}{10000}=756.811065 – aici parca m-as mai descurca (in sensul ca stiu din cap niste patrate apropiate):
    • de ex. stiu ca x1=252=625 si ca x2=302=900 iar 756.8 este un numar care se afla intre astea doua

Ideea e ca putem rescrie numarul 756811065=756.811065*1003

Deci \sqrt{756}=25+\frac{30-25}{900-625}\cdot(756-625)=25+\frac{131}{55}\approx{27.382}

Nu uitati ca noi cautam radacina patrata din 756811065=756.811065*1003 si nu din 758.

Cine este radacina patrata a lui 1003 ? Pai 1003 se mai scrie ca (102)3=(103)2.

Deci \sqrt{100^3}=\sqrt{(10^3)^2}=10^3

Ca atare as putea spune cu mana pe inima ca \sqrt{756811065} \approx 27.382\cdot 10^3 adica 27382

Ce zice calculatorul?

Radacina patrata a lui 756811065

Radacina patrata a lui 756811065

Nu-s chiar asa aproape de adevar dar nici extrem de departe, daca tinem cont cat de mare este numarul.

Pentru o aproximare mai buna cautati acele numere x1 si x2 care sunt cele mai apropiate de numarul vostru x. As fi putut alege de exemplu x1=272 respectiv x2=282 iar 758 s-ar fi nimerit exact intre ele, caz in care \sqrt{756811065} \approx (27+\frac{28-27}{28^2-27^2}\cdot(756-27^2))\cdot 100^3\approx 27491 ceea ce este deja o mult mai buna aproximare, nu-i asa?

Demonstratie
Demonstratia se bazeaza pe putina geometrie.

sqrtgraphPe axa-x am trecut valorile lui x, pe axa-y am trecut valorile lui y (adica radacina patrata corespunzatoare fiecarui x).

Observam ca in Δ ABC latura AC=x2-x1 iar latura BC=y2-y1. De asemenea, in Δ ADP latura AD=x-x1 iar latura PD=√13-y1.

Observam ca in Δ ABC ≈ Δ ADP (UUU) => \frac{BC}{AC}=\frac{PD}{AD} adica \frac{y_2-y_1}{x_2-x_1}=\frac{\sqrt{13}-y_1}{x-x_1}

Deci \sqrt{13}=y_1+\frac{y_2-y_1}{x_2-x_1}\cdot(x-x_1)=3+\frac{4-3}{16-9}\cdot(13-9)=3+\frac{4}{7}\approx 3,57 QED.

Facem si o verificare cu calculatorul de buzunar:

Radacina patrata a lui 13

Radacina patrata a lui 13

 

Posted in Algebra, Calculus, Maths | Tagged , , | Leave a comment

ATX PSU: from junkyard to working bench

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

I had few old computers that I had to recycle. Because I’m a sentimental guy (or just stingy?) I didn’t wanted to throw them out through the window so I began to collect everything that I could use later in some DIY projects.

Today I found that it would be nice to have a variable bench power supply. One could get one for twenty bucks plus shipping from eBay or if you want something fancy you could pay like one hundred bucks for something like this.

Another option would be to use one of your scrap computer from the junkyard, take out its power supply unit, do some minor adjustments and Voilà!, you have got a bench power supply for free:
atxpsu

Question: is it complicated to convert an ATX power supply to a bench variable PSU?

Answer: No. I’m not an electrician nor I’m working on electronics branch, in fact I started with small projects just few months ago. With proper tools and patient this task is a breeze.

Requirements

  1. an (old) working ATX PSU
  2. heat shrinking tubes (preferably different colours and sizes)
  3. 1 x main switch (rocker power switch 4-pins)
  4. 1 x load current switch (toggle switch 6-pins)
  5. 6 x binding posts (1 black for ground and 3/5 red for loads)
  6. 2 x dummy load resistor (5W 10Ω ceramic resistor)
  7. 2 x 330Ω resistors
  8. 2 x light emitting diode 5mm LED (1 red, 1 green)
  9. 1 x prototype paper PCB

atxreqOf course, you will need some tools like multimeter, soldering gun and  solder and soldering paste, a drill, pliers, etc.

Instructions

I followed this tutorial so I’m not going to duplicate the story. Please check that video and even the project’s page. Another good tutorial could be found here.

Final notes

Although I followed the video tutorial step by step I wasn’t able to succeed replicating that project. The problem was that the ATX PSU  started for 1-2 seconds than stopped unexpectedly. By checking the circuit diagram from the other tutorial I made a small change in the project’s design by adapting its circuit diagram (excepting the fuses which by the way are a very good idea):

Project gallery

I have taken few photos so that you can see how things works:

atxpsu_1atxpsu_2atxpsu_3atxpsu_4atxpsu_5atxpsu_6

Posted in Hardware | Tagged , , , , , , , | Leave a comment

Query eBay purchase history

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

eBay is great except that they don’t want to show you how much you have spent over a period of time. Maybe this is a strategic feature, I don’t know and I don’t care. I just need it!

Lately I’ve started working on some projects that requires cheap parts (in order to keep the project cost low). eBay is happening to be a good market for those Chinese cheap parts (let’s face it: almost everything is made in China, nowadays), so I began to trade on eBay quite a lot. The platform is great but some important feature is still (intentionally) missing: the summary of your purchases.

This can be accomplished quite easy if you save the HTML page on disk and then parse its content with the help of some data extraction utility (eg. awk).

My solution is using this approach, so I have two scripts for this:

Now all I have to do is to save the eBay purchase history to a file on local disk and then call the ebay_total script that will list all items and the total summary (expressed in original currency and also converted to EUR/my local currency):

ebay_total -f /tmp/My_eBay_Purchase_History.htm

The output of the command above will look like:

----------------------------------------------------------------------
Nr    Date        Shipped date    Price    Item description
----------------------------------------------------------------------
1    04/09/13    04/10/13    $2.75    35g Soldering Solder Paste Flux Cream Welding Paste NT
2    04/08/13    04/08/13    $1.59    1m Power Supply Multimeter Alligator Testing Cord Lead Clip to Banana Plug cable
3    04/08/13    04/09/13    $1.56    2 Pcs Fuse Holder FH043 10A 250V for 5x20mm Fuse NEW
...
26   03/16/13    03/18/13    $1.05    2.5FT 2.0MM Desoldering Braid Solder Remover Wick Cable
----------------------------------------------------------------------
TOTAL: 26 items => 54.38 USD (~ 41.57 EUR ; 182.18 RON)

Note: one can use a software to connect to his/her eBay account and to watch biddings/purchase history. I don’t like this approach, especially when we are talking about an eBay account!

Posted in linux, shell | 4 Comments

Finding which Linux module is needed for your hardware

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

Your Linux distro or even the stock Linux kernel comes with all thinkable drivers for all those hardware that they supported. Most of them are preselected by default (base on hardware architecture) to cover a wide palette of hardware.

However, if you are going to compile a Linux kernel only for your system, you should select/include only those modules that have something to do with your system. By cutting down the default kernel configuration you will save time, memory and will make your system faster.

How could you find out what drivers are need it by your system?If you have already a functional system or if you can boot a Live Linux CD then all you have to do is to look into the Linux system filesystem (sysfs) and to determine which device is using what driver.

For instance, to determine what driver is my network card using, first I need to know the network interface (eq. eth0, wlan0, etc) I want to find what where does the symlink /sys/class/net/<net-if>/device/driver/module point to.

In my case if I run the command ls against the path specified earlier I get the relative path to the driver module for my network card (where <net-if>=wlan1):

user@rpi-gentoo ~ $ ls -l /sys/class/net/<net-if>/device/driver/module
/sys/class/net/wlan1/device/driver/module -> ../../../../module/ath5k

As you can see the driver needed by this device is called ath5k. To setup the kernel to include this driver all I have to do is to search a configuration parameter named CONFIG_%ATH5K% (where % means one or more characters).

You should not be surprised if you will find more than one parameter with the pattern shown above because there could hundreds devices from that vendor. For example, the following configuration parameters contain the pattern show earlier:

CONFIG_ATH5K
CONFIG_ATH5K_AHB
CONFIG_ATH5K_DEBUG
CONFIG_ATH5K_PCI

If you want to understand what means any of those drivers I suggest you to look them up on Linux Hardware Database (lhwdb.org). The query string for any kernel configuration parameter is:

http://lhwdb.org/cfg/parameter

Note: the CONFIG_ prefix in the example above is stripped, so if the kernel parameter is named CONFIG_parameter you should use only the parameter part in the lhwdb.org query (or just go to lhwdb.org and use the damn search box :o).

Ok, so you’ve found out what is the driver name for you network card, right? But there could be at least 10-20 different drivers and finally, just to determine the kernel configuration name you have to search the content of at least 1600 different kernel Makefiles. It could be done automatically, though:

#!/bin/bash
TMP=$(mktemp)
FLIST=$(mktemp)
find -type f -name Makefile|sort -u > $FLIST
for f in $(find /sys/ -type l -name driver 2>/dev/null) ; do
        test -e $f/module && basename `readlink $f/module`
done|sort -u >$TMP

for m in $(cat $TMP);do
        echo -e "\e[33;1;31m[$m]\e[0m"
        for f in $(cat $FLIST);do
                grep -io "(CONFIG_.*$m.*)" $f
        done|sort -u
done|sed -e 's/^.*(//g;s/).*$//g'

rm -f $TMP $FLIST

The output of the code above run on my system looks like this (but it could look different on your system):

[ahci]
CONFIG_EXYNOS4_DEV_AHCI
CONFIG_IMX_HAVE_PLATFORM_AHCI
CONFIG_SATA_ACARD_AHCI
CONFIG_SATA_AHCI
CONFIG_SATA_AHCI_PLATFORM
[ath5k]
CONFIG_ATH5K
CONFIG_ATH5K_AHB
CONFIG_ATH5K_DEBUG
CONFIG_ATH5K_PCI
[coretemp]
CONFIG_SENSORS_CORETEMP
[drm]
CONFIG_DRM
CONFIG_DRM_AST
CONFIG_DRM_CIRRUS_QEMU
CONFIG_DRM_EXYNOS
...
CONFIG_DRM_I915
...
[ehci_hcd]
CONFIG_USB_EHCI_HCD
CONFIG_USB_EHCI_HCD_PLATFORM
[snd_hda_intel]
CONFIG_SND_HDA_INTEL
[uhci_hcd]
CONFIG_USB_UHCI_HCD
[usbcore]
[usbhid]

I searched on lhwdb.org and I’ve determined what represents each of these drivers and I’ve decided that those written with bold are the ones I need.

To include these and only these drivers on my Linux kernel, all I have to do is to step in each class of “Device drivers” (the lhwdb.org tells you even the kernel menus where to find these configuration parameters) and to select only those parameters that match with those shown by the output of the script above.

Final note: The method shown above it’s just the tip of the iceberg since it covers the process of finding the core drivers for the system. In order to determine each tiny driver used by each tiny device you might have, I would recommend reading the “Linux kernel in a Nutshell” by Greg Kroah-Hartman, which presents more techniques regarding this topic.

Posted in kernel, linux | Tagged , , | 1 Comment

Linux commands easily overlooked

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

Unlike other operating systems, GNU/Linux comes with a enriched application tool-chain and thus, some of them are easily overlooked by the average Linux user.

While learning about “how to create a Linux system from scratch” I’ve found that, just if we are limiting to the base components we’ll find few dozens of useful tools that either we haven’t known that they exist or worst, we forgot them on the way.

I’ve created a list of those commands, grouped by their container, as a reference for the future use/practice:

  • Util-linux
    • cfdisk (like fdsik but using nice ncurses menus)
    • column – Formats a given file into multiple columns
    • findmnt – Is a command line interface to the libmount library for work with mountinfo, fstab and mtab files
    • lsblk – Lists information about all or selected block devices in a tree-like format
    • lscpu – Prints CPU architecture information
    • pg – like more/less but displays a text file one screen full at a time
    • script – Makes a typescript of a terminal session
    • scriptreplay – Plays back typescripts using timing information
    • sfdisk – like parted, a disk partition table manipulator
    • whereis – Reports the location of the binary, source, and man page for the given command
  • Psmisc
    • pstree – Displays running processes as a tree
  • Procps
    • pmap – Reports the memory map of the given process
    • pwdx – Reports the current working directory of a process
    • w – Shows which users are currently logged on, where, and since when
  • E2fsprogs
    • badblocks – Searches a device (usually a disk partition) for bad blocks
    • e2freefrag – Reports free space fragmentation information
    • e4defrag – Online defragmenter for ext4 filesystems
    • filefrag – Reports on how badly fragmented a particular file might be
  • Shadow
    • lastlog – Reports the most recent login of all users or of a given user
    • pwck – Verifies the integrity of the password files /etc/passwd and /etc/shadow
    • pwconv – Creates or updates the shadow password file from the normal password file
    • pwunconv – Updates /etc/passwd from /etc/shadow and then deletes the latter
  • Coreutils
    • nl – Numbers the lines from the given files
    • nohup – Runs a command immune to hangups, with its output redirected to a log file
    • od – Dumps files in octal and other formats
  • Iana-etc
    • /etc/protocols – Describes the various DARPA Internet protocols that are available from the TCP/IP subsystem
    • /etc/services – Provides a mapping between friendly textual names for internet services, and their underlying assigned port numbers and protocol types
  • Inetutils
    • rcp – Performs remote file copy
    • rexec – executes commands on a remote host
    • rlogin – Performs remote login
    • rsh – Runs a remote shell
    • talk – Is used to chat with another user
  • Gawk
    • pwcat – Dumps the password database /etc/passwd
  • IPRoute
    • lnstat – provides Linux network statistics. It is a generalized and more feature-complete replacement for the old rtstat program
    • nstat – Shows network statistics
    • routel – A component of ip route. This is for listing the routing tables
    • rtstat – Route status utility
    • ss – Similar to the netstat command; shows active connections
  • Man-DB
    • apropos – Searches the whatis database and displays the short descriptions of system commands that contain a given string
    • whatis – Searches the whatis database and displays the short descriptions of system commands that contain the given keyword as a separate word
  • Sysvinit
    • last – Shows which users last logged in (and out), searching back through the /var/log/wtmp file; it also shows system boots, shutdowns, and run-level changes
    • lastb – Shows the failed login attempts, as logged in /var/log/btmp
Posted in linux | Tagged , , , , , , , , , , , , | 2 Comments

Create your own GNU/Linux system. From scratch!

Please note that this blog has been moved.

Now it has its own domain: mynixworld.info :-)

If you want to read the latest version of this article (recommended) please click here and I open the page for you.

Although it might sound odd, creating your own distro from scratch makes sense in certain situations:

  • you want to create a small self-contained (eventually read-only) system that delivers only those components that you want
    • it might be, for instance, a rescue disk, a diagnosis toolkit, whatever
  • you want to create the base of a system that you are going to deploy on your entire organization and, of course, to control and to maintain it by yourself; you want also that every component being installed to be tuned for that particular hardware and for that particular user usage.
  • you design an embedded system and you need a basic OS to help you to control the hardware.
  • you only want to have some fun and, being wired like me, you haven’t found anything more exciting than spending few hours/days building step by step the entire GNU/Linux system.

To get a grasp of this idea it would worth mentioning that you could, with little effort, create a self-contained system just enough to run the Apache web server, and this in only 5-8MB of disk space!

When I’m saying “create your own GNU/Linux system” I mean exactly that, a GNU/Linux system and not a system developed from scratch by yourself (including the kernel, system tools, etc). That would not be wired but a tremendous effort which, despite the fact that it will pay off eventually, it would require more than a 100-lines post on my blog.

The whole idea is to start with a working (HOST) system, an empty hard drive (or a raw disk image) and by downloading, compiling and installing some applications/libraries from the Internet on that new disk, to end with a self-contained working GNU/Linux system assembled step by step by yourself.

Unlike the other GNU/Linux distributions out there (Gentoo, Sorcerer,etc) the LFS is a type of an online book that will guide you step-by-step how to install a Linux From Scratch (thus LFS). It’s very well detailed (like a install Linux From Scratch for dummies) and the team that maintain this project are willing to help you on their IRC channel. Of course, if you work by the book the chances to fail are minimal.

I did it, it was fun, I’ve ended with a 600M disk image (a SMP x86_64 GNU/Linux tested on a qemu emulator; user=root, pwd=lfs) that contains the base of a working Linux system (no X11, of course). In a nutshell, the steps I’ve done are the the following:

  1. create a raw disk image file (dd if=/dev/zero of=image.raw bs=X count=Y)
  2. create partition and filesystems for your disk (fdisk/mkfs.ext*)
  3. create a filsystem hierarchy based on the standards set for UNIX-like operating systems (/bin,/boot,/dev,/etc,/home,/lib,/media,/opt,/root,/sbin,/tmp,etc).
  4. create a compiler toolchain for your new system:
    • step1: download/unpack/configure/install the Binutils,GCC,Linux API Headers,GLibC using the HOST GLibC library (dependency by the HOST system)
    • step 2: configure/install the Binutils,GCC using the newly create GLibC at step 1 (now it’s an independent/self contained toolchin)
  5. download/unpack/configure/test/install the libraries/applications for a temporary system (like ncurses,diffutils,coreutils,findutils,grep,sed,perl,tar,bzip2,xz,gzip,etc)
  6. download/unpack/configure/test/install the libraries/applications that will be self-contained, independent base of the new system (like Linux API headers,GlibC,Binutils,GCC,Util-linux, E2fsprogs, Shadow, Coreutils, Inetutils, Perl, Autoconf, Automake, IPRoute, SysVInit, Udev, GRUB, etc)
  7. create/configure the system bootscripts (like /etc/hosts,/etc/sysconfig,/etc/resolv.conf,/etc/sysconfig/network,/etc/sysconfig/clock,/etc/rc.d/*,etc/init.d/*,/etc/inittab,/etc/fstab,etc)
  8. download/unpack/configure/install the Linux kernel
  9. install the GRUB boot loader on the disk, configure the boot menu, reboot the new system

If you would stick to the English localization and if you are willing to discard the Linux documentation/manuals, you could easily lower the disk footprint to 300MB. If you would discard the GCC compiler toolkit and its libraries you could shrink the whole thing to 100MB. If you want something more extreme, like the 5-8MB Apache web server in the example above, you would need more time to test and to shrink every bit of it but the bottom line is that “it’s possible!”.

Posted in distro, linux | Tagged | 2 Comments