Skip to content

Instantly share code, notes, and snippets.

View enapupe's full-sized avatar

Iacami Gevaerd enapupe

View GitHub Profile
// http://pastie.org/783420.
// view the full video at:
// http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish
/* d8b .d88888b. d888 d8888
Y8P d88P" "Y88b d8888 d8P888
888 888 888 d8P 888
8888 888 888 888 888 .d88b. 888d888 888 888 888 d8P 888
"888 888 888 888 888 d8P Y8b 888P" 888 888 888 d88 888
888 888 Y8b 888 888 888 88888888 888 888 888 888 8888888888
@enapupe
enapupe / gist:775097
Created January 11, 2011 20:43
register_globals post
while (list($n,$v) = each($_POST)) {
$$n=$v;
}
@enapupe
enapupe / filter post
Created October 13, 2011 17:29
filter post columns to prevent injection
function filter_post($post, $columns){
return array_intersect_key($post, array_flip($columns));
}
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
function myInArray($array, $value, $key){
//loop through the array
foreach ($array as $val) {
//if $val is an array cal myInArray again with $val as array input
if(is_array($val)){
if(myInArray($val,$value,$key))
return true;
}
@enapupe
enapupe / slidebox.js
Created January 1, 2012 17:08
slideBox
$.fn.slideBox = function(){
var blockIt=function(a){if(!a.hasClass("blocked"))return a.addClass("blocked"),!0}
this.each(function(){
var a = $(this);
//prevent double binding
if (blockIt(a)) {
var obj = a.children();
var content_size = {width: obj.width(), height: obj.height()}
var total_size_minus_visible_area = {width: content_size.width - a.width(), height: content_size.height - a.height()};
var wrapperSize = {width:content_size.width + total_size_minus_visible_area.width, height: content_size.height + total_size_minus_visible_area.height};
@enapupe
enapupe / slider
Created January 5, 2012 17:58
simple left to right slider
$.fn.enapupeSlider = function(changeDelay, transitionDelay, startDelay, halt_opt) {
var blockIt = function (a){
if (!a.hasClass("blocked"))
return a.addClass("blocked"),!0
}
this.each(function(inc, el){
if (blockIt($(el))) {
//shows master slideshow div onstart
$(el).css("visibility", "visible");
<?php
namespace Obiz\Challenges\CashMachine;
class WithdrawException extends \Exception {
}
class CashMachine {
function s1mp_cep($cep) {
try {
$get = file_get_contents("http://cep.s1mp.net/" . $cep);
} catch (Exception $e) {
return false;
}
if ($json = json_decode($get)) {
if ($json->result === true) {
return array('cidade' => $json->data->cidade, 'uf' => $json->data->uf, 'logradouro' => $json->data->logradouro, 'bairro' => $json->data->bairro, 'tp_logradouro' => $json->data->tp_logradouro);>tp_logradouro);
}
//drop utm
if(/utm_/.test(location.search)&&window.history.replaceState){var oldUrl=location.href,newUrl=oldUrl.replace(/\?([^#]*)/,function(b,a){return(a=a.split("&").map(function(a){return!/^utm_/.test(a)&&a}).filter(Boolean).join("&"))?"?"+a:""});newUrl!=oldUrl&&window.history.replaceState({},"",newUrl)};
(function($){
})(jQuery);
<?php
//error_reporting(0);
$validation = array(
'email' => 'Digite um e-mail!',
'nome' => "Digite seu nome!"
);
foreach($validation as $key => $message){
if (empty($_POST[$key])){
echo json_encode(array('message' => $message, 'status' => 'fail'));
exit;