Skip to content

Instantly share code, notes, and snippets.

@zetrider
zetrider / RoutestTest.php
Created Oct 9, 2021
Laravel test via DebugBar
View RoutestTest.php
<?php
namespace Tests\Feature;
use Tests\TestCase;
class RoutesTest extends TestCase
{
const PHP_VERSION = '7.4.22';
const MAX_TIME_DURATION_SECONDS = 1;
@zetrider
zetrider / Detect TestFlight, XCode, Simulator, AppStore
Created Jun 4, 2021
Detect TestFlight, XCode, Simulator, AppStore
View Detect TestFlight, XCode, Simulator, AppStore
enum Environment: String {
case production = "production"
case development = "development"
}
func env() -> Environment {
// TestFLight, Xcode
if Bundle.main.appStoreReceiptURL?.lastPathComponent == "sandboxReceipt" {
return .development
}
@zetrider
zetrider / Bitrix - Serialize fields
Created Nov 16, 2015
Преобразование сериализованных массивов в базе данных Битрикс после изменения кодировки
View Bitrix - Serialize fields
<?
/* Массив таблиц и стобцов с сериализованными данными которые удалось найти */
$arDB = array(
'b_component_params' => 'PARAMETERS',
'b_event' => 'C_FIELDS',
'b_event_log' => 'DESCRIPTION',
'b_event_message' => 'ADDITIONAL_FIELD',
'b_group' => 'SECURITY_POLICY',
'b_iblock_element_property' => 'VALUE',
'b_iblock_fields' => 'DEFAULT_VALUE',
@zetrider
zetrider / laravel_bash_deploy.sh
Last active Feb 24, 2021
Laravel: Bash deploy
View laravel_bash_deploy.sh
#!/bin/sh
# Grant privileges
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service php7.4-fpm reload" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service nginx restart" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null
# echo "YOUR_USER ALL=NOPASSWD: /usr/sbin/service supervisor restart" | sudo tee -a /etc/sudoers.d/php-fpm > /dev/null
NAME=$(date +"%m-%d-%Y-%H-%M-%S")
FOLDER=releases/$NAME
BACKUP=backup/before_$NAME.sql
@zetrider
zetrider / Ubuntu: php-fpm, nginx, mariadb, ssh
Last active Feb 21, 2021
Ubuntu: php-fpm, nginx, mariadb, ssh
View Ubuntu: php-fpm, nginx, mariadb, ssh
#scp ~/.ssh/id_rsa.pub root@255.255.255.255:~
# [ -d ~/.ssh ] || (mkdir ~/.ssh; chmod 711 ~/.ssh)
# cat ~/id_rsa.pub >> ~/.ssh/authorized_keys
# chmod 600 ~/.ssh/authorized_keys
# rm ~/id_rsa.pub
apt install -y software-properties-common
add-apt-repository ppa:ondrej/php
# add-apt-repository universe
View 8-1.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
</head>
<body>
View laravel.sync.morphToMany.php
/**
* Sync morphToMany
*
* @param morphToMany $morphToMany
* @param array $ids
* @return array
*/
public static function syncMorphToMany($morphToMany, $ids)
{
$changes = [
View WordPress - replace serialize options
<?
global $wpdb;
define('MY_OLD_DOMAIN', 'http://olddomain.ru');
define('MY_NEW_DOMAIN', 'http://newdomain.ru');
function myWalkCallback(&$item, $key)
{
$item = str_replace(MY_OLD_DOMAIN, MY_NEW_DOMAIN, $item);
}
@zetrider
zetrider / css
Created May 12, 2019
Bootstrap4 Debug Grid
View css
.bootstrap-grid {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 9999;
width: 100%;
height: 100%;
}
@zetrider
zetrider / TimeWeb - SSH RSA Key
Created Nov 19, 2015
Авторизация SSH по RSA ключу - TimeWeb
View TimeWeb - SSH RSA Key
user - имя пользователя
server.timeweb.ru - сервер
1. На машине ssh-keygen -t rsa
2. Копируем, можно по FTP или одной из команд
2.1. ssh-copy-id -i ~/.ssh/id_rsa user@server.timeweb.ru
2.2. scp ~/.ssh/id_rsa.pub user@server.timeweb.ru:~
3. На сервере
[ -d ~/.ssh ] || (mkdir ~/.ssh; chmod 711 ~/.ssh) # создание директории и изменение прав
cat ~/id_rsa.pub >> ~/.ssh/authorized_keys # добавление открытого ключа