Skip to content

Instantly share code, notes, and snippets.

location ^~ /uploads/documents/ {
alias /volume/data/documents/;
set $auth_pass "$request_uri";
auth_request /auth/documents;
auth_request_set $auth_status "$upstream_status";
}
location ^~ /auth/ {
internal;
proxy_pass "http://back:8080/auth/$auth_pass";
@AnrDaemon
AnrDaemon / apiaware.php
Last active October 21, 2021 10:44
Domain to infrastructure chained API interaction
<?php
/** Wrapper for actual thing that do the network talking.
This could be encapsulation for curl, Guzzle, Net\Browser, etc.
The wrapper offers a known stable interface to external library.
*/
class Service\Api\Wrapper
{
<?php
$nf = new \NumberFormatter("ru_RU", \NumberFormatter::CURRENCY);
$cs = ini_get('default_charset');
$formatter = function($price, $currency = 'RUB')
use($nf, $cs)
{
return iconv('UTF-8', "$cs//IGNORE", $nf->formatCurrency($price, $currency));
};
@rvl
rvl / git-pushing-multiple.rst
Created February 9, 2016 11:41
How to push to multiple git remotes at once. Useful if you keep mirrors of your repo.

Pushing to Multiple Git Repos

If a project has to have multiple git repos (e.g. Bitbucket and Github) then it's better that they remain in sync.

Usually this would involve pushing each branch to each repo in turn, but actually Git allows pushing to multiple repos in one go.

If in doubt about what git is doing when you run these commands, just

@chadrien
chadrien / README.md
Last active September 1, 2023 12:43
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@adrian-enspired
adrian-enspired / post-defaults-concept.php
Last active January 1, 2021 03:13
I don't actually recommend this approach anymore. you're better off with a more holistic approach to input validation.
<?php
// I first saw this on freenode/##php, from Viper-7.
// first, make an array with ALL of the field names you expect, and default values for each.
// keys are field names; values are field defaults.
$defaults = [
"field1" => "default value",
"field2" => "", // ← default is empty string
"field3" => null // ← no default value
@bonii-xx
bonii-xx / ToolMaterials
Last active October 15, 2023 17:31
Tinkers' Construct IMC
/* This first part adds Seared Stone as a material. Toolparts and tool graphics are created automatically by color */
NBTTagCompound tag = new NBTTagCompound();
tag.setInteger("Id", 50); // Unique material ID. Reseved IDs: 0-40 Tinker, 41-45 Iguana Tinker Tweaks, 100-200 ExtraTiC
tag.setString("Name", "Seared Stone"); // Unique material name
tag.setInteger("HarvestLevel", 3); // diamond level
tag.setInteger("Durability", 100);
tag.setInteger("MiningSpeed", 100);
tag.setInteger("Attack", 0); // optional
tag.setFloat("HandleModifier", 0.1f);
tag.setInteger("Reinforced", 0); // optional
<?php
/**
* This class can add WSSecurity authentication support to SOAP clients
* implemented with the PHP 5 SOAP extension.
*
* It extends the PHP 5 SOAP client support to add the necessary XML tags to
* the SOAP client requests in order to authenticate on behalf of a given
* user with a given password.
*