2009-12-24

Quick Tips

  1. When using Vidalia 0.1.15, Tor 0.2.1.19 and Privoxy 3.0.6, use the proxy 127.0.0.1:8118. The port 8118 is the default in Privoxy.

  2. In VirtualBox to access the shared folders:
    net use x: \\vboxsvr\shared /persistent:yes
    To remove such a shared folder:
    net use x: /delete

2009-12-16

Philosophy through IT

I like to make my own philosophy. Because I am a programmer, I inevitable use terms from that area to describe some ideas or concepts. I want to put some of them here, more as an example and maybe later as a guideline in writing a book.
  • A context is an existential environment with a set of binding rules.
  • An environment is a space that may contain objects.
  • An existential environment is an environment that has a conglomerate of factors that supports existence.
  • Existence is a sequence of events in a time line, a space and abiding by a set of binding rules, thus existence is a sequence of events in a time line and a context.
  • An object is a conglomerate of elements that exist in a context and are tied together by a set of binding rules.
  • A persistence is an existence without a time frame.
  • A time frame is a well defined portion in a time line. 
  • An event is a manifestation in a time line.
  • A coincidence is an alignment of several events without a programmatic schedule.
Lets define the context eliminating the keywords:
A context is a space that may contain one or more conglomerates of elements presented within, tied together by a set o binding rules, that participate in a sequence of manifestations in a time line, a space and abiding by a set of binding rules, that has a conglomerate of factors that supports itself.
As you can see here, we have learned that the binding rules keep everything (elements, factors) together. Moreover existence and context are dependent one on another; existence without a context is just a time line (or time); context without existence is just a space. Thus we have learned what time and space are.

Now lets use these basic concepts to create some new ideas and explore if they are correct:
  • Life is a coincidence, while the universe is not.
Exploring the idea:

Life was possible because a sum of events aligned to make it happen. Because life manifests in a time line and an environment, if we assume the lack of a scheduling force, it is a coincidence. Arguably, but without any strong evidence, some assume the presence of a scheduling force (that is a deity) and thus the life is created by the force and not by random events that aligned successfully, resulting that the life is not a coincidence.
Universe is not a coincidence because it started simultaneously with the time line, therefore no events have been aligned for its inception. Arguably, if the time line existed before the universe, then the universe may be a coincidence.
If life is not a coincidence, then it's safe to assume that the scheduling force may interfere at any time in the sequence of events that forms it. But if we assume that this scheduling force exists, then we may safely guess that it appeared as a factor in the universe. This makes the scheduling force a persistent object.
Usually the scheduling force (deity) is thought to exist outside of space and the time line. This assumption breaks the definition of the existence and is impossible to demonstrate. Moreover, this assumption makes the scheduling force abstract (undefined).
It's therefore a matter of faith how people consider life and universe relative to coincidence.

2009-11-25

Script Integration Test

The main problem when writing a javascript inside a blogger post is that the editor interprets < and > as portions of html tags, even if they are inside the <script> tag. The solution presented as an example here is to create two string variables called lt and gt and use them instead. On the other hand, to write the code only once, it is put inside a string variable and then evaluated. To display it properly the two conflicting characters should be transformed again using a function that replaces their occurrences. You may also be aware that the code should be on a single line, because a new line creates html markup inside the script.

2009-11-21

MinGW Developer Studio 2.05 cu MinGW 5.1.6

MinGW Developer Studio 2.05 de la Parinya Software are inclus o versiune de MinGW mai veche (posibil incepand cu 3.1.0-1 si mai mica decat 3.4.5, pentru ca __MINGW32_VERSION este 3.7, iar __W32API_VERSION este 3.2). In MinGW 5.1.6 __MINGW32_VERSION este 3.15.2, iar __W32API_VERSION este 3.13. Cele doua valori se gasesc in fisierele _mingw.h si w32api.h din directorul include. De fapt suita este interesata de prezenta fisierelor g++.exe, gcc.exe si gdb.exe in directorul bin din cadrul directorului MinGW. GCC este o colectie de compilatoare, iar G++ este compilatorul pentru C++ din cadrul acestei colectii. In versiunea de MinGW care vine impreuna cu suita, compilatorul are versiunea 3.4.2, iar in MinGW 5.1.6 are versiunea 3.4.5. Pentru a afla versiunea se foloseste comanda:

gcc -dumpversion

Daca se doreste instalarea noii versiuni se descarca de pe situl http://www.mingw.org/ fisierul MinGW-5.1.6.exe. In momentul rularii, acest fisier va descarca pachetele necesare instalarii:

  • mingwrt-3.15.2-mingw32-dev.tar.gz,
  • mingwrt-3.15.2-mingw32-dll.tar.gz,
  • w32api-3.13-mingw32-dev.tar.gz,
  • binutils-2.20-1-mingw32-bin.tar.gz,
  • gcc-core-3.4.5-20060117-3.tar.gz,
  • gcc-g++-3.4.5-20060117-3.tar.gz,
  • gcc-g77-3.4.5-20060117-3.tar.gz,
  • gcc-ada-3.4.5-20060117-3.tar.gz,
  • gcc-java-3.4.5-20060117-3.tar.gz,
  • gcc-objc-3.4.5-20060117-3.tar.gz,
  • make-3.81-20090914-mingw32-bin.tar.gz.

Ne intereseaza numai G++ din cadrul GCC, prin urmare daca nu vom selecta si alte compilatoare atunci pachetele respective nu vor mai fi descarcate (G77, Ada, Java, Object C). Dupa instalare vom descarca gdb-5.2.1-1.exe din ramura GNU Source-Level Debugger, subramura Current Release_ gdb-5.2.1. Vom instala acest pachet in acelasi director unde am instalat si MinGW. Pentru MinGW Developer Studio nu este necesar sa fie instalat si pachetul care contine executabilul make.exe, asa cum este necesar pentru NetBeans. In general nu se recomanda amestecarea pachetelor MSYS cu cele MinGW. Daca este necesar executabilul make.exe, o solutie ar fi redenumirea fisierului mingw32-make.exe in make.exe, desi Netbeans nu a functionat fara executabilul din pachetul MSYS.

Pentru a seta MinGW Developer Studio sa foloseasca noua versiune a compilatorului se va merge in meniu la Edit -> Options..., se alege tabul Compiler si apoi se introduce calea catre MinGW.

Daca programelul de mai jos se compileaza si se construieste fara probleme, atunci instalarea a avut succes. Este necesara o linie libera la urma pentru a nu avea o avertizare.

#include <iostream>
using namespace std;

int main(){
cout << "Hello world!"; }

2009-11-03

Kaze no Gekido

Wind's Fury, the translation of xunrage is written as "Kaze no Gekido" in Japanese. 

2009-10-19

Hello world!

Blogger supports scripted forms:

2009-10-11

Javascript object functions runs on creation

Consider the code bellow:

function myfunction(){
document.write("I was executed.");
}
var f = new myfunction();

The function myfunction is used as a class for the object f, and is also executed at creation time.

The code produces this result:

Static variable in a Javascript object function

Consider the code bellow:

function myfunction(){
var myvariable=19.21;
this.mymethod = function(){ return myvariable; };
this.increase = function(amount){ myvariable+=amount; };
}
var f = new myfunction();
document.write("initial value is " + f.mymethod());
f.increase(0.80);
document.write("<br/>new value is " + f.mymethod());


Because the function myfunction is used as a class for the object f, the local variable myvariable is considered private and it can be accessed only by member functions like mymethod and increase. Therefore this code produces something like this:


2009-10-10

Test Java Presence

To detect if Java is enabled on your computer use the following code:
if(navigator.javaEnabled()){ ... }

Therefore you on your computer.

2009-09-22

Detecting Internet Explorer version with Javascript


This post contains JavaScript.

I have found on the Internet the following function for detecting Internet Explorer version:

function vIE(){return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;}
  • The property navigator.appName returns something like:
  • The property navigator.userAgent returns something like:
  • The function returns the conditional result of the expression <logical> ? <value_for_true> : <value_for_false>
  • Constructor RegExp creates a new object and defines a regular expression as: [0-9] defines a character set formed by any character in the range 0-9; {x,} defines the minimum x number of occurrences used in the match; () creates a subexpression.
  • RegExp.exec(string) returns an array of the matches of the regular expression in the given string or null if no match is found. The returned array contains both matches for the regular expression as well as for present subexpressions. For this reason, the second element in the array is parsed to a float value and returned by the function.
Therefore your Internet Explorer version is:

Note: You may get a wrong version for Internet Explorer 8 if you use Compatibility View, as at the time of this writing Blogspot domain is in the Compatibility View List (more information at this page). Check the list by typing in the Internet Explorer 8 address bar: .

2009-09-02

DKU-5 Driver

Although the Nokia DKU-5 cable is rather old, there is not a fair practice to not support it on Vista. After a few searches on the web, I have found a third party driver for this cable that works with Windows Vista SP2. I put it on MediaFire.

If you have a Nokia 3100 phone like I have, it's recommended to use Nokia PC Suite 6.84 with it because the latest version crashes when I try to install java applications.

This phone supports only MIDP-1.0 and CLDC-1.0 for java applications, 128x128 color display with 4096 colors and MIDI poliphonic sounds.

2009-08-25

Registry value types

Name

Type

Data

(Default)
BigEndian Value
Binary Value
DWORD Value
Expandable String Value
LittleEndian Value
Multi-String Value
None Value
String Value

REG_SZ
REG_DWORD_BIG_ENDIAN
REG_BINARY
REG_DWORD
REG_EXPAND_SZ
REG_DWORD
REG_MULTI_SZ
REG_NONE
REG_SZ

xunrage 
0xff000000
32
0x00000020
A text here
0x00000100
"Line One" "Line Two"
10 00 00
A text here

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\xunrage]
@="xunrage"
"BigEndian Value"=hex(5):ff,00,00,00
"Binary Value"=hex:32
"DWORD Value"=dword:00000020
"Expandable String Value"=hex(2):41,00,20,00,74,00,65,00,78,00,74,00,20,00,68,\
00,65,00,72,00,65,00,00,00
"LittleEndian Value"=dword:00000100
"Multi-String Value"=hex(7):4c,00,69,00,6e,00,65,00,20,00,4f,00,6e,00,65,00,00,\
00,4c,00,69,00,6e,00,65,00,20,00,54,00,77,00,6f,00,00,00,00,00
"None Value"=hex(0):10,00,00
"String Value"="A text here"

Automatic logon script for Windows XP

I have created a command line script for setting the windows registry values to logon automatically in Windows XP. To set these values manually go to a previous post here.

@echo off
echo Automatic Logon in Windows XP

if exist "%SystemRoot%\system32\reg.exe" (
 echo REG.EXE was found...
 goto :runscript
)
goto :exitfail

:runscript
if /i "%1" equ "set" (goto :activelogon) else (if /i "%1" equ "unset" (goto :unactivelogon) else (goto :exitfail))

:activelogon
set /p theuser="Default User Name:"
set /p thepassword="Default User Password:"
echo Running REG.EXE to set the required values...
echo. 
echo Setting DefaultUserName...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultUserName" /t REG_SZ /d "%theuser%" /f
echo.
echo Setting AutoAdminLogon...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /t REG_SZ /d "1" /f
echo.
echo Setting DefaultPassword...
"%SystemRoot%\system32\reg.exe" add "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /t REG_SZ /d "%thepassword%" /f
set theuser=
set thepassword=
goto :exitnormal

:unactivelogon
echo Running REG.EXE to delete the required values...
echo.
echo Deleting AutoAdminLogon...
"%SystemRoot%\system32\reg.exe" delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "AutoAdminLogon" /f
echo.
echo Deleting DefaultPassword...
"%SystemRoot%\system32\reg.exe" delete "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v "DefaultPassword" /f
goto :exitnormal

:exitfail
echo.
echo Failed.
goto :eof
:exitnormal
echo.
echo All operations completed successfully.

You can also download it from the box.

2009-08-24

Some tweaks for Windows XP

To disable the sending of unique player ID for Windows Media Player modify or create the following value:

[HKEY_CURRENT_USER\Software\Microsoft\MediaPlayer\Preferences]
"SendUserGUID"=hex:00

You can use the reg command for this as follows:

reg add "HKCU\Software\Microsoft\MediaPlayer\Preferences" /v "SendUserGUID" /t REG_BINARY /d "00" /f

Set the value back to 01 to send the ID again.

To protect against SYN attacks: From this documentation results that the minimum settings required is as follows:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters]
"SynAttackProtect"=dword:00000002
"TcpMaxPortsExhausted"=dword:00000005
"TcpMaxHalfOpen"=dword:000001f4
"TcpMaxHalfOpenRetried"=dword:00000190

These values are not present on a fresh installed system.


Disable Remote Registry service using the sc command (also discussed here):

sc stop RemoteRegistry
sc config RemoteRegistry start= disabled

Set the default back with:

sc config RemoteRegistry start= auto
sc start RemoteRegistry

2009-08-08

Search Engines in Opera

To set search engines in Opera 9.24 go in Tools -> Preferences... and then choose the Search tab. Now you can click the Add... button to add a new entry or use the Edit... button to edit an existing entry. Of course to delete an entry you have the Delete button. Let's assume you want to add the new search engine from Microsoft, Bing. You put Bing in the Name field, choose an unused letter like b in the Keyword field, and finally the important part, put http://www.bing.com/search?q=%s in the Address field. The %s is replaced with the string you type in the search box. You can also write something like b search_text in the address bar of the browser to invoke a search for search_text on Bing.

Search engines list:

Name

Keyword

Address

Bingbhttp://www.bing.com/search?q=%s
UTraceuhttp://en.utrace.de/?query=%s
Hallodhttp://hallo.ro/search.do?d=en&l=ro&type=both&query=%s
Merriam-Webstermhttp://www.merriam-webster.com/dictionary/%s
WebDEXxhttp://www.webdex.ro/online/dictionar/%s

2009-07-27

Romanian Special Symbols

Ă
Â
Î
Ş
Ţ

ă
â
î
ş
ţ
&#258;
&#194;
&#206;
&#350;
&#354;

&#259;
&#226;
&#238;
&#351;
&#355;

House MD


După ce am văzut House MD, sezonul 1, am rămas în cap cu câteva cuvinte noi :

  • seizure =  a sudden attack (as of disease) ; especially : the physical manifestations (as convulsions, sensory disturbances, or loss of consciousness) resulting from abnormal electrical discharges in the brain (as in epilepsy)
  • nausea = a stomach distress with distaste for food and an urge to vomit
  • spirochete = any of an order (Spirochaetales) of slender spirally undulating bacteria including those causing syphilis and Lyme disease.

Powered by Merriam-Webster.

2009-07-06

What is better?

What is better between an antivirus that removes files wrongly classified as suspicious or the lack of the  antivirus at all?

The antivirus from Comodo Internet Security 3.10.102194.530 is seeing Heur and unclassified mallware everywhere, even when heuristic scanning level is at the lowest. When the incidence of false alarms is so high, the user may be at a real risk of running a virus on his/her computer. At this point turning off the heuristics is the only solution for this suite. I hope they will fix this major flaw, or I will be forced to switch to other products.

2009-07-01

Some new words

Today I've learned new words:
  1. endeavor = strădanie, forţare, efort
  2. sophomore = student in anul doi [univ.]
  3. allegation = afirmaţie (nedovedită), declaraţie
  4. racking = de specula, sfâşietor
  5. foreclosure = prescriere (a unei ipoteci) [jur.]
Translation provided with the help of www.hallo.ro.

2009-06-23

Remove Windows Messenger

To remove Windows Messenger from Windows XP SP2 use the following command at the command prompt:
rundll32 advpack.dll,LaunchINFSection %windir%\INF\msmsgs.inf,BLC.Remove

2009-06-13

CAD-KAS Dividers and Ruler 1.0

Zirkel und Lineal, the name its developer gave it, was given away June 13, 2009 on www.giveawayoftheday.com.

It is somewhat portable I think, because it could be used without being installed. Indeed it is a very basic application. One thing about it bothers me: it doesn’t support antialiasing when exporting to bitmap. According to developer's site, the company has a lot of experience in printing software and when I was printing to PDF file using PrimoPDF (free printer software available at www.primopdf.com), the resulting pdf was antialiased. Then you can import the pdf in Inkscape (available for free at www.inkscape.org) and save the picture as SVG. At that point you have a vector format for your drawing.

But further testing of today's offering helped me discover some major issues a software costing $79 should not have:

  1. The dimension of the ruler, protractor and dividers can't be modified (i.e. the ruler always have 570 mm);
  2. The ruler, protractor and dividers don't repaint when the rubber is used;
  3. The background of the drawing area is always white;
  4. Curves are not considered objects (can't be moved and modified), only lines and rubber;
  5. Rubber instead of deleting existing objects adds a lot of white cicles in front of the existing lines and curves, but under the text;
  6. Text is always in front in the object order, but doesn't repaint either when the rubber is used;
  7. Text clipping for italic fonts is smaller than needed;
  8. Lines objects can't be edited;
  9. Using pencil creates a very large amount of lines;
  10. There is no UNDONE for operations;
  11. Total lack of features like object grouping, ordering and snapping; lack of antialiasing and exporting to more raster (only bitmap is supported) and vector formats; lack of the precision in many operations; lack of layers;
I have to give it a thumb down.

2009-05-26

Remove a service from Windows Registry

To remove a service from Windows registry use the following command at a cmd console (in Windows Vista run the console as Administrator):

sc delete <service_name>

2009-05-21

Some more JavaScript

Some quick tips:

  • To continue a string on the next line in JavaScript, use the \ operator like this:
    var s = "A long text \
    that continues on the next line";


  • Create on the fly functions like this:
    function functionAssembler(operatorSign){
    return new Function("a","b","return a" + operatorSign + "b;");
    }

    Use it to create functions:
    var add = functionAssembler("+");
    var substract = functionAssembler("-");
    var multiply = functionAssembler("*");
    var divide = functionAssembler("/");

    Use the function as always:
    document.write(add(10,5));
    document.write(substract(12,6));
    document.write(multiply(5,3));
    document.write(divide(125,5));

Functions in JavaScript

A Delphi programmer like me, accustomed with strongly typed programming, with clear function block limitation and with classic object oriented style, finds JavaScript overwhelmingly weird. In JavaScript a variable type is interpreted and can happily jump from one type to another, object oriented is based on prototyping starting from the Object primitive type and functions are objects derived from Object.
The Object type has two properties (constructor, prototype) and six methods (eval, toSource, toString, unwatch, valueOf, watch) (see here).
Function is a type descended from Object and has six more properties (arguments, arguments.callee, arguments.caller, arguments.length, arity, length) and two methods (apply, call) (see here).
Below are some code snippets:
Creating an object is as follows:
var myObject = new Object();
or
var myObject = { }
In the second notation, the members of the object are expressed like name:value pairs as:
var myObject = { aname : 15, bname: "test" }
Such a member can be a function like:
var myObject = { myfunc: function(msg){ return msg+msg; } }
A function can be created also as follows:
var f = new Function("a","b","return a+b;");
To create a simple object is used the special keyword this:
function myType(a,b,c){
 this.a=a;
 this.b=b;
 this.c=c;
}
Then you can use this object like:
var f = new myType(10," and ",20);
document.write(f.a + f.b + f.c); // The result is 10 and 20
Create an object with a method:
function myType(a,b){
 this.a=a;
 this.b=b;
 this.add = function(){ with(this) return a+b; }
}
Now use the object:
f = new myType(5,6);
document.write(f.add()); // The result is 11
Note that the add method is present in any object created and if there are 1000 instances of myType, there are also 1000 instances of the function add. To avoid this, use the prototype keyword like this:
function myType(a,b){
 this.a=a;
 this.b=b;
}
myType.prototype.add = function(){ return this.a + this.b; }
Use it like previously explained:
f = new myType(19,11);
document.write(f.add()); // The result is 30
There can be created a helper function like:
Function.prototype.method = function (name, func) {
  this.prototype[name] = func;
  return this;
};
The simple object:
function myType(a,b){
 this.a=a;
 this.b=b;
}
Add a new method like this:
myType.method("add", function(){ return this.a+this.b; });
Then use it as usual:
f = new myType(125,80);
document.write(f.add()); // The result is 205


This is enough to get started with objects for now.

2009-05-08

Problema cu monedele

Într-o urnă se află 4 tipuri de monede, cea mai mare având valoarea de 1£. Ştiind că fiecare monedă există de acelaşi număr de ori şi că suma existentă în urnă este de 14.13£, găsiţi câte monede sunt de fiecare tip şi care este valoarea lor.
Notă: În UK monedele au valorile: 0.01£, 0.02£, 0.05£, 0.10£, 0.20£, 0.25£, 0.50£, 1.00£.
Genul acesta de problemă presupune de fapt rezolvarea unei ecuaţii cu mai mulţi parametri întregi. Ecuaţia problemei este s=n*(a+b+c+d), unde s=14.13 şi d=1. Deci n*a+n*b+n*c+n=14.13 şi trebuie să se afle n,a,b şi c. O astfel de ecuaţie se poate rezolva prin forţă brută, însă ideea de rezolvare este mult mai frumoasă atunci când se studiază posibilele valori ale parametrilor astfel încât să se găsească mult mai repede soluţia. Pentru că a+b+c+1>=1 avem faptul că 0<n<15. Dacă folosim pentru a, b şi c valoarea cea mai mică (a=b=c=0.01) atunci n=14.13/1.03=13.72, deci n<14. Dacă folosim pentru a, b şi c valoarea cea mai mare (a=b=c=1) atunci n=14.13/4=3.5325, deci n>3. Având un interval pentru n şi ştiind că n este număr întreg nu ne rămâne decât să calculam prin forţă brută posibilele valori pentru n.
n=4, atunci 14.13/4=3.5325, valoare imposibilă pentru că rezultatul trebuie să aibă maxim 2 zecimale;
n=5, atunci 14.13/5=2.826, valoare imposibilă;
n=6, atunci 14.13/6=2.355, valoare imposibilă;
n=7, atunci 14.13/7=2.01(857142), valoare imposibilă;
n=8, atunci 14.13/8=1.76625, valoare imposibilă;
n=9, atunci  14.13/9=1.57, valoare posibilă;
n=10, atunci 14.13/10=1.413, valoare imposibilă;
n=11, atunci 14.13/11=1.28(45), valoare imposibilă;
n=12, atunci 14.13/12=1.1775, valoare imposibilă;
n=13, atunci 14.13/13=1.08(692307), valoare imposibilă;
Prin urmare am avut noroc şi am găsit doar o singură valoare posibilă pentru n şi anume n=9. Deci fiecare monedă se găseşte de exact 9 ori. Trebuie să aflăm acum valorile monedelor, conform ecuaţiei a+b+c+1=1.57, deci a+b+c=0.57. Ştim că a≠b≠c şi observăm rapid soluţia a=0.5, b=0.05 şi c=0.02.
Răspuns: Monedele au valorile 0.02£, 0.05£, 0.5£ şi 1£, fiecare monedă fiind de exact 9 ori.
Observaţie: Dacă nu am fi ştiut că valoarea unei monede este de 1£, atunci am fi fost nevoiţi să căutăm n în intervalul [4,78] (14.13/0.18=78.5, 0.18 fiind suma minimă a 4 monede diferite). Găsirea unei soluţii nu implică faptul că soluţia este unică.

2009-05-05

Valori versus Drogati

Originally posted on Aedoh forum (fragments):

Sunt de acord ca nu acordam atentia cuvenita oamenilor importanti care au trait in Romania, insa propria decadenta ne impiedica sa recunoastem valorile. In schimb sa afirmi ca in ziua de azi persoanele valoroase sunt pe cale de disparitie este foarte hazardat. Massmedia e prea preocupata cu isterizarea populatiei ca sa se mai preocupe de lucrurile cu adevarat importante. Este imprumutat modelul de stiri american, in care o stire despre ceva pozitiv nu este stire ci doar ceva negativ reprezinta o stire. Parerea mea e sa ne dea voie si cu arme ca sa putem sa ne impuscam de spaima (i.e. in USA anual 10K oameni mor prin impuscare). In aceste conditii ce se percepe de la televizor e o Romanie negativa. Prin urmare trebuie sa fii concentrat ca Chagdud Tulku Rinpoche (http://www.tibetantreasures.com/tthtml/ctr.htm) ca sa prinzi vagile stiri pozitive. Atunci afli ca avem valori in box, judo, inventii, chiar si retail. O alta solutie este sa mergi sa vezi lucrurile pe viu. De exemplu dupa cate stiri negative auzi despre Bucuresti ai crede ca sunt cam 2 infractori pe metrul patrat si in realitate cobori din tren in Gara de Nord si lucrurile sunt ok, nu te ataca nimeni in secuda numarul doi (de fapt multimea asta de stiri nasoale despre capitala mi se pare o palida incercare de a mai tempera migratia).

Sa polemizez impotriva tehnologiei din cauza unor ciumpalaci care nu o folosesc corespunzator sau isi fac rau folosind-o, nu o s-o fac niciodata. Ma doare in cot de oamenii care se distrug singuri. Daca ar fi dupa mine as lasa lumea sa se drogheze si sa moara. Tratarea drogatilor pe banii oamenilor platitori de taxe e ca naiba. As vrea o lume in care sa pot sa aleg daca sunt solidar sau nu. Eu nu as fi, iar celelalte specii existente pe planeta nu sunt nici ele solidare. Deja incit la violenta ca Mircea Badea si conform noii legi a lui peste fac inchisoare ca indemn la jihad, desi asa mujahid cum sunt nu am nimic cu nimeni.

2009-05-02

Ce au cu calculatorul?

Originally posted on Aedoh forum:

M-am saturat sa aud oamenii ca au ceva impotriva "calculatorului". Nu tehnologia este "evil", ci oamenii o folosesc adesea fara discernamant. Din punctul meu de vedere romanii habar nu au de tehnologie. Priveste pe situl http://www.ted.com/ si convinge-te.
Tinerii din ziua de azi sunt "a new breed", oameni fundamental globalizati si democratici. Internetul a ajutat la stergerea partiala a granitelor, cunoasterea este disponibila in cantitati uriase... Realizezi destul de repede ca nu poti sti si nu poti citi nici macar o zecime din cat exista (i.e. poti petrece cativa ani citind doar situl http://www.howstuffworks.com/). De aceea oamenii de maine se bazeaza pe infrastructura informatica, pe baze de date create automat de motoare de indexare, pe accesul oricand si oriunde la retea. Din toata masa aceasta de informatie trebuie sa alegi ce este relevant pentru tine... Invatamantul clasic, evident, nu face fata nevoii de "customization" a informatiei pentru fiecare individ.
"And there is real Romania", romanii (in proportie mai mare cei tineri) sunt foarte ancorati in Internet pentru ca: massmedia traditionala esueaza dramatic in a furniza continut pentru ei, cu exceptia catorva posturi de muzica si cateva emisiuni cu intindere numarata in secunde, lipsa banilor nu permite vizitarea pe viu a unui loc sau obiectiv, si altele mult mai subtile si complexe. Internetul devine astfel o fereastra spre lume, creaza viata paralela in care inegalitatile par sa fie nivelate. Migrarea asta bineinteles ca enerveaza pentru ca regulile sunt schimbate brusc; multi tineri lipsesc din viata reala, s-au virtualizat; astfel nu mai poti sa ajungi la ei cu produsele tale atat fizice, cat si intelectuale; nu mai participa haotic la munca pe viata pentru un camion de caramizi (i.e. o casa) sau o tona de tabla (i.e. o masina), tot ce au nevoie e apa, paine si bandwidth.

Nu pot sa fiu mai in dezacord de atat cu mentalitatea de genul: Toti copii sunt interesati de droguri si alte tampenii in loc sa se preocupe de ce e specific varstei.
In primul rand este mult prea generalizat toti copiii... Cam cat inseamna acest toti? Lipsa de incredere in tineri nu ajuta la nimic, insa adanceste si mai mult "gap"-ul dintre generatii. Drogurile sunt o problema, dar nu este extinsa la toata generatia, iar in ce priveste tampeniile, cel putin maturii au demostrat ce le-a putut capul in tara asta (i.e. razboaie, comunism, rasism, furt). Apoi este evident ca ce era specific varstei acum 20, 100, 1000 de ani nu mai este specific unei anumite varste acum.

Time has changed, therefore it's time for youth to claim equlity in rights.

Endnote: Cei care vor zice ca am scris intr-o limba neromana, sa considere faptul ca limba romana este o mixtura de toate limbile peste cele cateva sute de cuvinte dacice, asa ca tundeti iarba in alta parte.

2009-04-14

Security tips Windows XP

Two security tips for Windows XP:

1. Disable administrative shares:

Modify the key

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters]

by adding or modifying the value:

"AutoShareWks"=dword:00000000 .


2. Disable remote registry access:

Method 1: Go to Start->Run and type services.msc and then find Remote Registry service, right click it and choose Properties, then change under Startup type the value to Disabled. You can also stop the service right away.

Method 2: Disable Remote Registry service using the sc command:

sc stop RemoteRegistry
sc config RemoteRegistry start= disabled

Set the default back with:

sc config RemoteRegistry start= auto
sc start RemoteRegistry

2009-04-11

String pad function in JavaScript

I've found this mind blowing function for padding a string in JavaScript:

String.prototype.pad = function(l, s, t){
return s || (s = " "), (l -= this.length) > 0 ? (s = new Array(Math.ceil(l / s.length)+ 1).join(s)).substr(0, t = !t ? l : t == 1 ? 0 : Math.ceil(l / 2))+ this + s.substr(0, l - t) : this;
};

Let's break it in pieces :

  • The construction String.prototype.pad = function(l, s, t) extends the functionality of the String object adding a new method called pad, which is a function that has three parameters.
  • Parameters of the function stand for: l=maximal length of the string, s=padding string and t=type of padding (0=left, 1=right and 2=center).
  • An expression which contains an enumeration is evaluated to the last member of the enumeration, therefore the second expression in the return clause will be the result of the function.
  • A logical OR expression is evaluated until a member is true, therefore the expression s || (s=" ") actually means: if s contains something then it is true and left alone, otherwise s will contain exactly one space.
  • Expression (l-=this.length) makes l contain the number of needed characters for the string to have the required length (if the length of the string is 7 and we want it padded to 20 characters, now the l is 13).
  • Is well known the expression like <logical> ? <value_for_true> : <value_for_false>.
  • If new l is greater than 0, then computations are required, otherwise the string (referenced using this) is returned as it is.
  • Math.ceil(<value>) gives the closest upper integer value of the given value.
  • join(<separator>) creates a single string value from the array it is applied to using the given separator string.
  • The expression s=new Array(Math.ceil(l/s.length)+1).join(s) creates a new array with a number of elements equal to the number of times s is required to repeat for the string to be padded, plus one (because there are -1 separators involved in such a join), then the empty values are joined using s as a separator. The new value is now assigned to s. For example, if we want the string "xunrage" padded with s="{}" to the left (t=0) for a total length of l=20, first l became 13, and now l/s.length=13/2=6.5, therefore Math.ceil(l/s.length)=7, following that a new array with 8 elements will be created. When joined, only 7 separators forms the result, therefore s="{}{}{}{}{}{}{}".
  • substr(<start>,<length>) returns a portion of a string that the function is applied to starting at the given position and having the given length.
  • Expression substr(0, t=!t ? l : t == 1 ? 0 : Math.ceil(l/2)) contains two ?: expressions and an assignment in the second parameter of the substr function. The first expression is !t ? l : <the_rest> and the second expression is t==1 ? 0 : Math.ceil(l/2). The value of the entire expression at the end is assigned to t. In our example t=0, therefore !t is true and t=l=13, resulting a string like "{}{}{}{}{}{}{" that will be added to the result.
  • Finally, if something left to be added is added at the end, using substr again. For left padding (t=0) there is nothing left to be added because t=l=13 and l-t=0, resulting in "{}{}{}{}{}{}{xunrage". For right padding t=1, we have t=0 initially (t==1 ? 0 : ...) and l-t=13 at the end, resulting in "xunrage{}{}{}{}{}{}{". For center padding t=2 and we have t=Math.ceil(l/2) which is t=Math.ceil(13/2)=Math.ceil(6.5)=7, finally l-t=13-7=6, resulting in "{}{}{}{xunrage{}{}{}".

Now you can see how amazing this one line of code is.

2009-04-10

Stop autorun.inf from running in Windows

Put the following into the registry:

REGEDIT4
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\Autorun.inf]
@="@SYS:DoesNotExist"

Note: @ stands for (Default) value.

2009-03-29

Fox Pro - Cateva comenzi

O comanda FoxPro utila este aceea care permite filtrarea inregistrarilor dintr-o tabela:
SET FILTER TO [lExpression] [IN nWorkArea | cTableAlias]
de exemplu SET FILTER TO info=123 face accesibile numai inregistrarile pentru care info este egal cu 123. Pentru a elimina un filtru se foloseste comanda fara expresia lExpression.

O alta comanda interesanta este aceea care permite gasirea primei inregistrari pentru care criteriul de cautare este indeplinit:
LOCATE [FOR lExpression1] [Scope] [WHILE lExpression2] [NOOPTIMIZE]
Pentru Scope se poate folosi: ALL, NEXT nRecords, RECORD nRecordNumber si REST.
Pentru a gasi si celelalte inregistrari se foloseste constructia:
DO WHILE FOUND()
   <comenzi>
  CONTINUE
ENDDO
Functia FOUND([nWorkArea | cTableAlias]) determina daca cea mai recenta comanda CONTINUE, FIND, LOCATE sau SEEK a avut succes.
Comanda CONTINUE este folosita dupa comanda LOCATE pentru a gasi urmatoarea inregistrare care indeplineste criteriul de cautare definit de catre LOCATE.

2009-03-17

Problema din Biletul 11

În acest post am menţionat despre o problemă în FoxPro. La punctul e) a fost găsită şi o altă soluţie care a fost reîmpachetată în arhiva foxpro_11b.zip.

2009-03-10

Language issue

Before Unicode there were code pages and fonts like Arial or Times New Roman reflected this like scripts as Arabic, Baltic, Central European, Cyrillic, Greek, Hebrew, Turkish, Vietnamese or Western. I usually have to switch to Central European script in video players in order to see the subtitle in my native language, Romanian. I have recently found out that BSPlayer and JetAudio are unable to make that switch and the subtitle looks awful in Western script. In fact the diacritics are shown wrong, the rest of text is ok. I have found two solutions to this: To use a font that has only one script (the Central European) or to make some changes in Windows settings to sort this thing out.
First solution for me is to use a font called JetRomanian (see it in the BOX).
Second solution is to follow these steps in Windows XP:
  1. Click Start, then go to Control Panel.
  2. From there choose Regional and Language Options.
  3. Then go to the Advanced tab and choose Romanian under the long label "Select a language to match the language version of the non-Unicode programs you want to use:"

That's it. Now I can watch the subtitle as they should be displayed.

2009-02-27

Porturile folosite de Yahoo Messenger 9.0.0.2136

Pentru a afla porturile folosite de către o aplicaţie în Windows XP, se introduce de la consolă comanda:

netstat -aon

Comanda afişează PID-ul (Process Identifier) aplicaţiei. Pentru a afişa toate aplicaţiile care rulează împreună cu PID-ul lor se introduce comanda:

tasklist /svc

Astfel se descoperă că Yahoo Messenger foloseşte porturile:

5101, 3467, 3468, 3473, 5050, 3479, 443, 3470.

2009-02-23

Septica

Jocul are urmatoarele reguli:

 - sunt 32 de carti (opt figuri): 7, 8, 9, 10, J, Q, K si A, fiecare figura avand 4 carti;
 - fiecare jucator primeste initial patru carti, alese la intamplare;
 - jucatorii pun jos cate o carte, alternativ;
 - implicit, cartile de jos sunt luate de primul jucator;
 - daca al doilea jucator pune un 7, sau o carte cu aceeasi figura ca si cea initiala, atunci el va lua cartile;
 - primul jucator poate obiecta in cazul de mai sus, dar doar daca pune de asemenea un 7 sau o carte cu aceeasi figura ca si cea initiala;
 - daca primul jucator nu obiecteaza se ridica cartile;
 - dupa ridicarea cartilor, se primesc noi carti pentru ca fiecare jucator sa aiba 4 carti in mana;
 - 10 si A se considera puncte (in total sunt 8 puncte);
 - castigator este cel care a acumulat cele mai multe puncte la sfarsitul jocului.

Automatic logon in Windows XP

In this article is explained how to turn on automatic logon in Windows XP. Basically it means the modifications of the following keys:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon]
"DefaultUserName"="<user>"
"AutoAdminLogon"="1"
"DefaultPassword"="<password>"


where <user> is the desired user to logon and <password> is the password for that user.

2009-02-19

Problema in FoxPro

Mi-am testat puţin abilităţile de programare în FoxPro 9. Vezi în Box fişierul foxpro_11.zip.
Prietenul Octavian va fi probabil interesat.

2009-01-09

Pentru schimbarea caracterelor

Pentru a schimba caracterele in majuscule in VBA (Visual Basic for Applications) se poate folosi functia UCase(String).
Pentru a schimba caracterele in minuscule se poate folosi functia LCase(String). Vezi un exemplu in fisierul schimba.doc din BOX.