Skip to content

Instantly share code, notes, and snippets.

View sunviwo's full-sized avatar

Sunvi Wo sunviwo

  • Sunvi Tech
  • Cotonou
View GitHub Profile
@sunviwo
sunviwo / JsSnippets.js
Last active September 19, 2021 07:32
Handy Javascript snippets
/*====== RANDOM NUMBER BETWEEN TWO GIVEN VALUES ======= */
const randomInt = (min, max) =>
Math.floor(Math.random() * (max - min) + 1) + min;
/*====== DATE DIFF ======= */
const formatMovementDate = function (date, locale) {
const calcDaysPassed = (date1, date2) =>
Math.round(Math.abs(date2 - date1) / (1000 * 60 * 60 * 24));
<?php
namespace App\EventSubscriber;
use ApiPlatform\Core\EventListener\EventPriorities;
use App\Entity\Property;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
use Symfony\Component\HttpKernel\KernelEvents;
<?php
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use ApiPlatform\Core\Annotation\ApiSubresource;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Timestampable\Traits\TimestampableEntity;
@sunviwo
sunviwo / analyzer.rb
Last active March 19, 2019 03:18
Working with Ruby strings
puts "What's your first name?"
first_name = gets.chomp
puts "What's your last name?"
last_name = gets.chomp
full_name = "#{first_name} #{last_name}"
puts "Your full name is #{full_name}."
puts "Your full name reversed is " + full_name.reverse
puts "Your name has " + full_name.length + " characters in it"