Skip to content

Instantly share code, notes, and snippets.

View acanimal's full-sized avatar

Antonio Santiago acanimal

View GitHub Profile
@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 / debug_zsh.md
Last active September 3, 2016 08:08
Using DEBUG npm package in zsh
$ export DEBUG='*' && node your_app.js
@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 / 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 / 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 / specification-callback.js
Created September 2, 2015 06:04
Specification pattern with callback style
"use strict";
/**
* Specification base class
* @class
*/
var Specification = {
and: function(spec) {
return new AndSpecification(this, spec);
},
@acanimal
acanimal / specification.js
Last active November 4, 2020 09:40
Specification pattern in JavaScript
"use strict";
/**
* Specification base class
* @class
*/
var Specification = {
and: function(spec) {
return new AndSpecification(this, spec);
},