segunda-feira, 26 de maio de 2014

Remove NULL values from PHP arrays with 1 line [Linux]

Remove NULL values from PHP arrays with 1 line

I had an array with something like the following: Array ( [0] => [1] => test [2] => fun ). But I don't want [0], the empty value in the array.

After searching the web for a good solution, I saw that people were using anywhere from 4 to 10+ lines of code to remove null values from arrays. This is obviously overkill so I decided to tackle the problem myself.

Remove NULL values only

$new_array_without_nulls = array_filter($array_with_nulls, 'strlen');

Remove any FALSE values

This includes NULL values, EMPTY arrays, etc. Thanks to Paul Scott for pointing out this method.

$new_array_without_nulls = array_filter($array_with_nulls);

 

terça-feira, 20 de maio de 2014

Jail only a specific user with vsftpd [Linux]

You have 2 options:

 

chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/nonchroot.list

 

# Where file /etc/vsftpd/nonchroot.list should contail the users you don’t want to chroot.

 

OR

 

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd/chroot.list

 

Where the file /etc/vsftpd/chroot.list should contain the users you want to be chrooted to their home. By default all other users should have access to the / (root)

quarta-feira, 30 de abril de 2014

Substituir caracteres por quebra de linha

Quebra de linha manual ( )

 

No Word lica em substituir, ou CTRL + L:

 

Digita o termo de busca, e no outro digite: ^l or ^11

segunda-feira, 14 de abril de 2014

Error: core dump file size limit raised [Linux]

Cause:

core dump file size limit raised to 18446744073709551615 bytes

[notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)

Solution:

Step 7: Remove nss.conf file from httpd conf.d directory
#cd /etc/httpd/conf.d
#mv nss.conf nss.conf.orig
#/etc/init.d/httpd start
Start httpd   [
OK]

segunda-feira, 17 de março de 2014

bash: fork: Recurso temporariamente indisponível [Linux]

Solução:
 
Alterar arquivo /etc/security/limits.conf e descomentar ou adicionar a linha:
 
@users        -       maxlogins       10000
 
Salvar e atualizar as regras:
 
ulimit -a
 


Obs.: As vezes aconteceu comigo, de apresentar o mesmo erro mesmo após a mudança do 'limits', porém existia um shellscript no servidor que criava várias instâncias do processo na memória (ps -aux), o famoso processo zumbie. Resolvi criando um crontab para dar killall -9 a cada 1h.