Spring从2.0开始引入了一个新的机制用于扩展xml模式,我们就可以编写自定义的xml bean解析器然后集成到Spring IoC容器中。
xml扩展大概有以下几个步骤:
- 编写自定义类
- 编写xml schema来描述自定义元素
- 编写
NamespaceHandler新样式.css
的实现类 - 编写
BeanDefinitionParser
实现类 - 把以上组建注册到Spring
@startuml | |
' uncomment the line below if you're using computer with a retina display | |
' skinparam dpi 300 | |
!define Table(name,desc) class name as "desc" << (T,#FFAAAA) >> | |
' we use bold for primary key | |
' green color for unique | |
' and underscore for not_null | |
!define primary_key(x) <b>x</b> | |
!define unique(x) <color:green>x</color> | |
!define not_null(x) <u>x</u> |
package com.example; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.beans.factory.annotation.Qualifier; | |
import org.springframework.boot.SpringApplication; | |
import org.springframework.boot.autoconfigure.SpringBootApplication; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import java.util.List; |
const fetch = require('node-fetch') | |
const Bacon = require('baconjs') | |
function getInPortuguese(word) { | |
// Google Translate API is a paid (but dirt cheap) service. This is my key | |
// and will be disabled by the time the video is out. To generate your own, | |
// go here: https://cloud.google.com/translate/v2/getting_started | |
const apiKey = | |
'AIzaSyB4DyRHIsNhogQXmH16YKbZfR-lTXrQpq0' | |
const url = |
#!/bin/bash | |
#title :wildfly-install.sh | |
#description :The script to install Wildfly 9.0.2 | |
#author :Dmitriy Sukharev | |
#contributor :Kenner Kliemann | |
#date :14-11-2015 | |
#usage :/bin/bash wildfly-install.sh | |
#tested-version :9.0.2-Final | |
#tested-distros :CentOS 7; Ubuntu 14.04 |
package CompressAnImageToA4kibPreview; | |
import java.awt.BasicStroke; | |
import java.awt.Color; | |
import java.awt.GradientPaint; | |
import java.awt.Graphics2D; | |
import java.awt.Image; | |
import java.awt.RenderingHints; | |
import java.awt.RenderingHints.Key; | |
import java.awt.geom.Path2D; |
(def curl-opts | |
[["-A" "--user-agent AGENT" "User-Agent string" | |
:assoc-fn (fn [m _ v] (assoc-in m [:headers "User-Agent"] v))] | |
["-b" "--cookie DATA" "Cookie name=value" | |
:id :cookies :default {} | |
:assoc-fn (fn [m k v] (let [[kk & vv] (split v #"=")] | |
(assoc-in m [k kk] {:discard true | |
:path "/" | |
:value (join "=" vv)})))] | |
["-H" "--header DATA" "Header \"header: value\"" |
A lot of important government documents are created and saved in Microsoft Word (*.docx). But Microsoft Word is a proprietary format, and it's not really useful for presenting documents on the web. So, I wanted to find a way to convert a .docx file into markdown.
On a mac you can use homebrew by running the command brew install pandoc
.
require 'benchmark/ips' | |
require 'active_model' | |
require 'virtus' | |
require 'dry-validation' | |
require 'dry/validation/schema/form' | |
class User | |
include ActiveModel::Validations | |
include Virtus.model |