terça-feira, 2 de outubro de 2018

cURL with FTP

To download certain file: curl -u [username]:[password] 'ftp://[hostname]/[filePath]' -O

To list a directory: curl -s -l -u [username]:[password] 'ftp://[hostname]/[dirPath]'

segunda-feira, 1 de outubro de 2018

Padrões de Endereços

Brasil: [Tipo do Logradouro] [Nome do Logradouro], [Número do Lote], [Complemento (se houver)] - [Nome do Bairro], [Cidade]-[UF] [CEP]

US: [Responsável pela Casa] Se o destinatário não for o responsável pela casa: c/o [Destinatário] Se tem o [PO box code]: [PO box code] Senao: [numero] [Rua], [complemento] [Cidade], [Estado], [ZIP code] AddressLine 1: [numero] [Rua],[Cidade], [Estado abreviado], [ZIP code] AddressLine 2: [complemento]

quinta-feira, 10 de agosto de 2017

Doctrine 2 command sheet

orm:schema-tool

  • vendor/bin/doctrine orm:schema-tool:create: creates database's tables and their columns from scratch according the Entities Metadata.
  • vendor/bin/doctrine orm:schema-tool:update [--dump-sql] [--force]: update database's tables and their columns according the Entities Metadata.

orm:convert-mapping

  • vendor/bin/doctrine orm:convert-mapping [--from-database] [destination metadata type] [destination folder path]: convert Entities Metadata files from the current format to [destination metadata type] format and save them on [destination folder path].
    • The available values for [destination metadata type] are: xml, yaml and annotation.
    • If the param [--from-database] was suplied the input Metadata used to produce the output Metadata will be the current database's tables, instead of current Metadata infos. This is a great way to reverse ingeneer a database to Entities.

orm:generate

vendor/bin/doctrine orm:generate:entities [destination folder path]: generate Entities Classes files from the current Metadata files.

source: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/tools.html

quarta-feira, 19 de julho de 2017

MySQL Backup and Restoration Scripts

#!/bin/bash
PASSWORD=XXXXXX
HOST=XXXXXX
USER=XXXXXX
DATABASE=databasename
DB_FILE=dump.sql
EXCLUDED_TABLES=(
table1
table2
table3
table4
tableN   
)

IGNORED_TABLES_STRING=''
for TABLE in "${EXCLUDED_TABLES[@]}"
do :
   IGNORED_TABLES_STRING+=" --ignore-table=${DATABASE}.${TABLE}"
done

echo "Dump structure"
mysqldump --host=${HOST} --user=${USER} --password=${PASSWORD} --single-transaction --no-data ${DATABASE} > ${DB_FILE}

echo "Dump content"
mysqldump --host=${HOST} --user=${USER} --password=${PASSWORD} ${DATABASE} --no-create-info ${IGNORED_TABLES_STRING} >> ${DB_FILE}

Original source: https://stackoverflow.com/questions/425158/skip-certain-tables-with-mysqldump/425172

quarta-feira, 12 de julho de 2017

Restrict users from changing the wallpaper in Windows

Navigate to the following registry key: HKEY_CURRENT_USER\Software\Microsoft\Windows\ CurrentVersion\Policies\System
Create a new string value called "Wallpaper" and set it to the full path and filename of the image.
Additionally, to specify the display style, create a new string value called "WallpaperStyle" and set it to either "0", "1" or "2" according to the list below.
  • 0 - Centered (Default)
  • 1 - Tiled
  • 2 - Stretched
NOTE: You may need to restart Windows for the changes to take effect.
Original Source: https://support.microsoft.com/en-us/help/555429

terça-feira, 27 de setembro de 2016

Laravel command sheet

  • php artisan make:controller [ControllerName]: creates a new Controller called [ControllerName].

segunda-feira, 12 de setembro de 2016

Receita Bolo de Queijo


Ingredientes:
  • 3 ovos;
  • 100 ml de óleo de soja;
  • 1 colher de sopa margarina;
  • 2 xícaras de fécula de mandioca;
  • 1 xícara de farinha de trigo com fermento;
  • 1 xícara de leite;
  • sal à gosto (eu ponho uma colher chá);
  • 150g de queijo coalho;
  • 7 fatias de queijo mussarela. 3 para forrar a forma e 4 para misturar com os demais ingredientes;
Modo de preparo:
  •  Bata todos os ingredientes no liquidificador (lembre-se de deixar 3 (das 7) fatias de queijo mussarela para forrar a forma. Obs: para evitar sobrecarregar o liquidificador, bata os ingredientes em duas porções.
  • Unte a forma com manteiga e farinha e forre-a com as 3 fatias de queijo mussarela. Obs: usei uma forma com dimensões de 16cm X 26cm X 4cm.
  • Despeje a massa na forma e leve ao forno por aproximadamente 40 minutos à temperatura de 240 à 270 º C.

quarta-feira, 7 de setembro de 2016

MySQL Drop All Tables

SET FOREIGN_KEY_CHECKS = 0; 
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.', table_name) INTO @tables
  FROM information_schema.tables 
  WHERE table_schema = '[dbName]'; -- specify DB name here.

SET @tables = CONCAT('DROP TABLE ', @tables);
PREPARE stmt FROM @tables;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET FOREIGN_KEY_CHECKS = 1;

sábado, 6 de agosto de 2016

Linux Users and Groups Management

Create new User

# adduser [userName]

Note: adduser is a Perl script the helps you tu create the user itselfs and setup their personal informations.

Delete User

# userdel [-r] [userName]

Note: If -r arg was passed, userdel will remove the [userName] home directory

Add existing user to a existing group:

# usermod -a -G [group1[,group2...]] [user]

Remove user from a group

# gpasswd -d [user] [group]

segunda-feira, 11 de julho de 2016

Cygwin Setup command line arguments


 -D --download                     Download from internet
 -L --local-install                Install from local directory
 -s --site                         Download site
 -O --only-site                    Ignore all sites except for -s
 -R --root                         Root installation directory
 -x --remove-packages              Specify packages to uninstall
 -c --remove-categories            Specify categories to uninstall
 -P --packages                     Specify packages to install
 -C --categories                   Specify entire categories to install
 -p --proxy                        HTTP/FTP proxy (host:port)
 -a --arch                         architecture to install (x86_64 or x86)
 -q --quiet-mode                   Unattended setup mode
 -M --package-manager              Semi-attended chooser-only mode
 -B --no-admin                     Do not check for and enforce running as
                                   Administrator
 -h --help                         print help
 -l --local-package-dir            Local package directory
 -r --no-replaceonreboot           Disable replacing in-use files on next
                                   reboot.
 -X --no-verify                    Don't verify setup.ini signatures
 -n --no-shortcuts                 Disable creation of desktop and start menu
                                   shortcuts
 -N --no-startmenu                 Disable creation of start menu shortcut
 -d --no-desktop                   Disable creation of desktop shortcut
 -K --pubkey                       URL of extra public key file (gpg format)
 -S --sexpr-pubkey                 Extra public key in s-expr format
 -u --untrusted-keys               Use untrusted keys from last-extrakeys
 -U --keep-untrusted-keys          Use untrusted keys and retain all
 -g --upgrade-also                 also upgrade installed packages
 -o --delete-orphans               remove orphaned packages
 -A --disable-buggy-antivirus      Disable known or suspected buggy anti virus
                                   software packages during execution.

You can, for example, install packages from DOS command line:

setup-x86.exe -q -P packagename1,packagename2....

source:

SQL query to list Users in MySQL Database

>SELECT CONCAT(QUOTE(user),'@',QUOTE(host)) UserAccount FROM mysql.user ORDER BY user ASC;

sexta-feira, 1 de julho de 2016

Setting up Apache Virtual Hosts on XAMPP

C:\xampp\apache\conf\extra\httpd-vhosts.conf

# NameVirtualHost *:80 # deprecated
# NameVirtualHost *:443 # deprecated

<VirtualHost *:80>
        DocumentRoot "C:/XAMPP/htdocs"
        ServerName localhost
    </VirtualHost>
    <VirtualHost *:443>
        DocumentRoot "C:/XAMPP\htdocs"
        ServerName localhost
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/server.crt"
        SSLCertificateKeyFile "conf/ssl.key/server.key"
    </VirtualHost>

    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/someSite"
        ServerName [dns]
        ServerAlias [fqdns]
        <Directory "C:/xampp/htdocs/someSite">
            Options Indexes FollowSymLinks Includes ExecCGI
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    <VirtualHost *:443>
        DocumentRoot "C:/xampp/htdocs/someSite"
        ServerName [dns]
        ServerAlias [fqdns]
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/server.crt"
        SSLCertificateKeyFile "conf/ssl.key/server.key"
        <Directory "C:/xampp/htdocs/someSite">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
</VirtualHost>

domingo, 26 de junho de 2016

XAMPP set root password

$mysqladmin.exe -u root password secret

Source: https://www.apachefriends.org/faq_windows.html

PHP prefered modules

PHP 5.6

  • php_bz2.dll
  • php_curl.dll
  • php_mbstring.dll
  • php_exif.dll
  • php_gd2.dll
  • php_gettext.dll
  • php_mysql.dll
  • php_mysqli.dll
  • php_openssl.dll
  • php_pdo_mysql.dll
  • php_pdo_sqlite.dll
  • php_soap.dll
  • php_sockets.dll
  • php_sqlite3.dll
  • php_xmlrpc.dll
  • php_xsl.dll

PHP 7

  • php_bz2.dll
  • php_curl.dll
  • php_mbstring.dll
  • php_exif.dll
  • php_gd2.dll
  • php_gettext.dll
  • php_mysqli.dll
  • php_openssl.dll
  • php_pdo_mysql.dll
  • php_pdo_sqlite.dll
  • php_soap.dll
  • php_sockets.dll
  • php_sqlite3.dll
  • php_xmlrpc.dll
  • php_xsl.dll

terça-feira, 7 de junho de 2016

Activating XDebug on PHP

  • Download and adequate XDebug DLL from XDebug download site section
  • Place the DLL into your PHP ext folder, mine is C:\xampp\php\ext
  • Edit your php.ini files and add this lines:
  • zend_extension = [pathToYouDLLinsideExtFolder]
    ;mine was: zend_extension =  C:\xampp\php\ext\php_xdebug-2.4.0-5.6-vc11.dll
    
    [xdebug]
    xdebug.remote_enable=1
    xdebug.remote_host=localhost
    xdebug.remote_port=9000
    

If you are using a Web Server to execute your scripts, restart it.

If you got some problem, use XDebug Wizard

Aptana Studio 3 Tweaks

Menu Bar > Window > Preferences > General > Appearance > Theme: Dark Studio;

Menu Bar > Window > Preferences > General > Workspace > New Text Files Line Delimiter: Unix;

Menu Bar > Window > Preferences > General > Workspace > Text File encoding: utf-8;

Menu Bar > Window > Preferences > Aptana Studio > Themes > Editor Theme: Monokai;

Menu Bar > Window > Preferences > Aptana Studio > Themes > Editor Theme > Selection: 222222;

Menu Bar > Window > Preferences > Aptana Studio > Editors > Enable Word Wrap: checked;

Menu Bar > Window > Customize Perspective > Command Groups Availabilty > Available Command Groups > External Tools: checked;

Install Aptana Studio 3 on Windows without download NodeJS by installer.

Excute the Aptana install executable specifying the extraction directory, like this:

Aptana_Studio_3_Setup_3.6.1.exe /extract:[folderToExtract]

Remembering that Aptana Studio needs a x86 version of JRE to execute.

ConEmu tweaks

ConEmu tweaks

Make CMD output in utf-8 charset

In [Startup > Enviroment > Set up enviroment variables, cmd.exe aliases, codepage] add the following line:

chcp utf8