Skip to content

Instantly share code, notes, and snippets.

View hightemp's full-sized avatar
🎯
Focusing

Anton Panov hightemp

🎯
Focusing
View GitHub Profile
@hightemp
hightemp / conventions.md
Last active August 25, 2018 13:31
Variable naming conventions

Variable naming conventions

Camel case: numberOfPeople

A series of words, with each intermeidiate word started with a capital letter. Called "Camel Case" because the capital letters make it look like the humps of a camel.

Kebab case: number-of-people

Hypehated words - like chunks of meat or vegatables on a kebab skewer. Note that cannot case only works in a gew languahes such as Tcl and Perl 6, as the minus sign most usually is the subtraction operator.

Snake case: number_of_people

Words separated with underscores - the word snakes along past the underscores. Unlike Kebab case which is of limited (language) use, you can use Snake Case with most modern languages.

@hightemp
hightemp / snippets.md
Last active October 6, 2018 14:34
Laravel snippets

Laravel snippets

Define PDO object in DB Laravel

DB::connection()->setPdo($pdo);

Get PDO object from DB Laravel

$pdo = DB::connection()->getPdo();
@hightemp
hightemp / snippets.md
Last active September 29, 2018 12:32
JS Snippets
@hightemp
hightemp / snippets.md
Last active September 29, 2018 12:32
Vue snippets

Vue snippets

Watch vuex state changes

computed: {
  doneTodosCount () {
    return this.$store.getters.doneTodosCount
  }
}

watch:{
@hightemp
hightemp / snippets.md
Last active May 9, 2019 20:06
Git snippets

Git snippets

Merge unrelated histories repositories

git pull origin master --allow-unrelated-histories

Copy commit from one branch to another

git cherry-pick -x 
@hightemp
hightemp / snippets.md
Last active October 22, 2023 12:10
Bash snippets

Bash snippets

Get size of files of current directory with mask

du -c `find . -maxdepth 1 -name '*.php'` | tail -1

Count lines in files with mask

find . -maxdepth 1 -name '*.php' -print | xargs wc -l
@hightemp
hightemp / crc64.php
Created September 29, 2018 12:33
PHP crc64
<?php
/**
* @return array
*/
function crc64Table()
{
$crc64tab = [];
// ECMA polynomial
<?php
$check_digit = function($inn, $coefficients) {
$n = 0;
foreach ($coefficients as $i => $k) {
$n += $k * (int) $inn{$i};
}
return $n % 11 % 10;
};
switch ($inn_length) {
case 10:
<?php
/*
CREATE TABLE `log_changes` (
`id` INT NOT NULL AUTO_INCREMENT,
`id_user` INT NOT NULL,
`date_change` bigint(20) NOT NULL,
`type_change` varchar(25) NOT NULL,
`table_db` varchar(50) NOT NULL,
`field_db` varchar(50) NOT NULL,
@hightemp
hightemp / git_exclude.md
Created December 27, 2018 10:30
git exclude

Git ignore. Игнорирование в гит. Для начинающих

Есть различные ситуации, в каждой может применяться свой способ игнорирования. Разберу способы.

.gitignore — исключения в репозитории для всех

Игнорирование с помощью создания файла .gitignore прямо в содержимом репозитория приводит к тому, что:

гит будет игнорировать изменения в файлах указанных в .gitignore; сам файл .gitignore будет проиндексирован гитом, и это хорошо; все разработчики проекта в результате clone/pull получат файл .gitignore и будут видеть изменения в нем.