Skip to content

Instantly share code, notes, and snippets.

View antoniojps's full-sized avatar
🐬
Always learning

António Santos antoniojps

🐬
Always learning
View GitHub Profile
@antoniojps
antoniojps / tweenmax.js
Last active April 9, 2017 14:49
GSAP Tweenmax
// BASICO
var img = $('img'),
h2 = $('h2'),
tl = new TimelineMax();
tl
//from,fromTo, ou to, (elemento, tempo, opcoes)
.from(h2,0.3,{y:-15,autoAlpha:0,ease:Power1.easeOut})
// 0.15 seconds earlier than previous
.from(img,1,{y:-15,autoAlpha:0,ease:Power1.easeOut},'-=0.15')
@antoniojps
antoniojps / pdo.php
Last active April 9, 2017 14:49
PHP - PDO Connect e prepared statements
/////////////////////
// Connect
try {
$host = "localhost";
$database = "learning_pdo";
$db = new PDO("mysql:host=$host;dbname=$database;charset=utf8","antonio","123");
}
/*
HTTPS no Domain
Rate limiting
PDO Prepared statements
# Hash sensitive data
# Check the ORIGIN header
Check the REFERER header
If the Origin header is not present, verify the hostname in the
Referer header matches the site's origin.
@antoniojps
antoniojps / vue-cli
Last active April 9, 2017 14:50
Comandos para começar novo projeto Vue
$ vue init webpack-simple my-project
$ cd my-project
$ npm install
$ npm run dev
@antoniojps
antoniojps / vue-component.js
Last active April 9, 2017 14:50
Componentes do Vue
Vue.component('meu-componente',{
el: '.class',
// criamos funcao que retorna objetos para que nao interfiram com os outros componentes
data: function(){
return {
foo: 'bar'
}
},
template: '<p>{{foo}}</p>'
});
@antoniojps
antoniojps / es6.js
Last active April 9, 2017 14:50
ES6 - ECMASCRIPT 2015
/////////////////////////////////////////
// Let e const sao block scoped
{
let a = 2;
const b = "Hey";
console.log(a,b);
}
/////////////////////////////////////////
@antoniojps
antoniojps / vue-router.js
Last active April 9, 2017 14:50
Vue Router
import Vue from "vue"
import App from "./App.vue";
import VueRouter from "vue-router";
import User from "./components/user/User.vue";
import Home from './components/Home.vue';
Vue.use(VueRouter);
const router = new VueRouter(
{
@antoniojps
antoniojps / php-files.php
Created April 3, 2017 23:19
PHP Files Functions
<?php
$path ='/dir0/dir1/myfile.php';
$file = 'file1.txt';
// Return filename
echo basename($path);
// Return filename without ext
echo basename($path, '.php');
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)
)
@antoniojps
antoniojps / node-emitter.js
Created April 9, 2017 14:43
Node JS Emitter
// Emitter.js
// function constructor for event
function Emitter() {
this.events = {};
}
// prototype method to add listener (array of functions)
Emitter.prototype.on = function (type, listener) {
this.events[type] = this.events[type] || [];
this.events[type].push(listener);