Skip to content

Instantly share code, notes, and snippets.

View rafaelcalleja's full-sized avatar

Rafael Calleja rafaelcalleja

View GitHub Profile
/*
Change proposed values as necessary...
Proposed Table Name: `region`
Proposed Columns: ID(primary,), Name(char64), CountryCode(char2)
ID - varchar(6), primary key, not null
Name - varchar(64), not null
Country - char(2), not null
*/
INSERT INTO `region` VALUES
('AD-02', 'Canillo', 'AD'),
@rafaelcalleja
rafaelcalleja / README.md
Created March 17, 2016 00:03 — forked from tjamps/README.md
Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

Basic RESTful API with Symfony 2 + FOSRestBundle (JSON format only) + FOSUserBundle + FOSOauthServerBundle

The API we are creating in this gist will follow these rules :

  • The API only returns JSON responses
  • All API routes require authentication
  • Authentication is handled via OAuth2 with password Grant Type only (no need for Authorization pages and such).
  • API versioning is managed via a subdomain (e.g. v1.api.example.com)

The API will be written in PHP with the Symfony 2 framework. The following SF2 bundles are used :

@rafaelcalleja
rafaelcalleja / DirectoryStructure
Created June 3, 2016 09:53 — forked from satooshi/DirectoryStructure
Directory structure of Domain Driven Design application with Symfony2, Doctrine2.
sf2-ddd
├── app
├── bin
├── build
├── lib
├── src
│   └── __VendorPrefix
│   ├── Application
│   │   └── __DomainNameBundle
│   │   ├── Command
@rafaelcalleja
rafaelcalleja / threads.php
Created September 14, 2016 11:18
Running multiple threads example php
<?php
$pids = array();
for ($i = 0; $i < 10; ++$i) {
$pid = pcntl_fork();
if ($pid != 0) {
$pids[]=$pid;
@rafaelcalleja
rafaelcalleja / snippet.js
Created September 16, 2016 10:07 — forked from necolas/snippet.js
Optimised async loading of cross-domain scripts
/*
* Updated to use the function-based method described in http://www.phpied.com/social-button-bffs/
* Better handling of scripts without supplied ids.
*
* N.B. Be sure to include Google Analytics's _gaq and Facebook's fbAsyncInit prior to this function.
*/
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
(function () {
while (img = document.evaluate('//img[contains(@src, \'googleusercontent.com\')]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue) {
var src = img.attributes.src.value;
src = src.substr(src.indexOf('#') + 1);
img.attributes.src.value = src;
}
})();
@rafaelcalleja
rafaelcalleja / ddd_cqrs_event-sourcing_in_php.md
Created April 19, 2017 06:45 — forked from jsor/ddd_cqrs_event-sourcing_in_php.md
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD
@rafaelcalleja
rafaelcalleja / vm-resize-hard-disk.md
Created May 8, 2017 09:04 — forked from miraleung/vm-resize-hard-disk.md
Resize a hard disk for a vagrant-provisioned, VirtualBox-provided virtual machine using gparted and fdisk.

Added gparted instructions to extend the virtual disk to fork from christopher-hopper/vm-resize-hard-disk.md.

Resize a Hard Disk for a Virtual Machine

Our Virtual Machines are provisioned using Vagrant from a Linux base box to run using VirutalBox. If the Hard Disk space runs out and you cannot remove files to free-up space, you can resize the Hard Disk using some VirtualBox and Linux commands.

Some assumptions

@rafaelcalleja
rafaelcalleja / gist:663ebfddd156bc7d32375ddce1635c32
Created August 7, 2017 11:55 — forked from ondrasak/gist:10266716
Internet Explorer for Mac the Easy Way: Run IE 7, IE8, & IE9 in a Virtual Machine
1) If you have instaled VirtualBox skip this step. Download and install VirtualBox – Download Now (direct .dmg download link) – visit VirtualBox Downloads page
2) Launch the Terminal (located in /Applications/Utilities/)
3) Decide which versions of Internet Explorer you want to download and install. Select the text below and copy it:
- Install ALL versions of Internet Explorer: IE7, IE 8, and IE 9
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | bash
- Install Internet Explorer 7 Only
curl -s https://raw.github.com/xdissent/ievms/master/ievms.sh | IEVMS_VERSIONS="7" bash
https://parallelmindsblog.com/2012/12/18/some-basic-tips-to-speed-up-your-mysql-queries/
Parallel Minds Blogs
Some Basic Tips To Speed Up Your MySQL Queries
If you are interested in how to create fast MySqlqueries, this article is for you
1. Use persistent connections to the database to avoid connection overhead.
2. Check all tables have PRIMARY KEYs on columns with high cardinality (many rows match the key value). Well,`gender` column has low cardinality (selectivity), unique user id column has high one and is a good candidate to become a primary key.