Code Snippet

Just another Code Snippet site

Random Post :




Pexels – Des milliers de photos libres de droit à portée de clic – Korben

Si vous cherchez des photos pour illustrer vos articles de blog ou pour faire croire à vos amis Facebook que vous êtes un photographe hors pair, je vous invite à vous rendre sur Pexels. Sur ce site, vous trouverez des milliers de photos libres de droits, accessibles via le moteur de recherche, mais aussi classé > Lire la suite

Source: Pexels – Des milliers de photos libres de droit à portée de clic – Korben

How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6

LEMP stack is a group of open source software to get web servers up and running. The acronym stands for Linux, nginx (pronounced Engine x), MySQL, and PHP. This tutorial explains how to install the required repos to download nginx and php-fpm, how to

/etc/php.ini :

cgi.fix_pathinfo=0

/etc/nginx/nginx.conf :

worker_processes  4;

/etc/nginx/conf.d/default.conf :

    location / {
        root   /usr/share/nginx/html;
        index index.php  index.html index.htm;
    }

    location ~ \.php$ {
        root           /usr/share/nginx/html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

/etc/php-fpm.d/www.conf :

user = nginx
group = nginx

Restart all services :

service php-fpm restart
service nginx restart

Source: How To Install Linux, nginx, MySQL, PHP (LEMP) stack on CentOS 6 | DigitalOcean

, ,

[Ownlcoud] Tips

Export addressbook :

https://OWNCLOUD_DOMAIN/owncloud/remote.php/carddav/addressbooks/USERNAME/ADRESSBOOK_NAME?export

[Java] Get started with java JVM memory (heap, stack, -xss -xms -xmx -xmn…)

Java “Heap” is a continous memory region where all Objects data will be stored (by data, we mean instance of class, primitive and references). It’s a big part of the process heap.
It can be configured using the following parameters :

  • -Xmx : max heap size (ex: -Xmx1024)
  • -Xms : min heap size. Having -Xms = 1.8GB (32bit) can be bad, because you don’t let memory for anything else.
  • -Xmn : the size of the heap for the young generation
    Young generation represents all the objects which have a short life of time. Young generation objects are in a specific location into the heap, where the garbage collector will pass often. All new objects are created into the young generation region (called “eden”). When an object survive is still “alive” after more than 2-3 gc cleaning, then it will be swap has an “old generation” : they are “survivor” .
    Good size is 33%
  • -XX:NewRatio : the same as Wmn, but using a % (dynamic fs static -Xmn option). -XX:NewRatio=3 means that the ratio between the old and young generation is 1:3
  • -XX:NewSize – Size of the young generation at JVM init. Calculated automatically if you specify -XX:NewRatio
  • -XX:MaxNewSize – The largest size the young generation can grow to (unlimited if this value is not specified at command line)
  • -XX:SurvivorRatio : “old generation” called tenured generation, ratio, in %. For example, -XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6 (eden is where new objects are created)
  • -XX:MinHeapFreeRatio: default is 40%. JVM will allocate memory to always have as minimum 40% of free memory. When -Xmx = -Xms, it’s useless.
  • -XX:MaxHeapFreeRatio: default is 70%. The same as Min, to avoid unecessary memory allocation.

[PL/SQL] Random

select dbms_random.random from dual;

RANDOM
_____________
1393936551

E.g.: Generating a random number between 0 and 1.

select dbms_random.value from dual;

VALUE
_____________
1

E.g.: Generating a random number from a range, between 1 to 1000.

select dbms_random.value(1,1000) num from dual;

NUM
_____________
611

E.g.: Generating a 12 digit random number.

select dbms_random.value(100000000000, 999999999999) num from dual;

NUM
_____________
175055628780

E.g.: Generating an upper case string of 20 characters

select dbms_random.string('U', 20) str from dual;

STR
_______________________
VUOQOSTLHCKIPIADIZTD

E.g.: Generating a lower case string of 20 characters

select dbms_random.string('L', 20) str from dual;

STR
____________________
xpoovuspmehvcptdtzcz

E.g.: Generating an alphanumeric string of 20 characters. There is a bug in Oracle 8i that results in special (non-alphanumeric) characters such as ‘]’ in the string. This is resolved in Oracle 9i.

select dbms_random.string('A', 20) str from dual;

STR
__________________
sTjERojjL^OlTaIc]PLB

E.g.: Generating an upper case alphanumeric string of 20 characters

select dbms_random.string('X', 20) str from dual;

STR
________________________
SQ3E3B3NRBIP:GOGAKSC

E.g.: Generating a string of printable 20 characters. This will output a string of all characters that could possibly be printed.

select dbms_random.string('P', 20) str from dual;

STR
___________________
*Yw>IKzsj\uI8K[IQPag

Previous Posts Next posts