Skip to content

Instantly share code, notes, and snippets.

@juanmanavarro
juanmanavarro / .htaccess
Created November 10, 2015 15:09
1&1 htaccess file
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ /index.php [L]
@juanmanavarro
juanmanavarro / magickdistortimage.c
Last active June 8, 2017 15:24
Use of the MagickDistortImage method from the MagickWand C API
MagickWand *image;
int num_args;
double args[1] = {.5}; // scale the image to half size
double args[1] = {45}; // rotate the image 45 degrees from the center
double args[2] = {.5, 45}; // scale and rotate image
double args[3] = {0, 0, 45}; // rotate the image from 0,0
double args[4] = {0, 0, .5, 45}; // rotate and scale image
double args[6] = {0, 0, .5, 45, 50, 50}; // rotate, scale and translate image to 50,50
<?php
function validateNif($nif) {
$nifRegEx = '/^[0-9]{8}[A-Z]$/i';
$nieRegEx = '/^[XYZ][0-9]{7}[A-Z]$/i';
$letras = "TRWAGMYFPDXBNJZSQVHLCKE";
if (preg_match($nifRegEx, $nif)) {
return ($letras[(substr($nif, 0, 8) % 23)] == $nif[8]);
} else {
if (preg_match($nieRegEx, $nif)) {
@juanmanavarro
juanmanavarro / myEnter.directive.js
Created October 19, 2017 09:26
AngularJS press enter directive
app.directive('myEnter', function () {
return function (scope, element, attrs) {
element.bind("keydown keypress", function (event) {
if(event.which === 13) {
scope.$apply(function (){
scope.$eval(attrs.myEnter);
});
event.preventDefault();
}
@juanmanavarro
juanmanavarro / PushLibrary.php
Created November 20, 2017 16:41
FCM push library
<?php namespace App\Libraries;
use GuzzleHttp\Client;
class PushLibrary {
protected $users;
protected $title;
protected $data;
@juanmanavarro
juanmanavarro / README.md
Last active May 14, 2019 15:02 — forked from hilios/README.md
init.d for supervisord for Amazon Linux AMI

Auto start for Supervisord at AWS

Install commands
$ sudo mv supervisor /etc/init.d
$ sudo chkconfig --add supervisor
$ sudo chkconfig supervisor on
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
class MakeAngularComponent extends Command
{
/**
* The name and signature of the console command.
<IfModule mod_rewrite.c>
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<IfModule mod_setenvif.c>
SetEnvIf X-Forwarded-Proto "^https$" HTTPS
</IfModule>
@juanmanavarro
juanmanavarro / amazon-domains.json
Created January 27, 2023 16:46 — forked from AminulBD/amazon-domains.json
Amazon operating domains by country.
{
"us": "https://www.amazon.com",
"uk": "https://www.amazon.co.uk",
"ca": "https://www.amazon.ca",
"de": "https://www.amazon.de",
"es": "https://www.amazon.es",
"fr": "https://www.amazon.fr",
"it": "https://www.amazon.it",
"jp": "https://www.amazon.co.jp",
"in": "https://www.amazon.in",
@juanmanavarro
juanmanavarro / countries.json
Last active August 14, 2023 09:48 — forked from keeguon/countries.json
A list of countries in JSON
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},
{