Skip to content

Instantly share code, notes, and snippets.

View kunicmarko20's full-sized avatar
๐ŸŒ€

Marko Kunic kunicmarko20

๐ŸŒ€
View GitHub Profile
@kunicmarko20
kunicmarko20 / gcs
Last active January 22, 2025 09:20
Select branch to checkout from a list of recent ones.
#!/bin/bash
select branch in $(git branch --sort=-committerdate | head -n6 | grep -v "*")
do
git checkout $branch
exit
done
@kunicmarko20
kunicmarko20 / Article.php
Last active October 10, 2024 16:34
Symfony Second Level Cache
<?php
namespace AppBundle\Entity;
/**
* @package AppBundle\Entity
* @ORM\Entity()
* @ORM\Table()
* @ORM\Cache(usage="NONSTRICT_READ_WRITE")
*/
@kunicmarko20
kunicmarko20 / Readme.md
Last active August 28, 2024 09:31
ThinkPad keeps turning off because temprature is too high when charging

Thinkpad (Lenovo ThinkPad X1 Carbon Gen 9) Overheating resolved

This laptop overheats a lot, which makes it turn off a lot. As soon as I connect it to the charger, and it's in balanced power mode, the CPU temp goes over 100.

This is an adaptation of https://kobusvs.co.za/blog/power-profile-switching/

Solutions

1. Based on charging (battery-goes-brrrrrrrrrrrr.sh)

@kunicmarko20
kunicmarko20 / ImageProvider.php
Last active May 22, 2024 12:30
Sonata Media SVG Provider
<?php
namespace YourBundle\Provider;
use Sonata\MediaBundle\Provider\FileProvider;
class ImageProvider extends FileProvider
{
}
@kunicmarko20
kunicmarko20 / Login.php
Last active March 25, 2024 10:56
Symfony OAuth with Leage OAuth2 library
<?php
declare(strict_types=1);
namespace App;
use Symfony\Component\HttpFoundation\Response;
use Twig\Environment;
use League\OAuth2\Client\Provider\Google as GoogleProvider;
@kunicmarko20
kunicmarko20 / Exporter.php
Last active January 30, 2024 08:45
Custom sonata admin export
<?php
/**
* Created by PhpStorm.
* User: markokunic
* Date: 4/21/17
* Time: 3:41 PM
*/
namespace AppBundle\Exporter;
@kunicmarko20
kunicmarko20 / pre-commit
Last active February 15, 2023 08:30
Pre Commit Git hook that will remove file from commit if it contains "// warn-before-commit" string
#!/bin/bash
top_level_path="$(git rev-parse --show-toplevel)";
while read file_name; do
if grep -q "// warn-before-commit" "$top_level_path/$file_name"; then
git reset $file_name;
echo "File $file_name, was not commited because 'warn-before-commit' string was found."
fi
done < <(git diff --cached --name-only --diff-filter=ACM)
@kunicmarko20
kunicmarko20 / README.md
Last active February 6, 2023 10:24
Create new branch while providing ticket number and short description
gct 1111 create-user-managment

This will create a new branch ticket/PROJECT-1111-create-user-managment.

@kunicmarko20
kunicmarko20 / MigrateImagesCommand.php
Last active January 9, 2023 09:14
Transfer old images into Sonata Media Bundle. This command is used for adding sonata media gallery to new structure from old database.
<?php
namespace YourBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Application\Sonata\MediaBundle\Entity\Media;
use Application\Sonata\MediaBundle\Entity\Gallery;
use Application\Sonata\MediaBundle\Entity\GalleryHasMedia;
@kunicmarko20
kunicmarko20 / LocaleListener.php
Last active December 23, 2022 03:59
Symfony Locale Listener that redirects to default language route if no language has been added instead of 404
<?php
namespace YourBundle\EventListener;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;