Skip to content

Instantly share code, notes, and snippets.

View kunicmarko20's full-sized avatar
🌀

Marko Kunic kunicmarko20

🌀
View GitHub Profile
@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 / README.md
Last active May 23, 2022 16:40
Create new branch while providing ticket number and short description
gcf 1111 create-user-managment

This will create a new branch feature/PRJ-1111/create-user-managment

@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 / when to use final.txt
Last active March 10, 2020 08:28
When to use Final (from Slack)
Rule #1: if you can’t think of a use-case for extending, make the class final. At the same time, make everything private instead of protected.
Rule #2: if your class is final, all public methods must be part of an interface that people can mock
Rule #3: prefer small, targeted interfaces instead of a compound interface
Rule #4: listen to your users, hear their concerns, work with them to avoid opening a final class
Rule #5: if a user has a legitimate use-case for extending a final class (as opposed to wrapping it), open it up and make necessary methods protected. Keep fields private.
@kunicmarko20
kunicmarko20 / E2E.php
Created February 7, 2020 17:11
Example of annotation reader in phpunit hooks
<?php
namespace PHPUnitE2EExtension\Annotation;
/**
* @Annotation
* @Target("Class")
*/
final class E2E
{
@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 / gcs
Last active August 25, 2021 10:01
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 / prepare-commit-msg
Last active July 9, 2019 15:30
Prefix commit with ticket number from the branch if it isn't already prefixed
#./.git/hooks/prepare-commit-msg
COMMIT_PREFIX=$(git symbolic-ref --short HEAD | grep -Po 'PROJECT-([0-9]+)');
HAS_TICKET_NUMBER=$(grep -Po 'PROJECT-([0-9]+)' $1);
if [ -n "$HAS_TICKET_NUMBER" ]; then
return;
fi
if [ -n "$COMMIT_PREFIX" ]; then
@kunicmarko20
kunicmarko20 / eq
Last active May 8, 2019 10:32
PHPStorm Live templates
public function equals($CLASS$ $other): bool
{
return $END$;
}