:::: MENU ::::

Generating lottery codes – how many combinations will I have?

Here is a task. You have to prepare the schema for lottery codes. You have to generate lets say 1 000 000 codes that are 6 characters long. Client’s question is ‘Is that safe?’. This is a good question and you have to do some basic math to be sure that the combination of the code length and alphabet size give you enough combinations so users can’t guess other codes.

Simple example

Alphabet: A, B
Code length: 3 characters

So we have possible combinations:

AAA
AAB
ABA
ABB
BBB
BBA
BAA
BAB

So we have 8 possible combination for 3 characters code with 2 characters alphabet.

23 = 8

Later on, if we have 11 characters in our alphabet and 9 character code we will have

119 = 2 357 947 691

so if client wants 1 000 000 of codes, this scheme seems to be quite secure since is like 0,0424% of all possible combinations.








Removing .git / .svn directories

Sometimes you have to remove directories from your VCS tool.

find . -name .svn -exec rm -rf {} \;

Listing affected directories

find . -name .svn -exec echo {} \;

Useful curl

Headers only

--head – performs HEAD http request (not GET).

curl --head https://www.wp.pl/

Content + headers

--get – performs GET request
-i – include headers

curl --get -i https://www.wp.pl/


Pages:123