This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Group extends ActiveRecord\Model{ | |
static $has_many = array( | |
array('users'), | |
array('posts', 'through' => 'group_info'), | |
); | |
} | |
class User extends ActiveRecord\Model{ | |
static $belongs_to = array( | |
array('group'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Š','S'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'š','s'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ð','Dj'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ž','Z'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'ž','z'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'À','A'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Á','A'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Â','A'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ã','A'); | |
UPDATE TABLE_NAME SET COLUMN = REPLACE(COLUMN,'Ä','A'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$tabuada_da_vez = 1; | |
while ($tabuada_da_vez <= 10) { | |
echo "Tabuada do ". $tabuada_da_vez . '<br />'; | |
for($i =1; $i <= 10; $i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function changeDate($strDate, $op, $increment,$format='d/m/Y H:i'){ | |
if(!in_array($op,array('+','-'))){ | |
throw new Execption('The param 2 (operator) must be + or -'); | |
} | |
if($increment < 0){ | |
$increment *= -1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
for file in $(ls ./logs/"$1"_*); do | |
if [ $file == "./logs/"$1"_00.csv" ]; then | |
cabecalho=$(head -1 ./logs/"$1"_00.csv); | |
continue | |
fi | |
touch access_log_users.swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR='./logs/' | |
ATUAL=$(pwd) | |
for file in $(ls $DIR"$1"_*); do | |
cat $file >> "$DIR"olds/"$1"_full.csv | |
done | |
cd "$DIR"olds/ | |
split --additional-suffix=.csv -d -l 500 "$1"_full.csv $1"_" | |
rm -rf "$1"_full.csv | |
cd $ATUAL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DIR='./logs/' | |
files=""; | |
for file in $(ls $DIR"$1"_*); do | |
files=$files" "$file | |
done | |
zip -r $1".zip" $files | |
mv $1".zip" $DIR"olds/" | |
## exercicio 4 | |
rm -rf $DIR"$1"_* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#0) copiar e descompactar o seguinte arquivo https://dl.dropboxusercontent.com/u/32535093/app.tar.gz | |
# | |
#1) adicionar o cabecalho do arquivo de log contendo o titulo das colunas. | |
# * veirificar o arquivo *_00.csv de cada log | |
# | |
#2) criar arquivos de log com 500 linhas, excluindo o cabelçalho | |
# | |
#3) compactar os arquivos de log para o formato ".zip" e | |
# movê-los para a pasta app/log/olds | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pwd=$(pwd) | |
cd app/imgs | |
for file in $(ls ./); do | |
name=(${file//_/ }) | |
mv $file ${name[1]}"_"${name[2]} | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
pwd=$(pwd) | |
cd app/imgs | |
for file in $(ls ./); do | |
name=(${file//_/ }) | |
new_dir=${name[0]} |
OlderNewer