Skip to content

Instantly share code, notes, and snippets.

View tihoho's full-sized avatar
❤️
Hey everyone!

Alex T tihoho

❤️
Hey everyone!
View GitHub Profile
@tihoho
tihoho / php-docx-replace-template.php
Created January 20, 2022 10:26
PHP DOCX replace template
<?php
/**
* Docx Replacer
*
* @author Not me
* @param string $input Input file path
* @param string $output Output file path
* @param string $replacements Assoc array of replaces placeholders Ex: ['{NAME}' => 'Alex', ...]
*/
@tihoho
tihoho / README.md
Last active July 11, 2019 20:10
Simple realization of "reconnect" for php-cURL

PHP cURL reconnect

Simple implementations (2 variants) of the reconnection mechanism for CURL in PHP.

tihoho, 07.2019
Telegram: https://t.me/tihoho
PayPal for beer: tihoho@yandex.ru
@tihoho
tihoho / nginx.conf
Created March 2, 2019 19:23
simple CORS
server {
set $cors_origin "";
set $cors_cred "";
set $cors_header "";
set $cors_method "";
if ($http_origin ~* "^http.*\.yourhost\.com$") {
set $cors_origin $http_origin;
set $cors_cred true;
set $cors_header $http_access_control_request_headers;
Stopping spam is a constant fight and due to this, your account has restrictions specifically on port 25. However, you are be able to use mail services using ports 587, 993, 995 and 465. You will need to open these ports in your firewall. Here is our guide to common iptables commands:
https://www.digitalocean.com/community/tutorials/iptables-essentials-common-firewall-rules-and-commands#service-mail
We realize this is inconvenient, but many customers in your position move their mailing activities to a third party service such as SendGrid or similar which processes such mail separately from their droplet. I'm sorry for the frustration but we're not able to lift this port restriction at this time.
In terms of a workaround, here are a few alternatives:
1. Utilize port 587 for SMTP relay via another mail provider, for example G Suite/Gmail, Mailgun, etc. We have a guide on doing so using Postfix here:
@tihoho
tihoho / media-query.css
Created April 27, 2018 21:35 — forked from gokulkrishh/media-query.css
CSS Media Queries for Desktop, Tablet, Mobile.
/*
##Device = Desktops
##Screen = 1281px to higher resolution desktops
*/
@media (min-width: 1281px) {
//CSS
@tihoho
tihoho / backside.php
Created February 10, 2018 19:44
Search a Earth back-side by lat-lon point
<?php
function backSide($lat, $lon) {
$lat *= -1;
$lon = $lon < 0 ? $lon + 180 : $lon - 180;
return [$lat, $lon];
}
<?php
namespace common\models;
use Yii;
use yii\base\Model;
use yii\data\ActiveDataProvider;
use common\models\User;
use common\models\Balance;
@tihoho
tihoho / remove-not-unique.sql
Created January 6, 2018 13:39
Remove not-uniuqe values in table field
delete from MYTABLE where id in (
select id from (
select id, count(*) 'c' from MYTABLE where 1 group by MYFIELD having count(`c`) > 1
) as `items`
)
<?php
// Входящие данные
$article = 'hp'; // артикул товара
$sum = 3563; //Сумма (для теста тут принтер hp + 4 катриджа: hpb*3 + hpr*1)
// принтеры
$printersPrice = [
'canon' => 1000,
'hp' => 2000,
-- юзеры
CREATE TABLE `users` (
`id` INT(11) NOT NULL AUTO_INCREMENT,
`firstname` VARCHAR(32) NULL DEFAULT 'No_name',
PRIMARY KEY (`id`)
)
ENGINE=InnoDB
;
-- хобби