Skip to content

Instantly share code, notes, and snippets.

View rigobertocontreras's full-sized avatar

Rigoberto Contreras rigobertocontreras

  • United States
View GitHub Profile
@rigobertocontreras
rigobertocontreras / AcmeExtension.php
Created August 16, 2018 18:24 — forked from chalasr/AcmeExtension.php
Load configuration files depending on host in Symfony
// src/AcmeBundle/DependencyInjection/AcmeExtension.php
<?php
namespace AcmeBundle\DependencyInjection;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
@rigobertocontreras
rigobertocontreras / execAsync.js
Created May 18, 2018 16:23 — forked from davidrleonard/execAsync.js
Node exec async (with shell.js and bluebird)
const Promise = require('bluebird');
const sh = require('shelljs');
/**
* Asynchronously executes a shell command and returns a promise that resolves
* with the result.
*
* The `opts` object will be passed to shelljs's `exec()` and then to Node's native
* `child_process.exec()`. The most commonly used opts properties are:
*
@rigobertocontreras
rigobertocontreras / notes.md
Created November 8, 2017 03:46 — forked from mindscratch/notes.md
Debugging PHP Running in a Docker Container with XDebug and PHPStorm on macOS Sierra

I used docker compose to stand up MariaDB and Apache web server in containers.

xdebug

I'm using php7 with CentOS 7.2. I had to install "php70w-pecl-xdebug.x86_64". I also added the following the Dockerfile

RUN echo "xdebug.idekey = PHPSTORM" >> /etc/php.d/xdebug.ini &&
echo "xdebug.default_enable = 0" >> /etc/php.d/xdebug.ini &&
echo "xdebug.remote_enable = 1" >> /etc/php.d/xdebug.ini &&
echo "xdebug.remote_autostart = 0" >> /etc/php.d/xdebug.ini && \

@rigobertocontreras
rigobertocontreras / front.html
Created August 5, 2017 21:10 — forked from randerzander/front.html
zeppelin angular-tricks
%angular
<input id="textbox" class="hide" ng-model="someAngularVar"></input>
<button id="btn" type="submit" onclick="update()">UpperCase It!</button>
<script type="text/javascript">
function update(){
var element = $('#textbox');
var currentVal = element.val();
//Update the value
element.val(currentVal.toUpperCase());
@rigobertocontreras
rigobertocontreras / app.js
Created March 10, 2017 05:15 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@rigobertocontreras
rigobertocontreras / app.js
Created March 10, 2017 05:15 — forked from stongo/app.js
Joi validation in a Mongoose model
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
@rigobertocontreras
rigobertocontreras / contactform.js
Created December 3, 2015 23:40 — forked from insin/contactform.js
React contact form example
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var Example = React.createClass({
@rigobertocontreras
rigobertocontreras / select.jsx
Created December 3, 2015 19:44 — forked from jbottigliero/select.jsx
React <select> Component (JSX)
/** @jsx React.DOM */
define(['reactjs'], function(React){
return React.createClass({
getDefaultProps: function(){
return {
multiple: false
/*
name: 'mySelect'
{
"vars": {
"@gray-darker": "lighten(#000, 13.5%)",
"@gray-dark": "lighten(#000, 20%)",
"@gray": "lighten(#000, 33.5%)",
"@gray-light": "lighten(#000, 46.7%)",
"@gray-lighter": "lighten(#000, 93.5%)",
"@brand-primary": "#F4912C",
"@brand-success": "#4D4670",
"@brand-info": "#5bc0de",
class FormErrorsSerializer {
public function serializeFormErrors(\Symfony\Component\Form\Form $form, $flat_array = false, $add_form_name = false, $glue_keys = '_')
{
$errors = array();
$errors['global'] = array();
$errors['fields'] = array();
foreach ($form->getErrors() as $error) {
$errors['global'][] = $error->getMessage();