Merge pull request #227 from DSIW/master
Add some sinppets for ruby, tex and html. Merging the snippets now. If the "majority" is unhappy with some snippets the way to go is introducing "tex-more.snippets" and moving less used snippets there. Then people can opt in. First do brainstorming (collect snippets) - eventually judge later.
This commit is contained in:
commit
eaa01e7254
@ -730,10 +730,10 @@ snippet source
|
|||||||
<source src="${1}" type="${2}" media="${3}" />
|
<source src="${1}" type="${2}" media="${3}" />
|
||||||
snippet span
|
snippet span
|
||||||
<span>${1}</span>
|
<span>${1}</span>
|
||||||
snippet span#
|
|
||||||
<span id="${1}">${2}</span>
|
|
||||||
snippet span.
|
snippet span.
|
||||||
<span class="${1}">${2}</span>
|
<span class="${1}">${2}</span>
|
||||||
|
snippet span#
|
||||||
|
<span id="${1}">${2}</span>
|
||||||
snippet strong
|
snippet strong
|
||||||
<strong>${1}</strong>
|
<strong>${1}</strong>
|
||||||
snippet style
|
snippet style
|
||||||
|
@ -16,6 +16,14 @@ snippet =b
|
|||||||
=begin rdoc
|
=begin rdoc
|
||||||
${1}
|
${1}
|
||||||
=end
|
=end
|
||||||
|
snippet prot
|
||||||
|
protected
|
||||||
|
|
||||||
|
${1}
|
||||||
|
snippet priv
|
||||||
|
private
|
||||||
|
|
||||||
|
${1}
|
||||||
snippet y
|
snippet y
|
||||||
:yields: ${1:arguments}
|
:yields: ${1:arguments}
|
||||||
snippet rb
|
snippet rb
|
||||||
@ -156,6 +164,8 @@ snippet atp
|
|||||||
attr_protected :${1:attr_names}
|
attr_protected :${1:attr_names}
|
||||||
snippet ata
|
snippet ata
|
||||||
attr_accessible :${1:attr_names}
|
attr_accessible :${1:attr_names}
|
||||||
|
snippet ivc
|
||||||
|
@${1:variable_name} ||= ${2:chached_value}
|
||||||
# include Enumerable
|
# include Enumerable
|
||||||
snippet Enum
|
snippet Enum
|
||||||
include Enumerable
|
include Enumerable
|
||||||
@ -178,6 +188,11 @@ snippet defs
|
|||||||
def self.${1:class_method_name}
|
def self.${1:class_method_name}
|
||||||
${2}
|
${2}
|
||||||
end
|
end
|
||||||
|
# def initialize
|
||||||
|
snippet definit
|
||||||
|
def initialize(${1:args})
|
||||||
|
${2}
|
||||||
|
end
|
||||||
# def method_missing
|
# def method_missing
|
||||||
snippet defmm
|
snippet defmm
|
||||||
def method_missing(meth, *args, &blk)
|
def method_missing(meth, *args, &blk)
|
||||||
@ -309,6 +324,12 @@ snippet injd
|
|||||||
inject(${1:init}) do |${2:mem}, ${3:var}|
|
inject(${1:init}) do |${2:mem}, ${3:var}|
|
||||||
${4}
|
${4}
|
||||||
end
|
end
|
||||||
|
snippet red
|
||||||
|
reduce(${1:init}) { |${2:mem}, ${3:var}| ${4} }
|
||||||
|
snippet redd
|
||||||
|
reduce(${1:init}) do |${2:mem}, ${3:var}|
|
||||||
|
${4}
|
||||||
|
end
|
||||||
snippet map
|
snippet map
|
||||||
map { |${1:e}| ${2} }
|
map { |${1:e}| ${2} }
|
||||||
snippet mapd
|
snippet mapd
|
||||||
@ -597,14 +618,14 @@ snippet defcreate
|
|||||||
def create
|
def create
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
@${1:model_class_name} = ${2:ModelClassName}.new(params[:$1])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
if @$1.save
|
if @$1.save
|
||||||
flash[:notice] = '$2 was successfully created.'
|
flash[:notice] = '$2 was successfully created.'
|
||||||
wants.html { redirect_to(@$1) }
|
format.html { redirect_to(@$1) }
|
||||||
wants.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
format.xml { render :xml => @$1, :status => :created, :location => @$1 }
|
||||||
else
|
else
|
||||||
wants.html { render :action => "new" }
|
format.html { render :action => "new" }
|
||||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
@ -613,9 +634,9 @@ snippet defdestroy
|
|||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
@$1.destroy
|
@$1.destroy
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html { redirect_to($1s_url) }
|
format.html { redirect_to($1s_url) }
|
||||||
wants.xml { head :ok }
|
format.xml { head :ok }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defedit
|
snippet defedit
|
||||||
@ -626,41 +647,41 @@ snippet defindex
|
|||||||
def index
|
def index
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.all
|
@${1:model_class_name} = ${2:ModelClassName}.all
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # index.html.erb
|
format.html # index.html.erb
|
||||||
wants.xml { render :xml => @$1s }
|
format.xml { render :xml => @$1s }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defnew
|
snippet defnew
|
||||||
def new
|
def new
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.new
|
@${1:model_class_name} = ${2:ModelClassName}.new
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # new.html.erb
|
format.html # new.html.erb
|
||||||
wants.xml { render :xml => @$1 }
|
format.xml { render :xml => @$1 }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defshow
|
snippet defshow
|
||||||
def show
|
def show
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.html # show.html.erb
|
format.html # show.html.erb
|
||||||
wants.xml { render :xml => @$1 }
|
format.xml { render :xml => @$1 }
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
snippet defupdate
|
snippet defupdate
|
||||||
def update
|
def update
|
||||||
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
@${1:model_class_name} = ${2:ModelClassName}.find(params[:id])
|
||||||
|
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
if @$1.update_attributes(params[:$1])
|
if @$1.update_attributes(params[:$1])
|
||||||
flash[:notice] = '$2 was successfully updated.'
|
flash[:notice] = '$2 was successfully updated.'
|
||||||
wants.html { redirect_to(@$1) }
|
format.html { redirect_to(@$1) }
|
||||||
wants.xml { head :ok }
|
format.xml { head :ok }
|
||||||
else
|
else
|
||||||
wants.html { render :action => "edit" }
|
format.html { render :action => "edit" }
|
||||||
wants.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
format.xml { render :xml => @$1.errors, :status => :unprocessable_entity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end${3}
|
end${3}
|
||||||
@ -733,8 +754,8 @@ snippet ra
|
|||||||
snippet ral
|
snippet ral
|
||||||
render :action => "${1:action}", :layout => "${2:layoutname}"
|
render :action => "${1:action}", :layout => "${2:layoutname}"
|
||||||
snippet rest
|
snippet rest
|
||||||
respond_to do |wants|
|
respond_to do |format|
|
||||||
wants.${1:html} { ${2} }
|
format.${1:html} { ${2} }
|
||||||
end
|
end
|
||||||
snippet rf
|
snippet rf
|
||||||
render :file => "${1:filepath}"
|
render :file => "${1:filepath}"
|
||||||
@ -779,7 +800,7 @@ snippet ru
|
|||||||
snippet rxml
|
snippet rxml
|
||||||
render :xml => ${1:text to render}
|
render :xml => ${1:text to render}
|
||||||
snippet sc
|
snippet sc
|
||||||
scope :${1:name}, :where(:@${2:field} => ${3:value})
|
scope :${1:name}, -> { where(${2:field}: ${3:value}) }
|
||||||
snippet sl
|
snippet sl
|
||||||
scope :${1:name}, lambda do |${2:value}|
|
scope :${1:name}, lambda do |${2:value}|
|
||||||
where("${3:field = ?}", ${4:bind var})
|
where("${3:field = ?}", ${4:bind var})
|
||||||
@ -867,8 +888,8 @@ snippet vp
|
|||||||
validates :${1:attribute}, :presence => true
|
validates :${1:attribute}, :presence => true
|
||||||
snippet vu
|
snippet vu
|
||||||
validates :${1:attribute}, :uniqueness => true
|
validates :${1:attribute}, :uniqueness => true
|
||||||
snippet wants
|
snippet format
|
||||||
wants.${1:js|xml|html} { ${2} }
|
format.${1:js|xml|html} { ${2} }
|
||||||
snippet wc
|
snippet wc
|
||||||
where(${1:"conditions"}${2:, bind_var})
|
where(${1:"conditions"}${2:, bind_var})
|
||||||
snippet wh
|
snippet wh
|
||||||
@ -936,11 +957,16 @@ snippet its
|
|||||||
its(:${1:method}) { should ${2} }
|
its(:${1:method}) { should ${2} }
|
||||||
snippet itsn
|
snippet itsn
|
||||||
its(:${1:method}) { should_not ${2} }
|
its(:${1:method}) { should_not ${2} }
|
||||||
|
|
||||||
snippet desc
|
snippet desc
|
||||||
describe ${1:class_name} do
|
describe ${1:class_name} do
|
||||||
${2}
|
${2}
|
||||||
end
|
end
|
||||||
|
snippet descm
|
||||||
|
describe "#${1:method}" do
|
||||||
|
pending "Not implemented"
|
||||||
|
end
|
||||||
|
|
||||||
|
${2}
|
||||||
snippet cont
|
snippet cont
|
||||||
context "${1:message}" do
|
context "${1:message}" do
|
||||||
${2}
|
${2}
|
||||||
@ -959,10 +985,14 @@ snippet let!
|
|||||||
let!(:${1:object}) ${2:block}
|
let!(:${1:object}) ${2:block}
|
||||||
snippet subj
|
snippet subj
|
||||||
subject { ${1} }
|
subject { ${1} }
|
||||||
|
snippet s.
|
||||||
|
subject.${1:method}
|
||||||
snippet spec
|
snippet spec
|
||||||
specify { subject.${1} }
|
specify { subject.${1} }
|
||||||
snippet exp
|
snippet exp
|
||||||
expect(${1:object}).to ${2}
|
expect { ${1:object} }.to ${2}
|
||||||
|
snippet raise
|
||||||
|
expect { ${1:object} }.to raise_error ${2:StandardError}, /${3:message_regex}/
|
||||||
snippet btr
|
snippet btr
|
||||||
be_true
|
be_true
|
||||||
snippet bfa
|
snippet bfa
|
||||||
|
@ -80,7 +80,5 @@ snippet getopt
|
|||||||
esac # --- end of case ---
|
esac # --- end of case ---
|
||||||
done
|
done
|
||||||
shift $(($OPTIND-1))
|
shift $(($OPTIND-1))
|
||||||
|
|
||||||
|
|
||||||
snippet root
|
snippet root
|
||||||
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi
|
if [ $(id -u) -ne 0 ]; then exec sudo $0; fi
|
||||||
|
@ -56,6 +56,11 @@ snippet \
|
|||||||
\[
|
\[
|
||||||
${1}
|
${1}
|
||||||
\]
|
\]
|
||||||
|
# Equation array
|
||||||
|
snippet eqnarray
|
||||||
|
\begin{eqnarray}
|
||||||
|
${1}
|
||||||
|
\end{eqnarray}
|
||||||
# Enumerate
|
# Enumerate
|
||||||
snippet enum
|
snippet enum
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
@ -73,6 +78,10 @@ snippet desc
|
|||||||
\begin{description}
|
\begin{description}
|
||||||
\item[${1}] ${2}
|
\item[${1}] ${2}
|
||||||
\end{description}
|
\end{description}
|
||||||
|
# Endless new item
|
||||||
|
snippet ]i
|
||||||
|
\item ${1}
|
||||||
|
${2:]i}
|
||||||
# Matrix
|
# Matrix
|
||||||
snippet mat
|
snippet mat
|
||||||
\begin{${1:p/b/v/V/B/small}matrix}
|
\begin{${1:p/b/v/V/B/small}matrix}
|
||||||
@ -105,16 +114,31 @@ snippet sec
|
|||||||
\section{${1:section name}}
|
\section{${1:section name}}
|
||||||
\label{sec:${2:$1}}
|
\label{sec:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
|
# Section without number
|
||||||
|
snippet sec*
|
||||||
|
\section*{${1:section name}}
|
||||||
|
\label{sec:${2:$1}}
|
||||||
|
${3}
|
||||||
# Sub Section
|
# Sub Section
|
||||||
snippet sub
|
snippet sub
|
||||||
\subsection{${1:subsection name}}
|
\subsection{${1:subsection name}}
|
||||||
\label{sub:${2:$1}}
|
\label{sub:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
|
# Sub Section without number
|
||||||
|
snippet sub*
|
||||||
|
\subsection*{${1:subsection name}}
|
||||||
|
\label{sub:${2:$1}}
|
||||||
|
${3}
|
||||||
# Sub Sub Section
|
# Sub Sub Section
|
||||||
snippet subs
|
snippet subs
|
||||||
\subsubsection{${1:subsubsection name}}
|
\subsubsection{${1:subsubsection name}}
|
||||||
\label{ssub:${2:$1}}
|
\label{ssub:${2:$1}}
|
||||||
${3}
|
${3}
|
||||||
|
# Sub Sub Section without number
|
||||||
|
snippet subs*
|
||||||
|
\subsubsection*{${1:subsubsection name}}
|
||||||
|
\label{ssub:${2:$1}}
|
||||||
|
${3}
|
||||||
# Paragraph
|
# Paragraph
|
||||||
snippet par
|
snippet par
|
||||||
\paragraph{${1:paragraph name}}
|
\paragraph{${1:paragraph name}}
|
||||||
@ -205,4 +229,30 @@ snippet sum
|
|||||||
\sum^{${1:n}}_{${2:i=1}} ${3}
|
\sum^{${1:n}}_{${2:i=1}} ${3}
|
||||||
snippet lim
|
snippet lim
|
||||||
\lim_{${1:x \to +\infty}} ${2}
|
\lim_{${1:x \to +\infty}} ${2}
|
||||||
|
snippet frame
|
||||||
|
\begin{frame}[<+->]
|
||||||
|
\frametitle{${1:title}}
|
||||||
|
|
||||||
|
${2}
|
||||||
|
\end{frame}
|
||||||
|
snippet block
|
||||||
|
\begin{block}{${1:title}}
|
||||||
|
${2}
|
||||||
|
\end{block}
|
||||||
|
snippet alert
|
||||||
|
\begin{alertblock}{${1:title}}
|
||||||
|
${2}
|
||||||
|
\end{alertblock}
|
||||||
|
snippet example
|
||||||
|
\begin{exampleblock}{${1:title}}
|
||||||
|
${2}
|
||||||
|
\end{exampleblock}
|
||||||
|
snippet col2
|
||||||
|
\begin{columns}
|
||||||
|
\begin{column}{0.5\textwidth}
|
||||||
|
${1}
|
||||||
|
\end{column}
|
||||||
|
\begin{column}{0.5\textwidth}
|
||||||
|
${2}
|
||||||
|
\end{column}
|
||||||
|
\end{columns}
|
||||||
|
Loading…
Reference in New Issue
Block a user