Skip to content

Instantly share code, notes, and snippets.

View emmgfx's full-sized avatar
🏠
Working from home

Josep Viciana emmgfx

🏠
Working from home
View GitHub Profile
@emmgfx
emmgfx / class.mr.php
Created June 25, 2018 15:16
Test mailrelay
<?php
class MR {
private $url = null;
private $apikey = null;
public $id_package = null;
function __construct($url, $apikey){
$this->url = $url;
const int sensorPin = A0;
const int ledGreenPin = 2;
const int ledYellowPin = 3;
const int ledRedPin = 4;
const float temperatureCorrect = 19.0;
const float temperatureRaised = 20.0;
void setup() {
Serial.begin(9600);
pinMode(ledGreenPin, OUTPUT);
@emmgfx
emmgfx / 0-send-email-plesk.php
Last active March 2, 2024 11:49
Send email with PHPMailer and SMTP, default and Plesk
<?php
date_default_timezone_set('Europe/Madrid');
require_once 'PHPMailer-5.2.16/PHPMailerAutoload.php';
$mail = new PHPMailer;
$mail->isSMTP();
$mail->SMTPDebug = 2; # 0 off, 1 client, 2 client y server
$mail->CharSet = 'UTF-8';
<?php
function checkRecaptcha($recaptcha_response){
$url = 'https://www.google.com/recaptcha/api/siteverify';
$fields = array(
'secret' => 'YOUR_SECRET_KEY',
'response' => $recaptcha_response,
);
$fields_string = '';
@emmgfx
emmgfx / recaptcha.php
Created July 20, 2016 08:07
Check Recaptcha
<?php
if(checkRecaptcha($_POST['g-recaptcha-response'])){
# Recaptcha OK
}else{
# Recaptcha KO
}
function checkRecaptcha($recaptcha_response){
$url = 'https://www.google.com/recaptcha/api/siteverify';
@emmgfx
emmgfx / gist:5fb1ab747e9f643e5dfd
Last active August 29, 2015 14:22
Javascript number pad
Number.prototype.pad = function(size) {
var s = String(this);
while (s.length < (size || 2)) {s = "0" + s;}
return s;
}
// Examples:
var i = 1;
$age = date_diff(date_create($bdate), date_create('now'))->y;
@emmgfx
emmgfx / gist:75c8fa87636ec0e35995
Created February 5, 2015 08:18
Debug Symfony2
<?PHP
namespace ...
...
use Symfony\Component\Debug\Debug;
Debug::enable();
class ... extends Controller
@emmgfx
emmgfx / .editorconfig
Last active June 15, 2017 15:53
Boilerplate
# Editor configuration, see http://editorconfig.org
root = true
[*]
charset = utf-8
indent_style = space
indent_size = 4
insert_final_newline = true
trim_trailing_whitespace = true
@emmgfx
emmgfx / gist:0f018b5acfa3fd72b3f6
Created May 2, 2014 07:49
Android JSONArray remove before API 19
// Example of use: remove(i, savedProfiles);
public static JSONArray remove(final int idx, final JSONArray from) {
final List<JSONObject> objs = asList(from);
objs.remove(idx);
final JSONArray ja = new JSONArray();
for (final JSONObject obj : objs) {
ja.put(obj);
}