Skip to content

Instantly share code, notes, and snippets.

View danilobatistaqueiroz's full-sized avatar

Danilo Batista de Queiroz danilobatistaqueiroz

View GitHub Profile
@danilobatistaqueiroz
danilobatistaqueiroz / downloads.php
Last active August 1, 2018 02:23
using PHP. List files in a private directory
<?php
// abre o arquivo em modo binário
$fullname = './private/'.$_GET['file'];
$fp = fopen($name, 'rb');
$filename = basename($fullname);
// envia os headers
header("Content-Type: application/zip");
@danilobatistaqueiroz
danilobatistaqueiroz / zend_php.md
Last active July 27, 2018 18:58
zend php certification

You can also delete cookies by supplying setcookie an empty value.

setcookie("w3p_cookie", ""); 

Here's the easiest way to unset a cookie:

setcookie('name', 'content', 1);
@danilobatistaqueiroz
danilobatistaqueiroz / ruby_essentials.md
Last active September 27, 2018 13:36
ruby essentials

Tipagem
Por não ser necessária a declaração do tipo, muitos pensam que a linguagem Ruby é fracamente tipada
e com isso o tipo não importaria para o interpretador.
No Ruby os tipos são importantes sim para a linguagem, tornando-a fortemente tipada, além disso,
o Ruby também é implicitamente e dinamicamente tipada, implicitamente tipada pois os tipos são inferidos pelo interpretador,
não precisam ser declarados e dinamicamente tipada porque o Ruby permite que o tipo da variável possa ser alterado
durante a execução do programa

Strings Mutáveis

Install sql alchemy

Create and use a virtual environment to avoid libraries conflict between projects:

creating_a_virtualenv

Install alchemy library:

<?php
function compress_image($source_url, $destination_url, $quality)
{
$info = getimagesize($source_url);
if ($info['mime'] == 'image/jpeg') {
$image = imagecreatefromjpeg($source_url);
} elseif ($info['mime'] == 'image/gif') {
$image = imagecreatefromgif($source_url);
} elseif ($info['mime'] == 'image/png') {
$image = imagecreatefrompng($source_url);
@danilobatistaqueiroz
danilobatistaqueiroz / cmd_tips.md
Last active October 30, 2018 17:41
command windows tips

Printing Windows %PATH% with every entry on a new line

echo %path:;=&echo.%

Listing all environment variables from command line

SET | more

@danilobatistaqueiroz
danilobatistaqueiroz / mongodb_why_and_why_not.md
Last active May 22, 2019 21:07
why mongodb, and really why not!!

That's not to say that MongoDB isn't high performance, but its place probably isn't serving blogs.

NoSQL definitely has its uses. But it's definitely not the answer for everything.
The main advantage of NoSQL is the easily changeable data model.

If your DB is 3NF and you don’t do any joins
(you’re just selecting a bunch of tables and putting all the objects together,
AKA what most people do in a web app),

@danilobatistaqueiroz
danilobatistaqueiroz / creating_a_jasper_report.md
Last active February 6, 2018 01:16
creating a jasper report
@danilobatistaqueiroz
danilobatistaqueiroz / installing_was_on_windows.md
Last active February 11, 2018 04:03
websphere 8.5 ejb tutorial