Skip to content

Instantly share code, notes, and snippets.

View johnsardine's full-sized avatar

João Sardinha johnsardine

View GitHub Profile
<?php
$email = new SendMail(); // Uma instancia do phpmailer extendida com o from e o smtp preenchidos e que podem ser substituidos à frente
$email->AddAddress(':email', utf8_decode(':nome'));
$email->Subject = utf8_decode(':assunto');
$email_body = array();
$email_body[] = '<p>:mensagem</p>';
$email->MsgHTML(utf8_decode(implode('', $email_body)));
$email->Send();

Imagine the following questions

A - What color is red? 1. Red (1 point) 2. Blue (0 points) 3. Green (0 points)

B - How many wheels has a car? 1. Two (0 points) 2. Four (1 point)

<?php
$score = array();
$negative_score = array();
$answers = ( !empty($_POST['answers']) ) ? $_POST['answers'] : array();
foreach ( $answers as $question_id => $answer ) {
<?php
// Disable magic quotes
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
@johnsardine
johnsardine / Advanced-Checkbox-Hack.markdown
Created December 27, 2013 10:14
A Pen by Tim Pietrusky.

Advanced Checkbox Hack

This works for both iOS and Android! You can use almost the default checkbox-hack syntax and just need to add two things:

1. Android smaller than / equal 4.1.2

pseudo-class + general/adjacent sibling doesn't work on Android 4.1.2 so we need a hack:

body { -webkit-animation: bugfix infinite 1s; }
@-webkit-keyframes bugfix { from {padding:0;} to {padding:0;} }
@johnsardine
johnsardine / context_events.js
Created January 3, 2014 10:44
When triggering events on selected elements on another context, events are not triggered. see solution below
var context = top.window;
// Instead of this
var target = jQuery('#'+data.target, context.document);
// Do this
var target = context.jQuery('#'+data.target);
target.val(data.value).trigger('change');
@johnsardine
johnsardine / apps.md
Created January 5, 2014 17:33
Mac Apps

Work

  • Coda (IDE)
  • CodeKit (Less)
  • Transmit (FTP)
  • Tower (GIT)
  • Sequel Pro (SQL)
  • MAMP (LAMP Server)
  • Propedit (Permission Management)
@johnsardine
johnsardine / jquery.nestable.js
Created January 12, 2014 19:20
My nestable fork
/*!
* Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
* Dual-licensed under the BSD or MIT licenses
*/
;(function($, window, document, undefined)
{
var hasTouch = 'ontouchstart' in window;
/**
* Detect CSS pointer-events property
@johnsardine
johnsardine / paypal_simple.php
Last active January 3, 2016 12:29
Simple paypal form
<form method='post' action='https://www.paypal.com/cgi-bin/webscr' target='_blank'>
<!-- no caso de vir de uma ligação segura deve ser _s-click -->
<input type='hidden' name='cmd' value='_xclick' />
<!-- O email ou o id da conta do cliente -->
<input type='hidden' name='business' value='XXXXXXXXXXXXX' />
<!-- Titulo do produto -->
<input type='hidden' name='item_name' value='Compra' />
@johnsardine
johnsardine / db-save-import.php
Last active August 29, 2015 13:56
Save and/or import database into other server
<?php
$config = array(
'name' => 'Project Name',
'id' => 'project-id',
// (bool) If false, will only generate the sql file and will not import to destination server
'import' => true,
// Usually the remote connection