Skip to content

Instantly share code, notes, and snippets.

View Aliance's full-sized avatar
👨‍💻

Lesnykh Ilia Aliance

👨‍💻
View GitHub Profile
@k1paris
k1paris / Law-of-Demeter-with-PHP.md
Last active April 13, 2024 05:49
Law of Demeter with PHP (LoD)

Law of Demeter with PHP (LoD)

Law of Demeter or principle of least knowledge is a design guideline, that is using to make code more simple and stable.

Rules for module

  • Each unit should have only limited knowledge about other units: only units "closely" related to the current unit.
  • Each unit should only talk to his friends; don't talk to strangers.
  • Only talk to your immediate friends.
@zmts
zmts / tokens.md
Last active May 4, 2024 17:22
Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Про токены, JSON Web Tokens (JWT), аутентификацию и авторизацию. Token-Based Authentication

Last major update: 25.08.2020

  • Что такое авторизация/аутентификация
  • Где хранить токены
  • Как ставить куки ?
  • Процесс логина
  • Процесс рефреш токенов
  • Кража токенов/Механизм контроля токенов
@henriquemenezes
henriquemenezes / postgresql-set-id-seq.sql
Created March 31, 2016 12:23
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
@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 \
&& echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@lolzballs
lolzballs / HelloWorld.java
Created March 22, 2015 00:21
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@discordier
discordier / gist:ed4b9cba14652e7212f5
Created December 4, 2014 06:23
options for phpStorm @noinspection annotation
javascript
ES6ValidationInspection
JSAccessibilityCheckInspection
JSBitwiseOperatorUsageInspection
JSCheckFunctionSignaturesInspection
JSClosureCompilerSyntaxInspection
JSCommentMatchesSignatureInspection
JSComparisonWithNaNInspection
JSConsecutiveCommasInArrayLiteralInspection
@johnkary
johnkary / LikeQueryHelpers.php
Last active April 22, 2022 08:09
Proper DQL escaping for LIKE queries with Doctrine 2.
<?php
namespace Foo;
/**
* Methods for safe LIKE querying.
*/
trait LikeQueryHelpers
{
/**
@javajack
javajack / jquery.gdocsviewer.js
Created December 10, 2013 19:18
A JQuery Plugin for Google Doc Viewer Iframe Embeding http://jsfiddle.net/javajack/4s8bn/embedded/result/
/*
* jQuery.gdocViewer - Embed linked documents using Google Docs Viewer
* Licensed under MIT license.
* Date: 2011/01/16
*
* @author Jawish Hameed
* @version 1.0
*/
(function($){
$.fn.gdocsViewer = function(options) {
@sirkitree
sirkitree / node.js
Last active December 24, 2018 15:31
Parse a PHP file with Node.js and convert an array defined in the PHP script into a JSON object which the Node app can use.
var runner = require('child_process');
runner.exec(
'php -r \'include("settings.php"); print json_encode($databases);\'',
function (err, stdout, stderr) {
var connection = JSON.parse(stdout).default.default;
console.log(connection.database);
// result botdb
}
@rybakit
rybakit / Chain.php
Last active February 1, 2023 14:35
Nested chain validator for symfony > 2.1
<?php
namespace Acme\Validator\Constraints;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\Valid;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
/**
* @Annotation