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
}
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>
@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
View laravel.sync.morphToMany.php
/**
* Sync morphToMany
*
* @param morphToMany $morphToMany
* @param array $ids
* @return array
*/
public static function syncMorphToMany($morphToMany, $ids)
{
$changes = [
@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 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 / brew upgrade Sierra
Created Feb 2, 2017
Error: /usr/local must be writable!
View brew upgrade Sierra
1. sudo chown -R $(whoami) /usr/local
2. brew update
3. sudo chmod 0755 /usr/local
4. sudo chown root:wheel /usr/local
5. brew upgrade