Skip to content

Instantly share code, notes, and snippets.

View acanimal's full-sized avatar

Antonio Santiago acanimal

View GitHub Profile
@acanimal
acanimal / mysql_tips.md
Created March 22, 2016 11:19
MySQL Tips

Monitor queries

  • Check general_log flag:
mysql> SHOW VARIABLES LIKE "general_log%";

+------------------+----------------------------+
| Variable_name    | Value                      |
+------------------+----------------------------+
| general_log | OFF |
@acanimal
acanimal / PhystrixController.php
Created June 21, 2016 13:22
Controller to show Phystrix metrics using symfony2 phystrix-bundle config
// When working with Phystrix-bundle you must supply configuration in config.yml.
// Phystrix-Dashboard offers helper classes to serve phystrix metrics but you need to pass a config array with
// the config.
// Next code shows how you can create a symfony2 controller that passes the phystrix config.yml configuration and
// avoids duplications.
<?php
namespace MyBundle\Controller;
@acanimal
acanimal / redis-flush-one-line.sh
Created June 28, 2016 13:18
Flush redis database in one line
# n: the database number
# r: repeat command a number of times
#
redis-cli -n 4 -r 1 flushall
@acanimal
acanimal / debug_zsh.md
Last active September 3, 2016 08:08
Using DEBUG npm package in zsh
$ export DEBUG='*' && node your_app.js
@acanimal
acanimal / error_class_es6.js
Created January 10, 2017 16:02
Custom error in ES6
class ExtendableError extends Error {
constructor(message) {
super(message);
this.name = this.constructor.name;
this.message = message;
if (typeof Error.captureStackTrace === 'function') {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = (new Error(message)).stack;
}
@acanimal
acanimal / hoa.js
Created January 18, 2017 09:03
Higher Order Actions
const higherOrderAction = (func) => (...args) => (dispatch, ...props) => {
// Do whatever you need.
// Call the wrapped action.
const call = func(undefined, ...args);
// Check if the call returns a function, which means it is an async action
if (call && call.constructor && call.call && call.apply) {
return call(dispatch, ...props);
}
@acanimal
acanimal / withReduxProvider.js
Created March 24, 2017 08:25
High Order Component to wrap a component with redux Provider
import React, { Component } from 'react';
import { Provider } from 'react-redux';
import initialState from './store/initialState';
import createStore from './store/createStore';
const store = createStore(initialState);
const getDisplayName = WrappedComponent => WrappedComponent.displayName || WrappedComponent.name || 'WrappedComponent';
/**
* HOC to wrap a component within redux provider to allow access the store.