Skip to content

Instantly share code, notes, and snippets.

View ramingar's full-sized avatar
:octocat:
Not a PRO user

Rafael Minguet ramingar

:octocat:
Not a PRO user
View GitHub Profile
@ramingar
ramingar / restore-dump-mysql.md
Last active June 29, 2017 15:37
Restaurar un dump de una BBDD mysql #database #mysql #dump #restore
mysql -u root -p
create database crud;
grant all on crud.* to 'usercrud'@'localhost';
exit;
mysql -u root -p crud < crud_dump.sql
@ramingar
ramingar / angularjs-promises-sample.js
Last active January 12, 2016 13:05
Esperar a que una función asíncrona de angularjs acabe para seguir #angularjs #promise #deferred #q #funciones #asincrona
$scope.getPersonIdFromEmail = function (email) {
var parameters = $scope.init('person/search/by-email');
parameters.email = email;
var deferred = $q.defer();
$q.all([$scope.get(parameters)]).then(function (data) {
/* En data irá el resultado que devuelva cada función que se le haya pasado a $q.all() */
/* Por tanto, en data[0] irá el resultado de $scope.get(parameters) */
deferred.resolve(data[0]._embedded.person[0]);
}, function (data) {
@ramingar
ramingar / new_file0
Created November 6, 2015 09:05
Actualizar menú cuando la url refresca #angular #actualizar #refrescar
/* listener for changes in uri */
appAngular.run(['$rootScope', 'ToggleMenuActive', function ($rootScope, ToggleMenuActive) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
ToggleMenuActive.active = current.$$route.originalPath;
});
}]);
/* directive to change class */
angular.module('organizationDirectives', [])
.directive('markAsActive', ['ToggleMenuActive', function (ToggleMenuActive) {
@ramingar
ramingar / routeChangeSuccess-to-activate-menu-item.js
Last active November 6, 2015 09:10
Actualizar menú cuando la url refresca #angular #routeChangeSuccess #menuItem #actualizar #refrescar
/* factory for injections */
appAngular.factory('ToggleMenuActive', [function () {
return {
"active" : ""
}
}]);
/* listener for changes in uri */
appAngular.run(['$rootScope', 'ToggleMenuActive', function ($rootScope, ToggleMenuActive) {
$rootScope.$on('$routeChangeSuccess', function (event, current, previous) {
@ramingar
ramingar / curl-command.md
Last active September 20, 2016 07:34
curl command #curl #commandline #commands

Without data:

curl --data '' https://example.com/resource.cgi
curl -X POST https://example.com/resource.cgi
curl --request POST https://example.com/resource.cgi

With fields:

curl --data "param1=value1&param2=value2" https://example.com/resource.cgi
@ramingar
ramingar / ssh-ec2-aws.md
Last active November 10, 2015 07:55
ssh a EC2 AWS #aws #ec2 #ssh

optional:

chmod 400 /path/my-key-pair.pem

then:

ssh -i /path/my-key-pair.pem [email protected]
@ramingar
ramingar / pandoc-markdown-2-pdf-conversion.md
Last active November 10, 2015 11:51
Pandoc from markdown to pdf #pandoc #markdown #pdf #conversion
pandoc YOUR_DOC.md -o example13.pdf

with TOC:

pandoc --toc YOUR_DOC.md -o example13.pdf
@ramingar
ramingar / angularjs-file-upload.md
Last active November 20, 2015 08:28
Multipart/form-data file upload with AngularJS #angularjs #fileupload #multipart_form_data

Credits to: Jenny Louthan.

Seen at: Uncorked Studios

###Getting the file in the controller’s scope:

.directive('fileModel', ['$parse', function ($parse) {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
@ramingar
ramingar / git-bisect-tests.md
Created December 1, 2015 08:26
Ejecutar los tests desde tu versión hacia atrás #git #bisect #test #bug

Realiza una ejecución de un comando en cada commit para realizar la búsqueda de un bug. P.ej. git bisect run phpunit -c app MyClassTest.php

Cuando me devuelva un error, me marcará en qué commit se produjo

git bisect start
git bisect bad __hashRevisionBad__ #Hash de la revisión donde se ha detectado el fallo
git bisect good __hashRevisionGood__ #Hash de una revisión en la que los test pasaban
git bisect run __command__ #El script que ejecuta los tests
@ramingar
ramingar / sharing-objects-between-fixtures.md
Last active December 3, 2015 10:56
Compartir objetos entre fixtures #symfony #doctrine #fixtures #addreference #merge

Lo que quieres compartir:

// compartes el $user y la clave para encontrarlo es 'organization_account'
$this->addReference('organization_account', $user);

Recuperas lo que has compartido y lo usas

$manager->merge($this->getReference('person_account'))