This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Primeiro a lógica é que o usuário precise fazer o login | |
* Depois do usuário logar, você armazena alguns dados do usuário no login | |
*/ | |
session_start();// abre um sessão do PHP | |
// $_SESSION é uma váriavel global do php, guarda dados por sessão, traduzindo enquanto | |
// você não destruir a sessão, ou fechar o navegador, os dados vão permanecer lá | |
$_SESSION['cart'] = array();// iniciando o cart como um array, assim podemos armazenar vários produtos e os dados do cliente |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Return all the arguments of a specific function. | |
* @param func | |
* @returns {Array|{index: number, input: string}} | |
*/ | |
function func_get_args(func) { | |
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | |
var ARGUMENT_NAMES = /([^\s,]+)/g; | |
var fnStr = func.toString().replace(STRIP_COMMENTS, ''); | |
var result = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')).match(ARGUMENT_NAMES); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if ($node = menu_get_object()) { | |
// Get the nid | |
$nid = $node->nid; | |
if($data->nid == $nid){ | |
return TRUE; | |
}else{ | |
return FALSE; | |
} | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!is_null(arg(1)) { | |
// Get the nid | |
$node_date = $data->field_data['und'][0]['value']; | |
$date = date('Y' , strtotime($node_date)); | |
if($date != arg(1)){ | |
return TRUE; | |
}else{ | |
return FALSE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SSH_ENV=$HOME/.ssh/environment | |
# start the ssh-agent | |
function start_agent { | |
echo "Initializing new SSH agent..." | |
# spawn ssh-agent | |
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}" | |
echo succeeded | |
chmod 600 "${SSH_ENV}" | |
. "${SSH_ENV}" > /dev/null |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function implode(separator, data) { | |
var str = []; | |
for (var key in data) { | |
if (typeof data[key] !== 'function' && data.hasOwnProperty(key)) { | |
var _str = key + '=' + data[key]; | |
str.push(_str); | |
} | |
} | |
return str.join(separator); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var gulp = require('gulp'); | |
var plumber = require('gulp-plumber'); | |
var concat = require('gulp-concat'); | |
var uglify = require('gulp-uglify'); | |
var postcss = require('gulp-postcss'); | |
var autoprefixer = require('autoprefixer'); | |
var cssnano = require('cssnano'); | |
var sourcemaps = require('gulp-sourcemaps'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_ip_address() { | |
$ip_keys = array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR'); | |
foreach ($ip_keys as $key) { | |
if (array_key_exists($key, $_SERVER) === true) { | |
foreach (explode(',', $_SERVER[$key]) as $ip) { | |
// trim for safety measures | |
$ip = trim($ip); | |
// attempt to validate IP | |
if (validate_ip($ip)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function deleteAction(){ | |
// not a good practice | |
Mage::register("isSecureArea", 1); | |
//load all categories | |
$categories = Mage::getModel('catalog/category') | |
->getCollection() | |
->addAttributeToSelect('*') | |
->addIsActiveFilter(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.callPlayer = function (iframe, func, args) { | |
var iframe = document.getElementById(iframe); | |
var src = iframe.getAttribute('src'); | |
if (src && src.indexOf('youtube.com/embed') !== -1) { | |
iframe.contentWindow.postMessage(JSON.stringify({ | |
'event': 'command', | |
'func': func, | |
'args': args || [] | |
}), '*'); |
OlderNewer