Skip to content

Instantly share code, notes, and snippets.

View djonatanb's full-sized avatar

Djonatan Buss djonatanb

  • Wunderman Thompson Technology Brasil
  • Pelotas, RS
View GitHub Profile
@djonatanb
djonatanb / Validation_callback
Created September 19, 2011 13:26
Callback para funcionamento de plugin de validação de formulário
public $validation = array(
array(
'field' => 'usuario',
'label' => 'Validação',
'rules' => 'callback_valida_acesso'
)
);
@djonatanb
djonatanb / reup
Created April 9, 2012 19:07
Personal projects
public function admin_reup()
{
$videos = $this->Video->find('all', array(
'conditions' => array('Video.type' => '1'),
)
);
foreach ($videos as &$video) {
$video['Video']['duration'] = $this->duration($video['Video']['youtube']);
$video['Video']['duration2'] = $this->duration($video['Video']['youtube2']);
@djonatanb
djonatanb / reup
Created April 9, 2012 20:07
Save with time
public function beforeSave($options = array())
{
foreach ($this->_youtube as $youtube) {
if (isset($this->data[$this->alias])
&& isset($this->data[$this->alias][$youtube])
) {
//get rid of this
$countries = $this->Network->Country->find('list');
//and use this
$countries = $this->Network->find('list', array('contain' => 'Country');
//both using this in the view
echo $this->Form->input('Country');
@djonatanb
djonatanb / gist:6625988
Last active December 23, 2015 11:09
Resume a large scp transfer
rsync --partial --progress --rsh=ssh user@host:remote_file local_file
<select>
<option timeZoneId="1" gmtAdjustment="GMT-12:00" useDaylightTime="0" value="-12">(GMT-12:00) International Date Line West</option>
<option timeZoneId="2" gmtAdjustment="GMT-11:00" useDaylightTime="0" value="-11">(GMT-11:00) Midway Island, Samoa</option>
<option timeZoneId="3" gmtAdjustment="GMT-10:00" useDaylightTime="0" value="-10">(GMT-10:00) Hawaii</option>
<option timeZoneId="4" gmtAdjustment="GMT-09:00" useDaylightTime="1" value="-9">(GMT-09:00) Alaska</option>
<option timeZoneId="5" gmtAdjustment="GMT-08:00" useDaylightTime="1" value="-8">(GMT-08:00) Pacific Time (US & Canada)</option>
<option timeZoneId="6" gmtAdjustment="GMT-08:00" useDaylightTime="1" value="-8">(GMT-08:00) Tijuana, Baja California</option>
<option timeZoneId="7" gmtAdjustment="GMT-07:00" useDaylightTime="0" value="-7">(GMT-07:00) Arizona</option>
<option timeZoneId="8" gmtAdjustment="GMT-07:00" useDaylightTime="1" value="-7">(GMT-07:00) Chihuahua, La Paz, Mazatlan</option>
<option timeZoneId="9" gmtAdjustment="GMT-
@djonatanb
djonatanb / gist:7607130
Created November 22, 2013 21:23
UTF-8 right charset for database
"utf8_unicode_ci is generally more accurate for all scripts. For example, on Cyrillic block: utf8_unicode_ci is fine for all these languages: Russian, Bulgarian, Belarusian, Macedonian, Serbian, and Ukrainian. While utf8_general_ci is fine only for Russian and Bulgarian subset of Cyrillic. Extra letters used in Belarusian, Macedonian, Serbian, and Ukrainian are sorted not well."
@djonatanb
djonatanb / gist:8787074
Created February 3, 2014 16:26
fixing php-fpm ownership
/etc/php5/fpm/pool.d
SELECT table_name "Tables",
( data_length + index_length ) / 1024 /
1024 "Table Size in MB",
( data_free )/ 1024 / 1024 "Free Space in MB"
FROM information_schema.TABLES
where table_schema="area"
if [(].*[)][\s][^{]
if (winAAdDD) {
gameMap.addResultToMap("Win");
JOptionPane.showMessageDialog(mainGameView, "Good Job! You win!");
}
if (wawa)
asdasdas