• YouTube
  • LinkedIn
  • Google

Archives for : Development

Naming files using list from 0 to Z

Today I was coding some scripts and found a little trouble to use a defined pattern.

The pattern is to create files where the sequence starts in 0 (zero) and cannot be repeated until Z.


myfile0.ext, myfile1.ext, myfile2.ext, (...), myfile9.ext, myfileA.ext, myfileB.txt, (...), myfileZ.txt

Well, this is not a big trouble so I did use this code.

But $seq did not gave the expected value of 0 (zero) on first run. Instead, it was blank.

Debugging the variables, I saw that the while never evaluates to true. Attempting to reproduce on command line I saw that in_array($seq, $seqs); always return true. I tryed to use “”, “R” and no matter what value I used, still returning true.

So I change to use STRICT argument for in_array to true and works for ‘A’ through ‘Z’, but not for ‘0’ through ‘9’.

Damn… PHP is right, “0” is not strictly equals to 0. The Chr function return string and range('0', '9') creates an array with integer values.

So, I changed the approach to evaluate all values with STRICT, because I would like to create a nice and clean code without no other functions to be used.

This is the final code that I’m using:

How you can see, I changed the $seqs initial values from ‘0’ to your ASCII code and get back to your value that gave me an array with all values in string type.

See you!

PHP Comparison Error

Today, I was writing a script in PHP to be used in the command line when I came across unexpected behavior (at least on my part).
The script should receive three arguments, the last of them a list containing one or more numeric codes.
Trying to validate this last argument was getting a different result than imagined.
See the code snippet that I was using:

Continue Reading >>

jQuery.html() doesn't work in Internet Explorer

I recently had problems with a javascript code that uses jQuery and it worked in several browsers i.e. Chrome, o Firefox and some versions of Internet Explorer, but that stubbornly refused to work in Internet Explorer 7 and 8.
Here is the code:

After some tests I realized that wasn't a problem in the method, as in other codes it behaved as expected.
So debugging code thoroughly and the answers of the Ajax method realized a small syntax error in HTML and was just correct it and IE 7 displayed correctly the answer.
Then follows the big tip, If you have problems with the method jQuery.html(), check first of all whether the content being written in the element is an html code without errors, because the validation in IE 7/8 will not allow write HTML with errors, no matter how small it is.

Installing Redmine in Nginx on Centos 6. X

In this article I will show you how to set up the Redmine version 2.5.2 (2014-07-06) on a Web server Nginx.

Redmine is a web application for project management. I met him some time ago in one of the companies where I spent and is an excellent free alternative for those who need to manage projects, whether or not development.

Nginx is a Web server that is gaining a lot of space in recent years due to his performance for large quantities of request.

Continue Reading >>

Converting xor, shr and shl from Delphi to PHP

I'm migrating a software made in Delphi to PHP and I came across a problem in a fucking Blessed encryption function.

I suffered a bit trying to rewrite the function does the complexity of the code and with the differences in the results.

The function makes use of operators XOR and SHR in Delphi version. The SHR was relatively easy thanks to experience with bitwise operators and how Delphi documentation says that the operator pulls off bits to the right

Continue Reading >>

How to decrease the size of VMDK virtual disks-part 3

If you want to read the part 1 This tutorial, Click here.
If you want to read the part 2 This tutorial, Click here.

In the previous item made a cloning a disk with a single partition. In the next lines I'll show you how I cloned a disk with a single partition primary and logic for two primary partitions and a logic with a mount point for the swap that originally was in a file.

NOTE: I did use information from this site, to solve problems with the new boot disk. Do as I, always cite your sources.

Using as a basis the information of part 1 This tutorial, We will add a new disk to the virtual machine.

Continue Reading >>

Como diminuir o tamanho de discos virtuais VMDK –; part 2

If you haven't read the part 1, You can access it here.

Continuing the tutorial, We will now start the cloning of disks. The first part of the cloning is a disk that does not contain the operating system. If you want to go straight to the cloning system bootable, You can skip this part and go straight to the part 3.

Time to start cloning. We start the virtual machine in terminal mode (for if you have graphical environment) and login as root or we become root with the command su –; to be able to execute the instructions of partitioning, formatting and cloning, respectively without the need for sudo all command.

In terminal type fdisk-l for list disks and partitions:

Note that our disks appear as being /dev/sda, /dev/sdb, /dev/sdc (I marked in red to make it more visible) and beside its size. That order the, b, (c) is the connection order on IDE port. As our record was included in the Secondary Slave and on Primary Slave is the CDROM (see image on the 1) He is the third system disk, IE, o /dev/sdc.
We will from now on to partition and format the drive. Type the command Fdisk/dev/sdc.

Continue Reading >>

Como diminuir o tamanho de discos virtuais VMDK –; part 1

Where I work we have a few database servers PostgreSQL in different virtual machines running on a VMWare Server. So far so good, It wasn't a detail that was bothering me. All of them using old versions as 8.1 and 8.2, While the current version is the 9.3.
I sought to know and found out that there are version 9.3 for Centos 6.5 that's what we're using for the new servers and decided then unify the three servers in one.

Se você que leu até aqui e pensou “;Unify servers?? That Buro! give zero for him!; know that it was thought and our reality is an appropriate solution.

That said, and with the dilemma resolved, I set out to create a VM using the Vagrant.

The Vagrant is an excellent tool to help us Devops. With the use of it can create machines that can be easily shared among the members of a team. I won't go into the details of its use, just to inform you that I used a Box of Centos 6.5 Basic.

Until here everything was going very well. Set up the VM and installed the software that would use, including PostgreSQL 9.3.

When I went to migrate the production base started some problems. The PGDATA directory, that's where PostgreSQL stores the data in tables, I was with more than 40 GB. Do a dumpall and a Restore on-the-fly was not an option and decided to extract the whole Bank to later restore the VM.

Continue Reading >>

Vagrant init error [Box]

Updated the version of Vagrant em meu computador com Windows 7, and I came across the following error:

C:\Users\Marcos Regis\Projetos\XXXX>;vagrant init
Vagrant failed to initialize at a very early stage:

The plugins failed to load properly. The error message given is shown below.

undefined method '[]; is nil:NilClass

To correct this error in a simple, Navigate to the root directory of your server in my case was

C:\UsersMarcos Regis

Enter the directory .vagrant.d delete/rename the file plugins. json.

TIP: If you use the cmd to start the vagrant, simply enter the commands below

CD% HOMEPATH%/.vagrant.d
Rename plugins. json plugins.json.bak

The error has to do with the plugin vbguest with the new version.

Done that the Vagrant should already work normally.