Skip to content

Instantly share code, notes, and snippets.

Avatar

Călina Cenan calina-c

  • Kaolin Technologies
  • Cluj-Napoca, Romania
View GitHub Profile
View PaymentForm.yml
DueDate:
type: date
properties:
attr:
class: datepicker
label_attr:
class: required
Type:
type: choice
properties:
View ServiceForm.php
<?php
namespace App\Forms\Entities;
use App\Forms\YamlConfigForm as Form;
use App\Models\Agency;
use App\Models\Service;
class ServiceForm extends Form
{
public function getModelClass()
View YamlConfigForm.php
<?php
namespace App\Forms;
use Kris\LaravelFormBuilder\Form;
use Yaml;
use Carbon\Carbon;
use App\Forms\Report\FormConfig;
use App\Forms\Entities\EntityFormConfig;
use App\Services\ReportServices\ReportStringProcessingTrait;
View fizz-buzz-2.py
class Rule:
def matchesRule(self, number):
pass
def getReplacement(self):
pass
class FizzRule:
def matchesRule(self, number):
return not (number % 3);
View fizz-buzz-1.py
class FizzRule:
def matchesRule(self, number):
return not (number % 3);
def getReplacement(self):
return "Fizz";
class BuzzRule:
def matchesRule(self, number):
return not (number % 5);
View sprintf-conditionals.php
return $id ? "The item was updated." : "The item was created";
########
$action = $id ? "updated" : "created";
return sprintf("The item was %s.", $action).
View sprintf-py-conversions
return 'The number is ' + str(2) + '.'
return 'The number is %s.' % 2
View sprintf-conversions
return sprintf("%0.3f",$number);
return number_format($number, 3, '.', '');
View sprintf-readability
return sprintf(
“The user %s %s has a balance of $%f.”,
$firstName,
$lastName,
$balance
);
return "The user " . $firstName . " has a balance of $" . $balance . ".";
@calina-c
calina-c / if-inversion-untangled-function.php
Created Oct 19, 2016
Part of IF inversion examples, contains only the untangled version of the function
View if-inversion-untangled-function.php
<?php
function validateApplicationUntangled($user) {
if($user->age<18) {
printf("Sorry, but the user %s is under 18\n", $user->name);
return false;
}
if($user->hasPreviousApplication && $user->previousApplicationApproved) {
printf("Sorry, but the user %s has a previously approved application\n", $user->name);
return false;