Skip to content

Instantly share code, notes, and snippets.

Rigoberto Contreras rigobertocontreras

Block or report user

Report or block rigobertocontreras

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rigobertocontreras
rigobertocontreras / domino.ts
Created Jan 5, 2019
Function to parse domino strings recursive.
View domino.ts
/*
Given a string, representing domino tiles chain. Each tile has L-R format, where L and R are numbers from 1..6 range. Tiles are separated by the comma. Some examples of valid S chain are:
1. 1-4,4-2,3-1
2. 6-3
3. 4-3,5-1,2-2,1-3,4-4
Devise a function that, give a domino string, returns the number of tiles in the longest matching group within S. A matching group is a set of tiles that match and that are subsequent in S. Domino tiles match, if the right side of a tile is the same as the left side of the following tile. 2-4,4-1 are matching tiles, but 5-2,1-6 are not.
domino("1-1,3-5,5-2,2-3,2-4") should return 3.
*/
#!/usr/bin/env node
console.time('timerName');
View generate.ts
// Save JSON of full schema introspection
import {graphql, introspectionQuery, printSchema} from "graphql";
import {writeFileSync} from "fs";
import {join} from "path";
import schema from "./index";
function generate() {
(async () => {
const result = await (graphql(schema, introspectionQuery));
if (result.errors) {
@rigobertocontreras
rigobertocontreras / AcmeExtension.php
Created Aug 16, 2018 — forked from chalasr/AcmeExtension.php
Load configuration files depending on host in Symfony
View AcmeExtension.php
// 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 — forked from davidrleonard/execAsync.js
Node exec async (with shell.js and bluebird)
View execAsync.js
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 Nov 8, 2017 — forked from mindscratch/notes.md
Debugging PHP Running in a Docker Container with XDebug and PHPStorm on macOS Sierra
View notes.md

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 Aug 5, 2017 — forked from randerzander/front.html
zeppelin angular-tricks
View front.html
%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 Mar 10, 2017 — forked from stongo/app.js
Joi validation in a Mongoose model
View app.js
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 Mar 10, 2017 — forked from stongo/app.js
Joi validation in a Mongoose model
View app.js
var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/test');
var db = mongoose.connection;
db.on('error', function() {
return console.error.bind(console, 'connection error: ');
});
View LocaleListener.php
<?php
namespace Acme\MainBundle\Listener;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\SecurityContext;
use Symfony\Component\HttpKernel\HttpKernel;
@rigobertocontreras
rigobertocontreras / contactform.js
Created Dec 3, 2015 — forked from insin/contactform.js
React contact form example
View contactform.js
/** @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({
You can’t perform that action at this time.