Skip to content

Instantly share code, notes, and snippets.

View davialexandre's full-sized avatar

Davi Alexandre davialexandre

View GitHub Profile

Keybase proof

I hereby claim:

  • I am davialexandre on github.
  • I am davialexandre (https://keybase.io/davialexandre) on keybase.
  • I have a public key ASDiHk4XycfbGyPgWof9lRsGksMBMtWHcIT-TIa7jm6MqQo

To claim this, I am signing this object:

vagrant@civihr-upgrade:/vagrant/civihr/sites/all/modules/civicrm/tools/extensions/civihr/uk.co.compucorp.civicrm.hrcore$ phpunit4 --testsuite "Unit Tests"
PHPUnit 4.8.21 by Sebastian Bergmann and contributors.
............................................................... 63 / 153 ( 41%)
............................................................... 126 / 153 ( 82%)
...........................
Time: 1.12 minutes, Memory: 105.50Mb
OK (153 tests, 351 assertions)
"husky": {
"hooks": {
"pre-commit": "cd .. && vendor/bin/psalm && vendor/bin/phpcs"
}
}
@davialexandre
davialexandre / gruvbox_dark.json
Created June 23, 2019 18:09
Gruvbox Dark color scheme for the new Windows Terminal
{
"background" : "#282828",
"black" : "#282828",
"blue" : "#458588",
"brightBlack" : "#928374",
"brightBlue" : "#83A598",
"brightCyan" : "#8EC07C",
"brightGreen" : "#B8BB26",
"brightPurple" : "#D3869B",
"brightRed" : "#FB4934",
@davialexandre
davialexandre / civibuildcd.sh
Created September 3, 2018 12:47
civibuildcd
function civibuildcd {
DEST=$(civibuild show $1 | grep -o -e "CMS_ROOT: .*" | cut -d' ' -f 2)
if [ -d "$DEST" ]; then
cd $DEST
else
echo "No folder found for $1"
fi
}
function hrcore_civicrm_config($config) {
$defaultTimeout = 100000;
// get the timeout from settings or use the default one
$timeout = $config->get('session.timeout', $defaultTimeout);
ini_set('session.gc_maxlifetime', $timeout);
ini_set('session.cookie_lifetime', $timeout);
}
<?php
CRM_HRCore_Helpers_Database::printSQLResult('SELECT id, display_name, contact_type FROM civicrm_contact');
// Prints something like:
// | id | display_name | contact_type |
// ------------------------------------
// | 1 | S.H.I.E.L.D | Organization |
// | 2 | Nick Fury | Individual |
// | 3 | Steve Rogers | Individual |
<?php
class CSVAbsenceTypeCleaner extends CSVCleanerVisitor {
public function visit(array $row) {
$this->deleteRecord('HRAbsenceType', ['name' => $row['name']]);
}
}
<?php
public function getNumberOfPublicHolidaysForPeriod() {
if(!$this->numberOfPublicHolidaysInPeriod) {
$this->numberOfPublicHolidaysInPeriod = PublicHoliday::getNumberOfPublicHolidaysForPeriod(
$this->period->start_date,
$this->period->end_date
);
}
return $this->numberOfPublicHolidaysInPeriod;
@davialexandre
davialexandre / NomeDoSeuTypeType.php
Created June 2, 2016 20:23
Using getRepository on a FormType
<?php
namespace AppBundle\Form\Type;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class NomeDoSeuTypeType extends AbstractType
{
/**