Skip to content

Instantly share code, notes, and snippets.

View franzose's full-sized avatar

Yan Ivanov franzose

View GitHub Profile
@troelskn
troelskn / underscore.php
Created December 22, 2010 13:45
camelize + underscore in php
<?php
/**
* Transforms an under_scored_string to a camelCasedOne
*/
function camelize($scored) {
return lcfirst(
implode(
'',
array_map(
@raykolbe
raykolbe / CQRS.php
Created May 21, 2013 20:36
CQRS is simple!
<?php
namespace CQRSSample\Domain\Model
{
/**
* Please read this. It may be interesting to you. You can ridicule me ONLY if you read the whole thing.
*
* CQRS is NOT about different data sources and is NOT about Event Sourcing.
* CQRS IS about breaking out your reads and writes. It's powerful and simple!
@vudaltsov
vudaltsov / Condition.php
Last active September 22, 2021 15:18
Conditional validator
<?php
declare(strict_types=1);
namespace App\Validator\Constraints;
use Symfony\Component\Validator\Constraints\Composite;
/**
* @Annotation()
@karlhorky
karlhorky / grayscale-disable.css
Created August 26, 2012 12:17
Cross-Browser CSS Grayscale
img.grayscale.disabled {
filter: url("data:image/svg+xml;utf8,&lt;svg xmlns=\'http://www.w3.org/2000/svg\'&gt;&lt;filter id=\'grayscale\'&gt;&lt;feColorMatrix type=\'matrix\' values=\'1 0 0 0 0, 0 1 0 0 0, 0 0 1 0 0, 0 0 0 1 0\'/&gt;&lt;/filter&gt;&lt;/svg&gt;#grayscale");
-webkit-filter: grayscale(0%);
}
@Kreshnik
Kreshnik / PreventReplayAttack.php
Last active March 29, 2022 11:00
Laravel 5 - PreventReplayAttack Middleware
<?php namespace App\Http\Middleware;
use Carbon\Carbon;
use Closure;
use Illuminate\Cache\Repository as Cache;
use Illuminate\Support\Facades\Response;
use Illuminate\Support\Facades\Session;
class PreventReplayAttack
{
@enleur
enleur / ConstraintViolationsConverter.php
Last active May 18, 2022 10:31
Symfony json body to request object auto mapping
<?php
namespace App\Request\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Validator\ConstraintViolationListInterface;
final class ConstraintViolationsConverter implements ParamConverterInterface
@saqueib
saqueib / errorHandler.js
Last active June 9, 2022 06:42
Global error handling using axios interceptor for http calls http://www.qcode.in/api-error-handling-in-vue-with-axios
import axios from 'axios'
import toast from './toast'
function errorResponseHandler(error) {
// check for errorHandle config
if( error.config.hasOwnProperty('errorHandle') && error.config.errorHandle === false ) {
return Promise.reject(error);
}
// if has response show the error
@elizarov
elizarov / AspectOperators.kt
Last active September 8, 2022 07:56
Aspect operators
// Aspect interface for combinator
interface Aspect {
operator fun <R> invoke(block: () -> R): R
}
// Aspect combinator
operator fun Aspect.plus(other: Aspect) = object : Aspect {
override fun <R> invoke(block: () -> R): R =
this@plus {
other {
@thiagoeliasr
thiagoeliasr / swiper-magnific-popup.js
Created August 13, 2015 13:27
Adding swipe support to Magnific Popup galleries. (touchSwipe is required: http://labs.rampinteractive.co.uk/touchSwipe/demos/)
(function() {
/* Define a variável que dá swipe no lightbox */
var magnificPopup = $.magnificPopup.instance;
/* Carrega a função quando clica no lightbox (senão não pega a classe utilizada) */
$("a.image-lightbox").click(function(e) {
/* Espera carregar o lightbox */
setTimeout(function() {
/* Swipe para a esquerda - Próximo */
@goranprijic
goranprijic / BaseModel.php
Created December 17, 2014 10:12
Check if table is already joined in Laravel Query Builder
<?php
class BaseModel extends Eloquent {
public static function isJoined($query, $table)
{
$joins = $query->getQuery()->joins;
if($joins == null) {
return false;
}