Skip to content

Instantly share code, notes, and snippets.

@lusabo
lusabo / gist:919644
Created April 14, 2011 14:55
Exemplo - Curso ExtJs
var TwitterReader = new Ext.data.JsonReader({
idProperty: 'id',
root: 'users',
totalProperty: 'results',
fields: [
{name: 'description', mapping: 'description'},
{name: 'profile_image_url', mapping: 'profile_image_url'},
{name: 'name', mapping: 'name'},
{name: 'screen_name', mapping: 'screen_name'}
]
@lusabo
lusabo / Metas
Created December 30, 2011 13:28
Tela de Meta
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/jquery-ui.css"/> <!-- Link para o CSS do JQuery - Tema: Redmond -->
<link rel="stylesheet" type="text/css" href="css/table.css"/> <!-- Link para o CSS das Tabelas -->
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script> <!-- Link para o script principal do JQuery -->
<script type="text/javascript" src="js/jquery-ui-1.8.16.custom.min.js"></script> <!-- Link para o script do JQuery UI -->
<script type="text/javascript" src="js/jquery.maskedinput-1.3.min.js"></script> <!-- Link para o script do JQuery UI -->
<style>
body {
width: 80%;
@lusabo
lusabo / WebSecurityConfig_1.java
Created May 1, 2018 17:56
WebSecurityConfig - Step 1
package com.eco.security;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@lusabo
lusabo / application.properties
Last active May 1, 2018 19:17
application.properties
# Configurando conexão com o MySQL
spring.jpa.hibernate.ddl-auto=none
spring.datasource.url=jdbc:mysql://localhost:3306/eco
spring.datasource.username=root
spring.datasource.password=root
# Configurando o JWT
jwt.header=Authorization
jwt.secret=1us@b0
jwt.expiration=604800
@lusabo
lusabo / Profile.java
Last active May 1, 2018 18:32
Profile
package com.eco.security;
public enum Profile {
ROLE_ADMIN, ROLE_PATIENT, ROLE_DOCTOR;
}
@lusabo
lusabo / JwtTokenUtils.java
Last active May 1, 2018 19:40
JwtTokenUtils
package com.eco.security;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;
@lusabo
lusabo / User.java
Last active May 1, 2018 19:22
User
package com.eco.security;
import java.io.Serializable;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
@lusabo
lusabo / user.sql
Created May 1, 2018 19:26
Create User Table
CREATE TABLE user (
id INT NOT NULL AUTO_INCREMENT,
role VARCHAR(15) NOT NULL,
name VARCHAR(70) NOT NULL,
email VARCHAR(45) NOT NULL,
username VARCHAR(11) NOT NULL,
password VARCHAR(60) NOT NULL,
phone VARCHAR(11) NULL,
PRIMARY KEY (id))
ENGINE = InnoDB;
@lusabo
lusabo / UserRepository.java
Last active May 1, 2018 20:34
UserRepository
package com.eco.security;
// Imports
@Repository
public interface UserRepository extends JpaRepository<User, Long> {
User findByUsername(String username);
}
@lusabo
lusabo / PasswordUtils.java
Last active May 1, 2018 20:34
PasswordUtils
package com.eco.security;
// Imports
public class PasswordUtils {
@Autowired
private static BCryptPasswordEncoder encoder;
public static String generateBCrypt(String password) {