Skip to content

Instantly share code, notes, and snippets.

View vandro's full-sized avatar

Vandro Neves dos Santos vandro

View GitHub Profile
@vandro
vandro / postgres-cheatsheet.md
Created January 13, 2020 15:43 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" | tee -a /etc/apt/sources.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886
apt-get update
apt-get install oracle-java7-installer
exit
@vandro
vandro / ALTER SEQUENCE
Last active March 27, 2018 22:37
Reset primary key POSTGRESQL
ALTER SEQUENCE <TABLE_NAME>_id_seq RESTART;
TRUNCATE <TABLE_NAME> RESTART IDENTITY;
--UPDATE <TABLE_NAME> SET id=nextval('seq');
@vandro
vandro / permisos de archivos en Yii2
Last active March 27, 2018 20:44
Que permisos asignar en que carpetas y/o archivos en yii2
chmod -R 0777 runtime && chmod -R 0777 web/assets && chmod -R 0755 yii
@vandro
vandro / jsKeyCode.txt
Created March 15, 2018 15:48 — forked from lbj96347/jsKeyCode.txt
javascript Key Code
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode 16 = Shift_L
keycode 17 = Control_L
keycode 18 = Alt_L
keycode 19 = Pause
keycode 20 = Caps_Lock
keycode 27 = Escape Escape
@vandro
vandro / install_pdo_sqlsrv.sh
Created February 8, 2018 15:29 — forked from joecampo/install_pdo_sqlsrv.sh
Install Official MSSQL driver for Unbuntu 14.04 - pdo_sqlsrv
#!/bin/bash
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo -i export CPPFLAGS="-DSIZEOF_LONG_INT=8"
sudo apt-get -y install gcc-5 g++-5
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 60 --slave /usr/bin/g++ g++ /usr/bin/g++-5
cd ~
echo "Configuring the unixODBC 2.3.1 Driver Manager"
@vandro
vandro / disable_tracker.sh
Created August 16, 2017 14:56 — forked from DanyHenriquez/disable_tracker.sh
Disable tracker Ubuntu 16.04
echo -e "\nHidden=true\n"|sudo tee --append /etc/xdg/autostart/tracker-extract.desktop
echo -e "\nHidden=true\n"|sudo tee --append /etc/xdg/autostart/tracker-miner-apps.desktop
echo -e "\nHidden=true\n"|sudo tee --append /etc/xdg/autostart/tracker-miner-fs.desktop
echo -e "\nHidden=true\n"|sudo tee --append /etc/xdg/autostart/tracker-miner-user-guides.desktop
echo -e "\nHidden=true\n"|sudo tee --append /etc/xdg/autostart/tracker-store.desktop
gsettings set org.freedesktop.Tracker.Miner.Files crawling-interval -2
gsettings set org.freedesktop.Tracker.Miner.Files enable-monitors false
tracker reset --hard
@vandro
vandro / chtml-ajaxsubmitbutton.md
Last active August 5, 2017 20:52 — forked from umidjons/chtml-ajaxsubmitbutton.md
Yii: Using `CHtml::ajaxSubmitButton` in active forms

Using CHtml::ajaxSubmitButton in active forms

<div class="form-group">
	<div class="col-sm-12 text-right">
		<?=
		CHtml::ajaxSubmitButton( Yii::t( 'zr', 'Add' ), [ 'createProperty' ],
			[
				'type'     => 'POST',
				'dataType' => 'json',
@vandro
vandro / number-format.md
Created August 5, 2017 20:50 — forked from umidjons/number-format.md
Yii: Using Number formatter in Yii

Using Number formatter in Yii

<?php
Yii::app()->numberFormatter->formatCurrency(1234.5678, 'USD'); // 1 234,57 $
Yii::app()->numberFormatter->formatCurrency(1234.5678, 'EUR'); // 1 234,57 €
Yii::app()->numberFormatter->formatCurrency(1234.5678, 'RUB'); // 1 234,57 руб.

It is easy do this with wrapper function:

@vandro
vandro / many-serverfileinput-widgets.md
Created August 5, 2017 20:49 — forked from umidjons/many-serverfileinput-widgets.md
Yii: Using more than one ServerFileInput widgets on a page

Using more than one ServerFileInput widgets on a page

I need ServerFileInput widget without model and attribute, just to select file on a server or to upload file to the server, then select it. In advance I don't know how much inputs such widgets will be on a page. Therefore, I add temporary field to the model to use with this widget, then plan to clone it with jQuery.

<?php
class MyModel extends CActiveRecord
{
	public $my_attachment; // used only to generate elFinder.ServerFileInput widget
	// ...