Skip to content

Instantly share code, notes, and snippets.

View wescleymatos's full-sized avatar
:octocat:
I'm ready!

Wescley Matos wescleymatos

:octocat:
I'm ready!
View GitHub Profile
@wescleymatos
wescleymatos / .bashrc
Created May 2, 2011 13:06
Minhas alterações no .bashrc
#config rvm
[[ -s "/home/wescley/.rvm/scripts/rvm" ]] && source "/home/wescley/.rvm/scripts/rvm"
#config path java
export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=/usr/lib/jvm/java-6-sun/bin:$PATH
#config path grails
export PATH=~/.grails/bin:$PATH
export GRAILS_HOME=~/.grails
@wescleymatos
wescleymatos / ajax.js
Created August 30, 2011 14:58
Requisição ajax com jquery
$(function(){
$("#UsuarioLogin").blur(function(){
$.ajax({
type: "GET",
url: "valido/" + $(this).val(),
dataType: "json",
beforeSend: function(){
console.log("carregando...");
},
success: function(text){
@wescleymatos
wescleymatos / gist:1373001
Created November 17, 2011 12:02
Pegar timeline do twitter
<?php
function pegatwitter($usuario, $qtd = 10){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'http://twitter.com/statuses/user_timeline/' . $usuario . '.json?count=' . $qtd,
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true)
);
$request = curl_exec($curl);
curl_close($curl);
@wescleymatos
wescleymatos / gist:1376621
Created November 18, 2011 14:39
Codigo para pegar feeds do youtube
<?php
// Seu usuário do YouTube
$usuario = 'username';
// URL do Feed RSS de vídeos de um usuário
$youTube_UserFeedURL = 'http://gdata.youtube.com/feeds/api/users/%s/uploads';
// Usa cURL para pegar o XML do feed
$cURL = curl_init(sprintf($youTube_UserFeedURL, $usuario));
curl_setopt($cURL, CURLOPT_RETURNTRANSFER, true);
@wescleymatos
wescleymatos / innerjoin.txt
Created November 30, 2011 14:34
Relação Entre inner join SQL e no Cakephp
--
-- Estrutura da tabela `cars`
--
CREATE TABLE IF NOT EXISTS `cars` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kind_id` int(11) NOT NULL,
`album_id` int(11) DEFAULT NULL,
`type` set('novo','usado') DEFAULT NULL,
`year` varchar(45) DEFAULT NULL,
@wescleymatos
wescleymatos / autocomple.txt
Created December 1, 2011 19:13
autocomplete com cake e jqueryUI
function admin_busca(){
$this->layout = "ajax";
$list = $this->Car->find('list',array('fields' => array('Car.id', 'Car.type')));
foreach($list as $key => $value){
$array[] = array("label" => $value, "value" => $value, "id" => $key);
}
echo json_encode($array);
}
========================================
<div class="ui-widget">
@wescleymatos
wescleymatos / paginate.php
Created December 1, 2011 19:47
Paginate cakephp
<?php
$this->paginate = array('joins'=>$joins,'fields' => array('*'),'conditions'=> array ('Sale.agent'=>$user['User']['id']));
?>
@wescleymatos
wescleymatos / htaccess
Created December 13, 2011 14:49
Configuração do htaccess raiz para o cakephp
#Negar a acesso a tudo mundo e liberar para um ip
Order Deny,Allow
Deny from all
Allow from 192.168.1.103
<IfModule mod_rewrite.c>
RewriteEngine on
#forçar o www
RewriteCond %{HTTP_HOST} !^www\. [NC]
@wescleymatos
wescleymatos / routes.php
Created December 17, 2011 13:42
Rota para criação de paginas estáticas
<?php
Router::connect('/*', array('controller' => 'pages', 'action' => 'display'));
?>
@wescleymatos
wescleymatos / impar_par.php
Created December 21, 2011 12:49
Verifica se o numero passado é par ou impar;
<?php
$imparPar = function($number)
{
return $number & 1;
};
echo $imparPar(2);
?>