Skip to content

Instantly share code, notes, and snippets.

Avatar

Mikhail Osher miraage

View GitHub Profile
@miraage
miraage / app.js
Created Jun 25, 2019
Render tons of providers
View app.js
export const App = () => {
return 'app only specific stuff, no providers whatsoever';
};
View redux-thunk-middleware.js
import { createStore, compose } from 'redux';
import { composeWithDevTools } from 'redux-devtools-extension';
import { routerMiddleware } from 'react-router-redux';
import thunkMiddleware from 'redux-thunk';
export const makeStore = (options) => {
const {
reducer,
initialState,
history,
@miraage
miraage / ServiceInjectResolver.php
Last active Apr 21, 2017
Symfony + JMSDiExtraBundle automatic services injection into controller action methods.
View ServiceInjectResolver.php
<?php
namespace AppBundle\ArgumentResolver;
use JMS\DiExtraBundle\Annotation as DI;
use JMS\DiExtraBundle\Metadata\DefaultNamingStrategy;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
@miraage
miraage / hack.js
Created Dec 21, 2016
react-router + react-hot-loader 3.beta haxx
View hack.js
/**
* @typedef {Boolean} IS_DEV
*/
import React from 'react';
import { Router } from 'react-router';
if (IS_DEV) {
Router.prototype.componentWillReceiveProps = (nextProps) => {
View bem.js
import classnames from 'classnames';
import mapKeys from 'lodash/mapKeys';
const elemSeparator = '__';
const modSeparator = '--';
export function block(b: string, m: Object): string {
return classnames(b, mapKeys(m, (v, k) => `${b}${modSeparator}${k}`));
}
View bem.scss
$elementSeparator: ‘__’;
$modifierSeparator: ‘--’;
@function selectorToString($selector) {
$selector: inspect($selector);
$selector: str-slice($selector, 2, -2);
@return $selector;
}
@miraage
miraage / config.yml
Last active Jul 7, 2016
docker config for symfony nginx php7 redis postgres
View config.yml
imports:
- { resource: parameters.yml }
- { resource: security.yml }
- { resource: services.yml }
# Put parameters here that don't need to change on each machine where the app is deployed
# http://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:
locale: en
@miraage
miraage / gist:36c173a3c48de3a2ba1d
Created Feb 29, 2016 — forked from czarneckid/gist:762065
Creating high score leaderboards with Redis
View gist:36c173a3c48de3a2ba1d
NOTE: You will need at least Redis 2.1.6 to use the ZREVRANGEBYSCORE method.
Add players to HIGHSCORES table:
fossil:~ dczarnecki$ redis-cli
redis> zadd HIGHSCORES 1 player_1
(integer) 1
redis> zadd HIGHSCORES 2 player_2
(integer) 1
redis> zadd HIGHSCORES 3 player_3
@miraage
miraage / Model.php
Created Feb 7, 2016
laravel pivot casts fix
View Model.php
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model as BaseModel;
class Model extends BaseModel
{
public function toJson($options = 0)
{
View gist:70fb658f491ea3e3d682
function slugify(text) {
return angular.lowercase((text || ''))
.replace(/\s+/g, '-')
.replace(/[^\w\-]+/g, '')
.replace(/\-\-+/g, '-')
.replace(/^-+/, '')
.replace(/-+$/, '');
}