Skip to content

Instantly share code, notes, and snippets.

View m8rge's full-sized avatar
👨‍💻
Code is for developers first

Andrey m8rge

👨‍💻
Code is for developers first
View GitHub Profile
@m8rge
m8rge / fish-build-install.sh
Last active February 23, 2024 20:35 — forked from Brandonshire/fish-build-install.sh
Install Fish Shell 3+ on Raspberry Pi using nix-shell
#!/usr/bin/env nix-shell
#! nix-shell -i bash
#! nix-shell -p cmake gettext ncurses5 pcre2
# This script uses [nix-shell package manager](https://nixos.org/download)
# to install fish clearly without any useless packages aftewards
set -e
FISH_VERSION="3.7.0"
@m8rge
m8rge / query google finance.md
Last active November 1, 2022 11:20
Fetching currency for selected date in google sheets

Fetching currency for selected date in google sheets

Google offers great abilities for fetching currency value from google finance:

=GOOGLEFINANCE("USDEUR")

will fill cell with most recent value for this currency.

| 0.982705 |

<?php
class Base64Encode extends \php_user_filter
{
private $bufferHandle;
private $tail = '';
public function filter($in, $out, &$consumed, $closing)
{
<?php
class Writer
{
public function saveFile()
{
file_put_contents('/var/www/file.pdf', '123');
}
}
@m8rge
m8rge / date_diff.php
Created June 27, 2017 04:52
Как правильно посмотреть, что одна дата больше другой на N дней
<?php
$date1 = new \DateTime('2017-01-01');
$date2 = new \DateTime('2017-01-10');
$dateInterval = $date1->diff($date2); // this is not date1-date2, but date2-date1 :-(
var_dump($dateInterval->format('%r%a') > 3); // :-(
@m8rge
m8rge / telegram icon.txt
Last active June 30, 2023 08:17
Telegram vector svg font icon. MIT Licensed
To convert this svg to web font – just upload `telegram-single-path*.svg` to http://fontello.com service!
Use `telegram-source-240px.svg` as source file.
@m8rge
m8rge / ExcelCsvWriter.php
Last active December 15, 2018 20:49
Blazing fast php excel writer. With Yii2 formatter dependency
<?php
/**
* require Yii2 for decimal formatter
*/
class ExcelCsvWriter
{
/**
* @var resource
*/
@m8rge
m8rge / SerializeAttributeBehavior.php
Last active June 7, 2018 11:17
SerializeAttributeBehavior
<?php
use yii\base\Behavior;
use yii\db\ActiveRecord;
class SerializeAttributeBehavior extends Behavior
{
/**
* @var string[]
*/
@m8rge
m8rge / post-or-pre.md
Last active February 4, 2016 10:54
Что потребляет больше памяти в php: преинкремент или постинкремент?

Что потребляет больше памяти в php: преинкремент или постинкремент?

Существует мнение, что преинкремент потребляет меньше памяти, т.к. он инкрементирует саму переменную, а постинкремент помимо этого, копирует ее предыдущее значение во временную переменную.

Давайте рассмотрим следующий код:

1. <?php
2. $a = 1;
3. echo $a++;
4. $b = 1;
@m8rge
m8rge / ConsoleProgress.php
Last active November 3, 2016 06:50
Simple yii2 console progress helper
<?php
use yii\base\Object;
use yii\helpers\Console;
/**
* Usage:
* $consoleProgress = new ConsoleProgress(['max' => 365]);
* $consoleProgress->start();
* foreach($days in $day) {