Skip to content

Instantly share code, notes, and snippets.

Avatar

Davi Alexandre davialexandre

View GitHub Profile
View keybase.md

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:

View php tests
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)
View gist:4262b0f1fd62ef374d761d6d102cca77
"husky": {
"hooks": {
"pre-commit": "cd .. && vendor/bin/psalm && vendor/bin/phpcs"
}
}
@davialexandre
davialexandre / gruvbox_dark.json
Created Jun 23, 2019
Gruvbox Dark color scheme for the new Windows Terminal
View gruvbox_dark.json
{
"background" : "#282828",
"black" : "#282828",
"blue" : "#458588",
"brightBlack" : "#928374",
"brightBlue" : "#83A598",
"brightCyan" : "#8EC07C",
"brightGreen" : "#B8BB26",
"brightPurple" : "#D3869B",
"brightRed" : "#FB4934",
View civibuildcd.sh
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
}
View hrcore.php
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);
}
View helper.php
<?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 |
View visitor_CSVAbsenceTypeCleaner.php
<?php
class CSVAbsenceTypeCleaner extends CSVCleanerVisitor {
public function visit(array $row) {
$this->deleteRecord('HRAbsenceType', ['name' => $row['name']]);
}
}
View test.php
<?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 Jun 2, 2016
Using getRepository on a FormType
View NomeDoSeuTypeType.php
<?php
namespace AppBundle\Form\Type;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class NomeDoSeuTypeType extends AbstractType
{
/**