diff --git a/snippets/_.snippets b/snippets/_.snippets index b99f454..081db1c 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -214,4 +214,14 @@ snippet APACHE See the License for the specific language governing permissions and limitations under the License. + ${3} +snippet BEERWARE + ${1:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${2:copyright holder} + + Licensed under the "THE BEER-WARE LICENSE" (Revision 42): + ${1:`g:snips_author`} wrote this file. As long as you retain this notice you + can do whatever you want with this stuff. If we meet some day, and you think + this stuff is worth it, you can buy me a beer or coffee in return + ${3} diff --git a/snippets/clojure.snippets b/snippets/clojure.snippets new file mode 100644 index 0000000..e247deb --- /dev/null +++ b/snippets/clojure.snippets @@ -0,0 +1,90 @@ +snippet comm + (comment + ${1} + ) +snippet condp + (condp ${1:pred} ${2:expr} + ${3}) +snippet def + (def ${1}) +snippet defm + (defmethod ${1:multifn} "${2:doc-string}" ${3:dispatch-val} [${4:args}] + ${5}) +snippet defmm + (defmulti ${1:name} "${2:doc-string}" ${3:dispatch-fn}) +snippet defma + (defmacro ${1:name} "${2:doc-string}" ${3:dispatch-fn}) +snippet defn + (defn ${1:name} "${2:doc-string}" [${3:arg-list}] + ${4}) +snippet defp + (defprotocol ${1:name} + ${2}) +snippet defr + (defrecord ${1:name} [${2:fields}] + ${3:protocol} + ${4}) +snippet deft + (deftest ${1:name} + (is (= ${2:assertion}))) + ${3}) +snippet is + (is (= ${1} ${2})) +snippet defty + (deftype ${1:Name} [${2:fields}] + ${3:Protocol} + ${4}) +snippet doseq + (doseq [${1:elem} ${2:coll}] + ${3}) +snippet fn + (fn [${1:arg-list}] ${2}) +snippet if + (if ${1:test-expr} + ${2:then-expr} + ${3:else-expr}) +snippet if-let + (if-let [${1:result} ${2:test-expr}] + (${3:then-expr} $1) + (${4:else-expr})) +snippet imp + (:import [${1:package}]) + & {:keys [${1:keys}] :or {${2:defaults}}} +snippet let + (let [${1:name} ${2:expr}] + ${3}) +snippet letfn + (letfn [(${1:name) [${2:args}] + ${3})]) +snippet map + (map ${1:func} ${2:coll}) +snippet mapl + (map #(${1:lambda}) ${2:coll}) +snippet met + (${1:name} [${2:this} ${3:args}] + ${4}) +snippet ns + (ns ${1:name} + ${2}) +snippet dotimes + (dotimes [_ 10] + (time + (dotimes [_ ${1:times}] + ${2}))) +snippet pmethod + (${1:name} [${2:this} ${3:args}]) +snippet refer + (:refer-clojure :exclude [${1}]) +snippet require + (:require [${1:namespace} :as [${2}]]) +snippet use + (:use [${1:namespace} :only [${2}]]) +snippet print + (println ${1}) +snippet reduce + (reduce ${1:(fn [p n] ${3})} ${2}) +snippet when + (when ${1:test} ${2:body}) +snippet when-let + (when-let [${1:result} ${2:test}] + ${3:body}) diff --git a/snippets/cs.snippets b/snippets/cs.snippets index fd8c255..725f8b7 100644 --- a/snippets/cs.snippets +++ b/snippets/cs.snippets @@ -59,28 +59,28 @@ # entry point snippet sim public static int Main(string[] args) { - ${1} - return 0; + ${1} + return 0; } snippet simc public class Application { - public static int Main(string[] args) { - ${1} - return 0; - } + public static int Main(string[] args) { + ${1} + return 0; + } } # if condition snippet if if (${1}) { - ${2} + ${2} } snippet el else { - ${1} + ${1} } snippet ifs if (${1}) - ${2} + ${2} # ternary conditional snippet t ${1} ? ${2} : ${3} @@ -89,77 +89,77 @@ snippet ? # do while loop snippet do do { - ${2} + ${2} } while (${1}); # while loop snippet wh while (${1}) { - ${2} + ${2} } # for loop snippet for for (int ${1:i} = 0; $1 < ${2:count}; $1${3:++}) { - ${4} + ${4} } # foreach snippet fore foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } snippet foreach foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } snippet each foreach (var ${1:entry} in ${2}) { - ${3} + ${3} } # interfaces snippet interface public interface ${1:`Filename()`} { - ${2} + ${2} } snippet if+ public interface ${1:`Filename()`} { - ${2} + ${2} } # class bodies snippet class public class ${1:`Filename()`} { - ${2} + ${2} } snippet cls ${2:public} class ${1:`Filename()`} { - ${3} + ${3} } snippet cls+ public class ${1:`Filename()`} { - ${2} + ${2} } snippet cls+^ public static class ${1:`Filename()`} { - ${2} + ${2} } snippet cls& internal class ${1:`Filename()`} { - ${2} + ${2} } snippet cls&^ internal static class ${1:`Filename()`} { - ${2} + ${2} } snippet cls| protected class ${1:`Filename()`} { - ${2} + ${2} } snippet cls|% protected abstract class ${1:`Filename()`} { - ${2} + ${2} } # constructor snippet ctor public ${1:`Filename()`}() { - ${2} + ${2} } # properties - auto properties by default. # default type is int with layout get / set. @@ -259,101 +259,101 @@ snippet ps- # members - void snippet m ${1:public} ${2:void} ${3:}(${4:}) { - ${5:} + ${5:} } snippet m+ public ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m& internal ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m| protected ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } snippet m- private ${1:void} ${2:}(${3:}) { - ${4:} + ${4:} } # members - int snippet mi ${1:public} int ${2:}(${3:}) { - ${4:return 0;} + ${4:return 0;} } snippet mi+ public int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi& internal int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi| protected int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } snippet mi- private int ${1:}(${2:}) { - ${3:return 0;} + ${3:return 0;} } # members - bool snippet mb ${1:public} bool ${2:}(${3:}) { - ${4:return false;} + ${4:return false;} } snippet mb+ public bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb& internal bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb| protected bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } snippet mb- private bool ${1:}(${2:}) { - ${3:return false;} + ${3:return false;} } # members - string snippet ms ${1:public} string ${2:}(${3:}) { - ${4:return "";} + ${4:return "";} } snippet ms+ public string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms& internal string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms| protected string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } snippet ms- private string ${1:}(${2:}) { - ${3:return "";} + ${3:return "";} } # structure snippet struct public struct ${1:`Filename()`} { - ${2} + ${2} } # enumeration snippet enum public enum ${1} { - ${2} + ${2} } # preprocessor directives snippet #if #if - ${1} + ${1} #endif # inline xml documentation snippet /// diff --git a/snippets/erlang.snippets b/snippets/erlang.snippets index e44bf5e..acc6fd1 100644 --- a/snippets/erlang.snippets +++ b/snippets/erlang.snippets @@ -33,6 +33,16 @@ snippet case ${2:pattern} -> ${3:body}; end +# anonymous function +snippet fun + fun (${1:Parameters}) -> ${2:body} end${3} +# try...catch +snippet try + try + ${1} + catch + ${2:_:_} -> ${3:got_some_exception} + end # record directive snippet rec -record(${1:record}, { @@ -54,3 +64,97 @@ snippet %s # private function marker snippet %p %% @private +# OTP application +snippet application + -module(${1:`Filename('', 'my')`}). + + -behaviour(application). + + -export([start/2, stop/1]). + + start(_Type, _StartArgs) -> + case ${2:root_supervisor}:start_link() of + {ok, Pid} -> + {ok, Pid}; + Other -> + {error, Other} + end. + + stop(_State) -> + ok. +# OTP supervisor +snippet supervisor + -module(${1:`Filename('', 'my')`}). + + -behaviour(supervisor). + + %% API + -export([start_link/0]). + + %% Supervisor callbacks + -export([init/1]). + + -define(SERVER, ?MODULE). + + start_link() -> + supervisor:start_link({local, ?SERVER}, ?MODULE, []). + + init([]) -> + Server = {${2:my_server}, {$2, start_link, []}, + permanent, 2000, worker, [$2]}, + Children = [Server], + RestartStrategy = {one_for_one, 0, 1}, + {ok, {RestartStrategy, Children}}. +# OTP gen_server +snippet gen_server + -module(${1:`Filename('', 'my')`}). + + -behaviour(gen_server). + + %% API + -export([ + start_link/0 + ]). + + %% gen_server callbacks + -export([init/1, handle_call/3, handle_cast/2, handle_info/2, + terminate/2, code_change/3]). + + -define(SERVER, ?MODULE). + + -record(state, {}). + + %%%=================================================================== + %%% API + %%%=================================================================== + + start_link() -> + gen_server:start_link({local, ?SERVER}, ?MODULE, [], []). + + %%%=================================================================== + %%% gen_server callbacks + %%%=================================================================== + + init([]) -> + {ok, #state{}}. + + handle_call(_Request, _From, State) -> + Reply = ok, + {reply, Reply, State}. + + handle_cast(_Msg, State) -> + {noreply, State}. + + handle_info(_Info, State) -> + {noreply, State}. + + terminate(_Reason, _State) -> + ok. + + code_change(_OldVsn, State, _Extra) -> + {ok, State}. + + %%%=================================================================== + %%% Internal functions + %%%=================================================================== + diff --git a/snippets/eruby.snippets b/snippets/eruby.snippets index f856265..be1c7ec 100644 --- a/snippets/eruby.snippets +++ b/snippets/eruby.snippets @@ -7,6 +7,10 @@ snippet rc <% ${1} %> snippet rce <%= ${1} %>${2} +snippet % + <% ${1} %> +snippet = + <%= ${1} %>${2} snippet end <% end %>${1} snippet ead @@ -36,7 +40,7 @@ snippet lica snippet licai <%= link_to '${1:link text...}', :controller => '${2:items}', :action => '${3:edit}', :id => ${4:@item} %> snippet yield - <%= yield${1::content_symbol}%>${2} + <%= yield ${1::content_symbol} %>${2} snippet conf <% content_for :${1:head} do %> ${2} diff --git a/snippets/falcon.snippets b/snippets/falcon.snippets index 2d12df3..85fb918 100644 --- a/snippets/falcon.snippets +++ b/snippets/falcon.snippets @@ -1,23 +1,28 @@ snippet #! #!/usr/bin/env falcon + # Import snippet imp import ${1:module} + # Function snippet fun function ${2:function_name}(${3}) ${4:/* code */} end + # Class snippet class class ${1:class_name}(${2:class_params}) ${3:/* members/methods */} end + # If snippet if if ${1:condition} ${2:/* code */} end + # If else snippet ife if ${1:condition} @@ -25,86 +30,42 @@ snippet ife else ${1} end + # If else if snippet elif elif ${1:condition} ${2:/* code */} + +# Switch case +snippet switch + switch ${1:expression} + case ${2:item} + case ${3:item} + default + end + +# Select +snippet select + select ${1:variable} + case ${2:TypeSpec} + case ${3:TypeSpec} + default + end + # For/in Loop snippet forin for ${1:element} in ${2:container} ${3:/* code */} end + # For/to Loop snippet forto for ${1:lowerbound} to ${2:upperbound} ${3:/* code */} end + # While Loop snippet while while ${1:conidition} ${2:/* code */} end - -#==================================== -# Common Licenses -#==================================== -# GPL -snippet gpl - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version ${3:version} of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -# APLv2 -snippet apache - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -# BSD -snippet bsd - /* Copyright (c) `strftime("%Y")` ${1:`g:snips_author`} <${2:email}> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ diff --git a/snippets/html.snippets b/snippets/html.snippets index ca6bbcf..be8b0f6 100644 --- a/snippets/html.snippets +++ b/snippets/html.snippets @@ -387,9 +387,9 @@ snippet h2# snippet h3

${1}

snippet h3. -

${2}

+

${2}

snippet h3# -

${2}

+

${2}

snippet h4

${1}

snippet h4. @@ -565,7 +565,7 @@ snippet map# snippet map+ - ${6} + ${5}${6} ${7} snippet mark ${1} diff --git a/snippets/htmldjango.snippets b/snippets/htmldjango.snippets index c87b5ee..38f836b 100644 --- a/snippets/htmldjango.snippets +++ b/snippets/htmldjango.snippets @@ -12,17 +12,17 @@ snippet { snippet autoescape {% autoescape ${1:off} %} - ${2} + ${2} {% endautoescape %} snippet block {% block ${1} %} - ${2} + ${2} {% endblock %} snippet # {# ${1:comment} #} snippet comment {% comment %} - ${1} + ${1} {% endcomment %} snippet cycle {% cycle ${1:val1} ${2:val2} ${3:as ${4}} %} @@ -32,33 +32,33 @@ snippet extends {% extends "${1:base.html}" %} snippet filter {% filter ${1} %} - ${2} + ${2} {% endfilter %} snippet firstof {% firstof ${1} %} snippet for {% for ${1} in ${2} %} - ${3} + ${3} {% endfor %} snippet empty {% empty %} ${1} snippet if {% if ${1} %} - ${2} + ${2} {% endif %} snippet else {% else %} - ${1} + ${1} snippet ifchanged {% ifchanged %}${1}{% endifchanged %} snippet ifequal {% ifequal ${1} ${2} %} - ${3} + ${3} {% endifequal %} snippet ifnotequal {% ifnotequal ${1} ${2} %} - ${3} + ${3} {% endifnotequal %} snippet include {% include "${1}" %} diff --git a/snippets/java.snippets b/snippets/java.snippets index 784153d..fb27b9c 100644 --- a/snippets/java.snippets +++ b/snippets/java.snippets @@ -1,84 +1,121 @@ -snippet main - public static void main (String[] args) { - ${1:/* code */} - } -snippet pu - public +## Access Modifiers snippet po protected +snippet pu + public snippet pr private -snippet st - static -snippet fi - final -snippet ab - abstract -snippet re - return -snippet br - break; -snippet de - default: - ${1} -snippet ca - catch(${1:Exception} ${2:e}) ${3} -snippet th - throw -snippet sy - synchronized +## +## Annotations +snippet before + @Before + static void ${1:intercept}(${2:args}) { ${3} } +snippet mm + @ManyToMany + ${1} +snippet mo + @ManyToOne + ${1} +snippet om + @OneToMany${1:(cascade=CascadeType.ALL)} + ${2} +snippet oo + @OneToOne + ${1} +## +## Basic Java packages and import snippet im import -snippet imp - implements -snippet ext - extends -snippet j.u - java.util -snippet j.i - java.io. snippet j.b java.beans. -snippet j.n - java.net. +snippet j.i + java.io. snippet j.m java.math. -snippet if - if (${1}) ${2} -snippet el - else -snippet elif - else if (${1}) ${2} -snippet wh - while (${1}) ${2} -snippet for - for (${1}; ${2}; ${3}) ${4} -snippet fore - for (${1} : ${2}) ${3} -snippet sw - switch (${1}) ${2} -snippet cs - case ${1}: - ${2} - ${3} -snippet tc - public class ${1:`Filename()`} extends ${2:TestCase} -snippet t - public void test${1:Name}() throws Exception ${2} +snippet j.n + java.net. +snippet j.u + java.util. +## +## Class snippet cl class ${1:`Filename("", "untitled")`} ${2} snippet in interface ${1:`Filename("", "untitled")`} ${2:extends Parent}${3} -snippet m - ${1:void} ${2:method}(${3}) ${4:throws }${5} -snippet v - ${1:String} ${2:var}${3: = null}${4};${5} +snippet tc + public class ${1:`Filename()`} extends ${2:TestCase} +## +## Class Enhancements +snippet ext + extends +snippet imp + implements +## +## Comments +snippet /* + /* + * ${1} + */ +## +## Constants snippet co static public final ${1:String} ${2:var} = ${3};${4} snippet cos static public final String ${1:var} = "${2}";${3} +## +## Control Statements +snippet case + case ${1}: + ${2} +snippet def + default: + ${2} +snippet el + else +snippet elif + else if (${1}) ${2} +snippet if + if (${1}) ${2} +snippet sw + switch (${1}) { + ${2} + } +## +## Create a Method +snippet m + ${1:void} ${2:method}(${3}) ${4:throws }${5} +## +## Create a Variable +snippet v + ${1:String} ${2:var}${3: = null}${4};${5} +## +## Enhancements to Methods, variables, classes, etc. +snippet ab + abstract +snippet fi + final +snippet st + static +snippet sy + synchronized +## +## Error Methods +snippet err + System.err.print("${1:Message}"); +snippet errf + System.err.printf("${1:Message}", ${2:exception}); +snippet errln + System.err.println("${1:Message}"); +## +## Exception Handling snippet as assert ${1:test} : "${2:Failure message}";${3} +snippet ca + catch(${1:Exception} ${2:e}) ${3} +snippet thr + throw +snippet ths + throws snippet try try { ${3} @@ -90,45 +127,62 @@ snippet tryf } catch(${1:Exception} ${2:e}) { } finally { } -snippet rst - ResultSet ${1:rst}${2: = null}${3};${4} -snippet @au - @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")` -snippet mm - @ManyToMany - ${1} -snippet mo - @ManyToOne - ${1} -snippet om - OneToMany${1:(cascade=CascadeType.ALL)} - ${2} -snippet oo - @OneToOne - ${1} -snippet action - public static void ${1:index}(${2:args}) { ${3} } -snippet before - @Before - static void ${1:intercept}(${2:args}) { ${3} } -snippet debug - Logger.debug(${1:param});${2} -snippet error - Logger.error(${1:param});${2} +## +## Find Methods snippet findall List<${1:listName}> ${2:items} = ${1}.findAll();${3} snippet findbyid ${1:var} ${2:item} = ${1}.findById(${3});${4} +## +## Javadocs +snippet /** + /** + * ${1} + */ +snippet @au + @author `system("grep \`id -un\` /etc/passwd | cut -d \":\" -f5")` +snippet @br + @brief ${1:Description} +snippet @fi + @file ${1:`Filename()`}.java +snippet @pa + @param ${1:param} +snippet @re + @return ${1:param} +## +## Logger Methods +snippet debug + Logger.debug(${1:param});${2} +snippet error + Logger.error(${1:param});${2} snippet info Logger.info(${1:param});${2} -snippet rnf - notFound(${1:param});${2} -snippet rnfin - notFoundIfNull(${1:param});${2} -snippet rr - redirect(${1:param});${2} -snippet ru - unauthorized(${1:param});${2} +snippet warn + Logger.warn(${1:param});${2} +## +## Loops +snippet enfor + for (${1} : ${2}) ${3} +snippet for + for (${1}; ${2}; ${3}) ${4} +snippet wh + while (${1}) ${2} +## +## Main method +snippet main + public static void main (String[] args) { + ${1:/* code */} + } +## +## Print Methods +snippet print + System.out.print("${1:Message"); +snippet printf + System.out.printf("${1:Message", ${2:args}); +snippet println + System.out.println(${1}); +## +## Render Methods snippet ren render(${1:param});${2} snippet rena @@ -139,27 +193,48 @@ snippet renj renderJSON(${1:param});${2} snippet renx renderXml(${1:param});${2} -snippet unless - (unless=${1:param});${2} -snippet warn - Logger.warn(${1:param});${2} -snippet sysout - System.out.println(${1}); -snippet syserr - System.err.println(${1}); -snippet /* - /* - * ${1} - */ -snippet /** - /** - * ${1} - */ -snippet prop - $1 void set$3($2 $4){ +## +## Setter and Getter Methods +snippet set + ${1:public} void set${3:}(${2:String} ${4:}){ this.$4 = $4; } - +snippet get ${1:public} ${2:String} get${3:}(){ return this.${4:}; } +## +## Terminate Methods or Loops +snippet re + return +snippet br + break; +## +## Test Methods +snippet t + public void test${1:Name}() throws Exception { + ${2} + } +snippet test + @Test + public void test${1:Name}() throws Exception { + ${2} + } +## +## Utils +snippet Sc + Scanner +## +## Miscellaneous +snippet action + public static void ${1:index}(${2:args}) { ${3} } +snippet rnf + notFound(${1:param});${2} +snippet rnfin + notFoundIfNull(${1:param});${2} +snippet rr + redirect(${1:param});${2} +snippet ru + unauthorized(${1:param});${2} +snippet unless + (unless=${1:param});${2} diff --git a/snippets/javascript-jquery.snippets b/snippets/javascript-jquery.snippets new file mode 100644 index 0000000..ce247a0 --- /dev/null +++ b/snippets/javascript-jquery.snippets @@ -0,0 +1,589 @@ +snippet add + ${1:obj}.add('${2:selector expression}')${3} +snippet addClass + ${1:obj}.addClass('${2:class name}')${3} +snippet after + ${1:obj}.after('${2:Some text and bold!}')${3} +snippet ajax + $.ajax({ + url: '${1:mydomain.com/url}', + type: '${2:POST}', + dataType: '${3:xml/html/script/json}', + data: $.param( $('${4:Element or Expression}') ), + complete: function (jqXHR, textStatus) { + ${5:// callback} + }, + success: function (data, textStatus, jqXHR) { + ${6:// success callback} + }, + error: function (jqXHR, textStatus, errorThrown) { + ${7:// error callback} + } + }); +snippet ajaxcomplete + ${1:obj}.ajaxComplete(function (${1:e}, xhr, settings) { + ${2:// callback} + }); +snippet ajaxerror + ${1:obj}.ajaxError(function (${1:e}, xhr, settings, thrownError) { + ${2:// error callback} + }); + ${3} +snippet ajaxget + $.get('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); +snippet ajaxpost + $.post('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); +snippet ajaxprefilter + $.ajaxPrefilter(function (${1:options}, ${2:originalOptions}, jqXHR) { + ${3: // Modify options, control originalOptions, store jqXHR, etc} + }); +snippet ajaxsend + ${1:obj}.ajaxSend(function (${1:request, settings}) { + ${2:// error callback} + }); + ${3} +snippet ajaxsetup + $.ajaxSetup({ + url: "${1:mydomain.com/url}", + type: "${2:POST}", + dataType: "${3:xml/html/script/json}", + data: $.param( $("${4:Element or Expression}") ), + complete: function (jqXHR, textStatus) { + ${5:// callback} + }, + success: function (data, textStatus, jqXHR) { + ${6:// success callback} + }, + error: function (jqXHR, textStatus, errorThrown) { + ${7:// error callback} + } + }); +snippet ajaxstart + $.ajaxStart(function () { + ${1:// handler for when an AJAX call is started and no other AJAX calls are in progress}; + }); + ${2} +snippet ajaxstop + $.ajaxStop(function () { + ${1:// handler for when all AJAX calls have been completed}; + }); + ${2} +snippet ajaxsuccess + $.ajaxSuccess(function (${1:e}, xhr, settings) { + ${2:// handler for when any AJAX call is successfully completed}; + }); + ${2} +snippet andself + ${1:obj}.andSelf()${2} +snippet animate + ${1:obj}.animate({${2:param1: value1, param2: value2}}, ${3:speed})${4} +snippet append + ${1:obj}.append('${2:Some text and bold!}')${3} +snippet appendTo + ${1:obj}.appendTo('${2:selector expression}')${3} +snippet attr + ${1:obj}.attr('${2:attribute}', '${3:value}')${4} +snippet attrm + ${1:obj}.attr({'${2:attr1}': '${3:value1}', '${4:attr2}': '${5:value2}'})${6} +snippet before + ${1:obj}.before('${2:Some text and bold!}')${3} +snippet bind + ${1:obj}.bind('${2:event name}', function (${3:e}) { + ${4:// event handler} + }); +snippet blur + ${1:obj}.blur(function (${2:e}) { + ${3:// event handler} + }); +snippet C + $.Callbacks()${1} +snippet Cadd + ${1:callbacks}.add(${2:callbacks})${3} +snippet Cdis + ${1:callbacks}.disable()${2} +snippet Cempty + ${1:callbacks}.empty()${2} +snippet Cfire + ${1:callbacks}.fire(${2:args})${3} +snippet Cfired + ${1:callbacks}.fired()${2} +snippet Cfirew + ${1:callbacks}.fireWith(${2:this}, ${3:args})${4} +snippet Chas + ${1:callbacks}.has(${2:callback})${3} +snippet Clock + ${1:callbacks}.lock()${2} +snippet Clocked + ${1:callbacks}.locked()${2} +snippet Crem + ${1:callbacks}.remove(${2:callbacks})${3} +snippet change + ${1:obj}.change(function (${2:e}) { + ${3:// event handler} + }); +snippet children + ${1:obj}.children('${2:selector expression}')${3} +snippet clearq + ${1:obj}.clearQueue(${2:'queue name'})${3} +snippet click + ${1:obj}.click(function (${2:e}) { + ${3:// event handler} + }); +snippet clone + ${1:obj}.clone()${2} +snippet contains + $.contains(${1:container}, ${2:contents}); +snippet css + ${1:obj}.css('${2:attribute}', '${3:value}')${4} +snippet csshooks + $.cssHooks['${1:CSS prop}'] = { + get: function (elem, computed, extra) { + ${2: // handle getting the CSS property} + }, + set: function (elem, value) { + ${3: // handle setting the CSS value} + } + }; +snippet cssm + ${1:obj}.css({${2:attribute1}: '${3:value1}', ${4:attribute2}: '${5:value2}'})${6} +snippet D + $.Deferred()${1} +snippet Dalways + ${1:deferred}.always(${2:callbacks})${3} +snippet Ddone + ${1:deferred}.done(${2:callbacks})${3} +snippet Dfail + ${1:deferred}.fail(${2:callbacks})${3} +snippet Disrej + ${1:deferred}.isRejected()${2} +snippet Disres + ${1:deferred}.isResolved()${2} +snippet Dnotify + ${1:deferred}.notify(${2:args})${3} +snippet Dnotifyw + ${1:deferred}.notifyWith(${2:this}, ${3:args})${4} +snippet Dpipe + ${1:deferred}.then(${2:doneFilter}, ${3:failFilter}, ${4:progressFilter})${5} +snippet Dprog + ${1:deferred}.progress(${2:callbacks})${3} +snippet Dprom + ${1:deferred}.promise(${2:target})${3} +snippet Drej + ${1:deferred}.reject(${2:args})${3} +snippet Drejw + ${1:deferred}.rejectWith(${2:this}, ${3:args})${4} +snippet Dres + ${1:deferred}.resolve(${2:args})${3} +snippet Dresw + ${1:deferred}.resolveWith(${2:this}, ${3:args})${4} +snippet Dstate + ${1:deferred}.state()${2} +snippet Dthen + ${1:deferred}.then(${2:doneCallbacks}, ${3:failCallbacks}, ${4:progressCallbacks})${5} +snippet Dwhen + $.when(${1:deferreds})${2} +snippet data + ${1:obj}.data(${2:obj})${3} +snippet dataa + $.data('${1:selector expression}', '${2:key}'${3:, 'value'})${4} +snippet dblclick + ${1:obj}.dblclick(function (${2:e}) { + ${3:// event handler} + }); +snippet delay + ${1:obj}.delay('${2:slow/400/fast}'${3:, 'queue name'})${4} +snippet dele + ${1:obj}.delegate('${2:selector expression}', '${3:event name}', function (${4:e}) { + ${5:// event handler} + }); +snippet deq + ${1:obj}.dequeue(${2:'queue name'})${3} +snippet deqq + $.dequeue('${1:selector expression}'${2:, 'queue name'})${3} +snippet detach + ${1:obj}.detach('${2:selector expression}')${3} +snippet die + ${1:obj}.die(${2:event}, ${3:handler})${4} +snippet each + ${1:obj}.each(function (index) { + ${2:this.innerHTML = this + " is the element, " + index + " is the position";} + }); +snippet el + $('<${1}/>'${2:, {}})${3} +snippet eltrim + $.trim('${1:string}')${2} +snippet empty + ${1:obj}.empty()${2} +snippet end + ${1:obj}.end()${2} +snippet eq + ${1:obj}.eq(${2:element index})${3} +snippet error + ${1:obj}.error(function (${2:e}) { + ${3:// event handler} + }); +snippet eventsmap + { + :f${1} + } +snippet extend + $.extend(${1:true, }${2:target}, ${3:obj})${4} +snippet fadein + ${1:obj}.fadeIn('${2:slow/400/fast}')${3} +snippet fadeinc + ${1:obj}.fadeIn('slow/400/fast', function () { + ${2:// callback}; + }); +snippet fadeout + ${1:obj}.fadeOut('${2:slow/400/fast}')${3} +snippet fadeoutc + ${1:obj}.fadeOut('slow/400/fast', function () { + ${2:// callback}; + }); +snippet fadeto + ${1:obj}.fadeTo('${2:slow/400/fast}', ${3:0.5})${4} +snippet fadetoc + ${1:obj}.fadeTo('slow/400/fast', ${2:0.5}, function () { + ${3:// callback}; + }); +snippet filter + ${1:obj}.filter('${2:selector expression}')${3} +snippet filtert + ${1:obj}.filter(function (${2:index}) { + ${3:// test code} + })${4} +snippet find + ${1:obj}.find('${2:selector expression}')${3} +snippet focus + ${1:obj}.focus(function (${2:e}) { + ${3:// event handler} + }); +snippet focusin + ${1:obj}.focusIn(function (${2:e}) { + ${3:// event handler} + }); +snippet focusout + ${1:obj}.focusOut(function (${2:e}) { + ${3:// event handler} + }); +snippet get + ${1:obj}.get(${2:element index})${3} +snippet getjson + $.getJSON('${1:mydomain.com/url}', + ${2:{ param1: value1 },} + function (data, textStatus, jqXHR) { + ${3:// success callback} + } + ); +snippet getscript + $.getScript('${1:mydomain.com/url}', function (script, textStatus, jqXHR) { + ${2:// callback} + }); +snippet grep + $.grep(${1:array}, function (item, index) { + ${2:// test code} + }${3:, true}); +snippet hasc + ${1:obj}.hasClass('${2:className}')${3} +snippet hasd + $.hasData('${1:selector expression}'); +snippet height + ${1:obj}.height(${2:integer})${3} +snippet hide + ${1:obj}.hide('${2:slow/400/fast}')${3} +snippet hidec + ${1:obj}.hide('${2:slow/400/fast}', function () { + ${3:// callback} + }); +snippet hover + ${1:obj}.hover(function (${2:e}) { + ${3:// event handler} + }, function ($2) { + ${4:// event handler} + });${5} +snippet html + ${1:obj}.html('${2:Some text and bold!}')${3} +snippet inarr + $.inArray(${1:value}, ${2:array}); +snippet insa + ${1:obj}.insertAfter('${2:selector expression}')${3} +snippet insb + ${1:obj}.insertBefore('${2:selector expression}')${3} +snippet is + ${1:obj}.is('${2:selector expression}')${3} +snippet isarr + $.isArray(${1:obj})${2} +snippet isempty + $.isEmptyObject(${1:obj})${2} +snippet isfunc + $.isFunction(${1:obj})${2} +snippet isnum + $.isNumeric(${1:value})${2} +snippet isobj + $.isPlainObject(${1:obj})${2} +snippet iswin + $.isWindow(${1:obj})${2} +snippet isxml + $.isXMLDoc(${1:node})${2} +snippet jj + $('${1:selector}')${2} +snippet kdown + ${1:obj}.keydown(function (${2:e}) { + ${3:// event handler} + }); +snippet kpress + ${1:obj}.keypress(function (${2:e}) { + ${3:// event handler} + }); +snippet kup + ${1:obj}.keyup(function (${2:e}) { + ${3:// event handler} + }); +snippet last + ${1:obj}.last('${1:selector expression}')${3} +snippet live + ${1:obj}.live('${2:events}', function (${3:e}) { + ${4:// event handler} + }); +snippet load + ${1:obj}.load(function (${2:e}) { + ${3:// event handler} + }); +snippet loadf + ${1:obj}.load('${2:mydomain.com/url}', + ${2:{ param1: value1 },} + function (responseText, textStatus, xhr) { + ${3:// success callback} + } + }); +snippet makearray + $.makeArray(${1:obj}); +snippet map + ${1:obj}.map(function (${2:index}, ${3:element}) { + ${4:// callback} + }); +snippet mapp + $.map(${1:arrayOrObject}, function (${2:value}, ${3:indexOrKey}) { + ${4:// callback} + }); +snippet merge + $.merge(${1:target}, ${2:original}); +snippet mdown + ${1:obj}.mousedown(function (${2:e}) { + ${3:// event handler} + }); +snippet menter + ${1:obj}.mouseenter(function (${2:e}) { + ${3:// event handler} + }); +snippet mleave + ${1:obj}.mouseleave(function (${2:e}) { + ${3:// event handler} + }); +snippet mmove + ${1:obj}.mousemove(function (${2:e}) { + ${3:// event handler} + }); +snippet mout + ${1:obj}.mouseout(function (${2:e}) { + ${3:// event handler} + }); +snippet mover + ${1:obj}.mouseover(function (${2:e}) { + ${3:// event handler} + }); +snippet mup + ${1:obj}.mouseup(function (${2:e}) { + ${3:// event handler} + }); +snippet next + ${1:obj}.next('${2:selector expression}')${3} +snippet nexta + ${1:obj}.nextAll('${2:selector expression}')${3} +snippet nextu + ${1:obj}.nextUntil('${2:selector expression}'${3:, 'filter expression'})${4} +snippet not + ${1:obj}.not('${2:selector expression}')${3} +snippet off + ${1:obj}.off('${2:events}', '${3:selector expression}'${4:, handler})${5} +snippet offset + ${1:obj}.offset()${2} +snippet offsetp + ${1:obj}.offsetParent()${2} +snippet on + ${1:obj}.on('${2:events}', '${3:selector expression}', function (${4:e}) { + ${5:// event handler} + }); +snippet one + ${1:obj}.one('${2:event name}', function (${3:e}) { + ${4:// event handler} + }); +snippet outerh + ${1:obj}.outerHeight()${2} +snippet outerw + ${1:obj}.outerWidth()${2} +snippet param + $.param(${1:obj})${2} +snippet parent + ${1:obj}.parent('${2:selector expression}')${3} +snippet parents + ${1:obj}.parents('${2:selector expression}')${3} +snippet parentsu + ${1:obj}.parentsUntil('${2:selector expression}'${3:, 'filter expression'})${4} +snippet parsejson + $.parseJSON(${1:data})${2} +snippet parsexml + $.parseXML(${1:data})${2} +snippet pos + ${1:obj}.position()${2} +snippet prepend + ${1:obj}.prepend('${2:Some text and bold!}')${3} +snippet prependto + ${1:obj}.prependTo('${2:selector expression}')${3} +snippet prev + ${1:obj}.prev('${2:selector expression}')${3} +snippet preva + ${1:obj}.prevAll('${2:selector expression}')${3} +snippet prevu + ${1:obj}.prevUntil('${2:selector expression}'${3:, 'filter expression'})${4} +snippet promise + ${1:obj}.promise(${2:'fx'}, ${3:target})${4} +snippet prop + ${1:obj}.prop('${2:property name}')${3} +snippet proxy + $.proxy(${1:function}, ${2:this})${3} +snippet pushstack + ${1:obj}.pushStack(${2:elements})${3} +snippet queue + ${1:obj}.queue(${2:name}${3:, newQueue})${4} +snippet queuee + $.queue(${1:element}${2:, name}${3:, newQueue})${4} +snippet ready + $(function () { + ${1} + }); +snippet rem + ${1:obj}.remove()${2} +snippet rema + ${1:obj}.removeAttr('${2:attribute name}')${3} +snippet remc + ${1:obj}.removeClass('${2:class name}')${3} +snippet remd + ${1:obj}.removeData('${2:key name}')${3} +snippet remdd + $.removeData(${1:element}${2:, 'key name}')${3} +snippet remp + ${1:obj}.removeProp('${2:property name}')${3} +snippet repa + ${1:obj}.replaceAll(${2:target})${3} +snippet repw + ${1:obj}.replaceWith(${2:content})${3} +snippet reset + ${1:obj}.reset(function (${2:e}) { + ${3:// event handler} + }); +snippet resize + ${1:obj}.resize(function (${2:e}) { + ${3:// event handler} + }); +snippet scroll + ${1:obj}.scroll(function (${2:e}) { + ${3:// event handler} + }); +snippet scrolll + ${1:obj}.scrollLeft(${2:value})${3} +snippet scrollt + ${1:obj}.scrollTop(${2:value})${3} +snippet sdown + ${1:obj}.slideDown('${2:slow/400/fast}')${3} +snippet sdownc + ${1:obj}.slideDown('${2:slow/400/fast}', function () { + ${3:// callback}; + }); +snippet select + ${1:obj}.select(function (${2:e}) { + ${3:// event handler} + }); +snippet serialize + ${1:obj}.serialize()${2} +snippet serializea + ${1:obj}.serializeArray()${2} +snippet show + ${1:obj}.show('${2:slow/400/fast}')${3} +snippet showc + ${1:obj}.show('${2:slow/400/fast}', function () { + ${3:// callback} + }); +snippet sib + ${1:obj}.siblings('${2:selector expression}')${3} +snippet size + ${1:obj}.size()${2} +snippet slice + ${1:obj}.slice(${2:start}${3:, end})${4} +snippet stoggle + ${1:obj}.slideToggle('${2:slow/400/fast}')${3} +snippet stop + ${1:obj}.stop('${2:queue}', ${3:false}, ${4:false})${5} +snippet submit + ${1:obj}.submit(function (${2:e}) { + ${3:// event handler} + }); +snippet sup + ${1:obj}.slideUp('${2:slow/400/fast}')${3} +snippet supc + ${1:obj}.slideUp('${2:slow/400/fast}', function () { + ${3:// callback}; + }); +snippet text + ${1:obj}.text(${2:'some text'})${3} +snippet this + $(this)${1} +snippet toarr + ${1:obj}.toArray() +snippet tog + ${1:obj}.toggle(function (${2:e}) { + ${3:// event handler} + }, function ($2) { + ${4:// event handler} + }); + ${4} +snippet togclass + ${1:obj}.toggleClass('${2:class name}')${3} +snippet togsh + ${1:obj}.toggle('${2:slow/400/fast}')${3} +snippet trig + ${1:obj}.trigger('${2:event name}')${3} +snippet trigh + ${1:obj}.triggerHandler('${2:event name}')${3} +snippet $trim + $.trim(${1:str})${2} +snippet $type + $.type(${1:obj})${2} +snippet unbind + ${1:obj}.unbind('${2:event name}')${3} +snippet undele + ${1:obj}.undelegate(${2:selector expression}, ${3:event}, ${4:handler})${5} +snippet uniq + $.unique(${1:array})${2} +snippet unload + ${1:obj}.unload(function (${2:e}) { + ${3:// event handler} + }); +snippet unwrap + ${1:obj}.unwrap()${2} +snippet val + ${1:obj}.val('${2:text}')${3} +snippet width + ${1:obj}.width(${2:integer})${3} +snippet wrap + ${1:obj}.wrap('${2:<div class="extra-wrapper"></div>}')${3} diff --git a/snippets/markdown.snippets b/snippets/markdown.snippets index b69e135..e4efd3c 100644 --- a/snippets/markdown.snippets +++ b/snippets/markdown.snippets @@ -1,5 +1,7 @@ # Markdown +# Includes octopress (http://octopress.org/) snippets + snippet [ [${1:text}](http://${2:address} "${3:title}") snippet [* @@ -28,3 +30,58 @@ snippet --- `repeat('-', strlen(getline(line(".") - 1)))` ${1} + +snippet blockquote + {% blockquote %} + ${1:quote} + {% endblockquote %} + +snippet blockquote-author + {% blockquote ${1:author}, ${2:title} %} + ${3:quote} + {% endblockquote %} + +snippet blockquote-link + {% blockquote ${1:author} ${2:URL} ${3:link_text} %} + ${4:quote} + {% endblockquote %} + +snippet bt-codeblock-short + ``` + ${1:code_snippet} + ``` + +snippet bt-codeblock-full + ``` ${1:language} ${2:title} ${3:URL} ${4:link_text} + ${5:code_snippet} + ``` + +snippet codeblock-short + {% codeblock %} + ${1:code_snippet} + {% endcodeblock %} + +snippet codeblock-full + {% codeblock ${1:title} lang:${2:language} ${3:URL} ${4:link_text} %} + ${5:code_snippet} + {% endcodeblock %} + +snippet gist-full + {% gist ${1:gist_id} ${2:filename} %} + +snippet gist-short + {% gist ${1:gist_id} %} + +snippet img + {% img ${1:class} ${2:URL} ${3:width} ${4:height} ${5:title_text} ${6:alt_text} %} + +snippet youtube + {% youtube ${1:video_id} %} + +# The quote should appear only once in the text. It is inherently part of it. +# See http://octopress.org/docs/plugins/pullquote/ for more info. + +snippet pullquote + {% pullquote %} + ${1:text} {" ${2:quote} "} ${3:text} + {% endpullquote %} diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 79462fc..6416180 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -104,7 +104,8 @@ snippet packagev512 snippet moose use Moose; use namespace::autoclean; - ${1:#}extends '${2:ParentClass}'; + ${1:#}BEGIN {extends '${2:ParentClass}'}; + ${3} # moose extends snippet extends diff --git a/snippets/processing.snippets b/snippets/processing.snippets new file mode 100755 index 0000000..b0aa93c --- /dev/null +++ b/snippets/processing.snippets @@ -0,0 +1,784 @@ +#BASICS +# doc +snippet doc + /** + * ${1:Description} + * + * @author ${2:name} + * @since ${3:`strftime("%d/%m/%y %H:%M:%S")`} + */ + ${4} +# doc comment +snippet docc + /** + * ${1:@private}$0 + */ + ${2} +# class +snippet class + ${1:public }class ${2:`fnamemodify(bufname("%"),":t:r")`} ${3:extends} + { + + //-------------------------------------- + // CONSTRUCTOR + //-------------------------------------- + + public $2 (${4:arguments}) { + ${0:// expression} + } + } +# package +snippet package + /** + * ${1:Description} + * + * @author ${2:$TM_FULLNAME} + * @since ${3:`strftime("%d/%m/%y %H:%M:%S")`} + */ + + package ${4:package}; +# function +snippet fun + ${1:void/private/protected/public}${2: static} ${3:name}(${4}) { + ${5://if not void return null;} + } + ${6} +snippet fn + ${1:void }${2:name}(${3}) { + ${4://if not void return null;} + } + ${5} +# constant +snippet const + static final ${1:Object} ${2:VAR_NAM} = ${3}; +# var +snippet var + ${1:private/public }${2:static }${3:String} ${4:str}${5: =}${6:value}; +# var objects +snippet obj + ${1:private/public }${2:Object} ${3:o}${4: = new }$2(${5}); +#loop for +snippet for + for (int ${2:i} = 0; $2 < ${1:Things}.length; $2${3:++}) { + ${4:$1[$2]} + }; +#loop while +snippet while + while (${1:/* condition */}) { + ${2:/* code */} + } +#break +snippet break + break ${1:label}; +#case +snippet case + case ${1:expression} : + ${2} + break; +#default +snippet default + default : + ${1} + break; +#switch +snippet switch + switch(${1:expression}) { + case '${3:case}': + ${4:// code} + break; + ${5} + default: + ${2:// code} + } +#try +snippet try + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } +#try catch finally +snippet tryf + try { + ${3} + } catch(${1:Exception} ${2:e}) { + } finally { + } +#throw +snippet throw + throw new ("${1:Exception()}"); +#ternary +snippet ? + ? ${1:trueExpression} : ${2:falseExpression} + ${3} +snippet if + if (${1:true}) {${2}} +# if ... else +snippet ife + if (${1:true}) {${2}} + else{${3}} +#get +snippet get + public ${1:String} get${2}() { + return ${2:fieldName}; + } +#set +snippet set + public void set${1}(${2:String} new${1}) { + ${1:fieldName} = new${1}; + } +#printIn +snippet println + println("${1:`fnamemodify(bufname("%"),":t:r")`}::${2:method}() "${3: +} ${4}); +#println string +snippet pr + println("${1}"); +#setup draw +snippet setup + void setup(){ + ${1} + } + + void draw(){ + ${2} + } +#setup OPENGL +snippet opengl + import processing.opengl.*; + import javax.media.opengl.*; + + PGraphicsOpenGL pgl; + GL gl; + + void setup(){ + size( ${1:300}, ${2:300}, OPENGL ); + colorMode( RGB, 1.0 ); + hint( ENABLE_OPENGL_4X_SMOOTH ); + pgl = (PGraphicsOpenGL) g; + gl = pgl.gl; + gl.setSwapInterval(1); + initGL(); + ${3} + } + + void draw(){ + pgl.beginGL(); + ${4} + pgl.endGL(); + getOpenGLErrors(); + } + + void initGL(){ + ${5} + } + + void getOpenGLErrors(){ + int error = gl.glGetError(); + switch (error){ + case 1280 : + println("GL_INVALID_ENUM - An invalid enumerant was passed to an OpenGL command."); + break; + case 1282 : + println("GL_INVALID_OPERATION - An OpenGL command was issued that was invalid or inappropriate for the current state."); + break; + case 1281 : + println("GL_INVALID_VALUE - A value was passed to OpenGL that was outside the allowed range."); + break; + case 1285 : + println("GL_OUT_OF_MEMORY - OpenGL was unable to allocate enough memory to process a command."); + break; + case 1283 : + println("GL_STACK_OVERFLOW - A command caused an OpenGL stack to overflow."); + break; + case 1284 : + println("GL_STACK_UNDERFLOW - A command caused an OpenGL stack to underflow."); + break; + case 32817 : + println("GL_TABLE_TOO_LARGE"); + break; + } + } + +#GL Functions +snippet gl begin gl + pgl.beginGL(); + ${1} + pgl.endGL(); +snippet gl gl swap interval + // specify the minimum swap interval for buffer swaps. + gl.setSwapInterval(${1:interval}); +snippet gl gl call list + // execute a display list + gl.glCallList(${1:list}); +snippet gl gl gen buffers + // import java.nio.IntBuffer; + // import java.nio.FloatBuffer; + // import com.sun.opengl.util.BufferUtil; + + // You might need to create four buffers to store vertext data, normal data, texture coordinate data, and indices in vertex arrays + IntBuffer bufferObjects = IntBuffer.allocate(${1:4}); + gl.glGenBuffers($1, bufferObjects); + + int vertexCount = ${2:3}; + int numCoordinates = ${3:3}; + // vertexCount * numCoordinates + FloatBuffer vertices = BufferUtil.newFloatBuffer(vertexCount * numCoordinates); + float[] v = {0.0f, 0.0f, 0.0f, + 1.0f, 0.0f, 0.0f, + 0.0f, 1.0f, 1.0f}; + vertices.put(v); + + // Bind the first buffer object ID for use with vertext array data + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, bufferObjects.get(0)); + gl.glBufferData(GL.GL_ARRAY_BUFFER, vertexCount * numCoordinates * BufferUtil.SIZEOF_FLOAT, vertices, GL.GL_STATIC_DRAW); +snippet gl gl bind buffer + ${2:// A buffer ID of zero unbinds a buffer object} + gl.glBindBuffer(GL.GL_ARRAY_BUFFER, ${1:0}); +snippet gl gl delete buffers + ${3:// Parameters are the same for glGenBuffers} + gl.glDeleteBuffers(${1:4}, ${2:bufferObjects}); +snippet gl gl depth mask + // enable or disable writing into the depth buffer + gl.glDepthMask(${1:flag}); +snippet gl gl load identity + // replaces the top of the active matrix stack with the identity matrix + gl.glLoadIdentity(); +snippet gl gl tex coord 2f + // set the current texture coordinates - 2 floats + gl.glTexCoord2f(${1:0.0f}, ${2:0.0f}); +snippet gl gl vertex 2f + gl.glVertex2f(${1:0.0f}, ${2:0.0f}); +snippet gl gl vertex 3f + gl.glVertex3f(${1:0.0f}, ${2:0.0f}, ${3:0.0f}); +snippet gl gl translate f + // multiply the current matrix by a translation matrix + gl.glTranslatef(${1:x}, ${2:y}, ${3:z}); +snippet gl gl rotate f + // rotate, x-axis, y-axis, z-axiz + gl.glRotatef(${1:angle}, ${2:x}, ${3:y}, ${4:z}); +snippet gl gl scale f + // multiply the current matrix by a general scaling matrix + gl.glScalef(${1:x}, ${2:y}, ${3:z}); +snippet gl gl color 4f + gl.glColor4f(${1:red}, ${2:green}, ${3:blue}, ${4:alpha}); +snippet gl gl clear color + gl.glClearColor(${1:red}, ${2:green}, ${3:blue}, ${4:alpha}); +snippet gl gl color 3f + gl.glColor3f(${1:red}, ${2:green}, ${3:blue}); +snippet gl gl push matrix + // spush and pop the current matrix stack + gl.glPushMatrix(); + ${1} + gl.glPopMatrix(); +snippet gl gl gen lists + gl.glGenLists(${1:1}) +snippet gl gl flush + // Empties buffers. Call this when all previous issues commands completed + gl.glFlush(); + ${1} +snippet gl gl get error + println(gl.glGetError()); +snippet gl gl clear + gl.glClear(${1:GL.GL_COLOR_BUFFER_BIT}${2: | }${3:GL.GL_DEPTH_BUFFER_BIT}); + +#frame operations +snippet fr framerate + frameRate(${1:30}); + ${2} +snippet fr frameRate + frameRate +snippet fr frameCount + frameCount +snippet fr saveFrame + saveFrame("${1:filename-####}${2:.ext}"); + +#size +snippet size normal size + size(${1:200}, ${2:200}${3:, P3D}); +snippet size opengl size + size(${1:200}, ${2:200}${3:, OPENGL}); + +#PRIMITIVES +#color +snippet color + color ${1:c}${2: = color(}${3:value1, }${4:value2, }${5:value3)}; +#char +snippet char + char ${1:m}${2: = "}${3:char"}; +#float +snippet float + float ${1:f}${2: = }${3:0.0f}; +#int +snippet int + int ${1:f}${2: = }${3:0}; +#boolean +snippet boolean + boolean ${1:b}${2: = }${3:true}; +#byte +snippet byte + byte ${1:b}${2: = }${3:127}; +#string +snippet string + String ${1:str}${2: = "}${3:CCCP"}; +#array +snippet array + ${1:int}[] ${2:numbers}${3: = new $1}[${4:length}]; +#object +snippet object + ${1:Object} ${2:o}${3: = new $1}(${4}); + +#curve +snippet curve curve + curve(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}, ${7:x4}, ${8:y4}); +snippet curve curve 3D + curve(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}, ${7:x3}, ${8:y3}, ${9:z3}, ${10:x4}, ${11:y4}, ${12:z4}); +snippet curve curve Detail + curveDetail(${1:detail}); +snippet curve curve point + curvePoint(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); +snippet curve curve tightness + curveTightness(${1:squishy}); + +#bezier +snippet bezier bezier + bezier(${1:x1}, ${2:y1}, ${3:cx1}, ${4:cy1}, ${5:cx2}, ${6:cy2}, ${7:x2}, ${8:y2}); +snippet bezier bezier 3D + bezier(${1:x1}, ${2:y1}, ${3:z1}, ${4:cx1}, ${5:cy1}, ${6:cz1}, ${7:cx2}, ${8:cy2}, ${9:cz2}, ${10:x2}, ${11:y2}, ${12:z2}); +snippet bezier bezier detail + bezierDetail(${1:detail}); +snippet bezier bezier tangent + bezierTangent(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); +snippet bezier bezier point + bezierPoint(${1:a}, ${2:b}, ${3:c}, ${4:d}, ${5:t}); + +#vertex +snippet vertex vertex + vertex(${1:x}, ${2:y}${3:, }${4:u}${5:, }${6:v}); +snippet vertex vertex 3D + vertex(${1:x}, ${2:y}, ${3:z}${4:, }${5:u}${6:, }${7:v}); +snippet vertex vertex bezier + bezierVertex(${1:cx1}, ${2:cy1}, ${3:cx2}, ${4:cy2}, ${5:x}, ${6:y}); +snippet vertex vertex bezier 3D + bezierVertex(${1:cx1}, ${2:cy1}, ${3:cz1}, ${4:cx2}, ${5:cy2}, ${6:cz2}, ${7:x}, ${8:y}, ${9:z}); +snippet vertex vertex curve + curveVertex(${1:x}, ${2:y}); +snippet vertex vertex curve 3D + curveVertex(${1:x}, ${2:y}, ${3:z}); + +#stroke +snippet stroke stroke + stroke(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet stroke stroke weight + strokeWeight(${1:1}); +snippet stroke no stroke + noStroke(); + +#mouse +snippet mouse mouse x + mouseX +snippet mouse mouse y + mouseY +snippet mouse mouse drag + void mouseDragged(){ + ${1} + } +snippet mouse mouse move + void mouseMoved(){ + ${1} + } +snippet mouse mouse release + void mouseReleased(){ + ${1} + } +snippet mouse mouse pressed + void mousePressed(){ + ${1} + } +snippet mouse mouse pressed? + mousePressed +snippet mouse mouse button? + mouseButton +snippet mouse pmouse X + pmouseX +snippet mouse pmouse Y + pmouseY + +#key +snippet key keycode? + keyCode +snippet key key + key +snippet key key released + void keyReleased(){ + ${1} + } +snippet key key typed + void keyTyped(){ + ${1} + } +snippet key key pressed + void keyPressed(){ + ${1} + } +snippet key key pressed? + keyPressed + +#file +snippet file load string + loadStrings("${1:filename}"); +snippet file save string + saveStrings(${1:filename}, ${2:strings}); +snippet file load bytes + loadBytes("${1:filename}"); +snippet file begin record + beginRecord(${1:renderer}, ${2:filename}); +snippet file end record + endRecord(); +snippet file save bytes + saveBytes(${1:filename}, ${2:bytes}); +snippet file create writer + createWriter(${1:filename}); +snippet file create reader + createReader(${1:filename}); + +#time +snippet time hour + hour() +snippet time milliseconds + millis() +snippet time year + year() +snippet time minutes + minutes() +snippet time month + month() +snippet time second + second() + +#matrix +snippet matrix reset matrix + translate(${1:x}, ${2:y}, ${3:z}); +snippet matrix print matrix + printMatrix(); +snippet matrix push matrix + pushMatrix(); + ${1:}; + popMatrix(); + + +#text +snippet txt text data + text(${1:data}, ${2:x}, ${3:y}${4:, }${5:z}); +snippet txt text string data + text(${1:stringdata}, ${2:x}, ${3:y}, ${4:width}, ${5:height}${6:, }${7:z}); +snippet txt text size + textSize(${1:size}); +snippet txt text leading + textLeading(${1:size}); +snippet txt text width + textWidth(${1:data}); +snippet txt text descent + textDescent(); +snippet txt text ascent + textAscent(); +snippet txt font + PFont ${1:font}; + $1 = loadFont("${2:FFScala-32.vlw}"); +#load font +snippet txt load font + ${1:font} = loadFont("${2:FFScala-32.vlw}"); +snippet txt text font + textFont(${1:font}${2:, }${3:size}); + +#math +snippet math tangent + tan(${1:rad}); +snippet math atan + atan(${1:rad}); +snippet math atan2 + atan2(${1:rad}); +snippet math sin + sin(${1:rad}); +snippet math asin + asin(${1:rad}); +snippet math cos + cos(${1:rad}); +snippet math acos + acos(${1:rad}); +snippet math degrees + degrees(${1:rad}); +snippet math radians + radians(${1:deg}); +snippet math random seed + randomSeed(${1:value}); +snippet math random + random(${1:value1}${2:, }${3:value2}); +snippet math half PI + HALF_PI +snippet math 2 PI + TWO_PI +snippet math PI + PI +snippet math pow + pow(${1:num}, ${2:exponent}); +snippet math floor + floor(${1:value}); +snippet math sqrt + sqrt(${1:value}); +snippet math abs + abs(${1:value}); +snippet math sq + sq(${1:value}); +snippet math ceil + ceil(${1:value}); +snippet math exp + exp(${1:value}); +snippet math round + round(${1:value}}; +snippet math min + min(${1:value1}, ${2:value2}${3:, }${4:value3}); +snippet math max + max(${1:value1}, ${2:value2}${3:, }${4:value3}); +snippet math array max + max(${1:array}); +snippet math array min + min(${1:array}); +snippet math logarithm + log(${1:value}); +snippet math map + map(${1:value}, ${2:low1}, ${4:high1}, ${5:low2}, ${6:high2}); +snippet math normalize + norm(${1:value}, ${2:low}, ${3:high}); +snippet math constrain + constrain(${1:value}, ${2:min}, ${3:max}); +snippet math magnitude of a vector + mag(${1:a}, ${2:b}${3:, }${4:c}); +snippet math distance + dist(${1:x1}, ${2:y1}, ${4:x2}, ${5:y2}); +snippet math distance 3D + dist(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}); + +#noise math +snippet noise set noise + noise(${1:x}${2:, }${3:y}${4:, }${5:z}); +snippet noise noise detail + noiseDetail(${1:octaves}${2:, }${3:falloff}); +snippet noise noise seed + noiseSeed(${1:x}); + +#material +snippet material shininess + shininess(${1:shine}); +snippet material specular + specular(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet material ambient + ambient(${1:value1}, ${2:value2}, ${3:value3}); +snippet material emissive + emissive(${1:value1}, ${2:value2}, ${3:value3}); + +#light +snippet light no light + noLights(); +snippet light light + lights(); +snippet light diretional light + directionalLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:nx}, ${5:ny}, ${6:nz}); +snippet light point light + pointLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:nx}, ${5:ny}, ${6:nz}); +snippet light falloff light + lightFalloff(${1:constant}, ${2:linear}, ${3:quadratic}); +snippet light normal light + normal(${1:nx}, ${2:ny}, ${3:nz}); +snippet light specular light + lightFalloff(${1:v1}, ${2:v2}, ${3:v3}); +snippet light ambient light + ambientLight(${1:v1}, ${2:v2}, ${3:v3}${7:, ${4:x}, ${5:y}, ${6:z}}); +snippet light spot light + spotLight(${1:v1}, ${2:v2}, ${3:v3}, ${4:x}, ${5:y}, ${6:z}, ${7:nx}, ${8:ny}, ${9:nz}, ${10:angle}, ${11:concentration}); + +#camera +snippet cam camera + camera(${1:eyeX}, ${2:eyeY}, ${3:eyeZ}, ${4:centerX}, ${5:centerY}, ${6:centerZ}, ${7:upX}, ${8:upY}, ${9:upZ}); +snippet cam ortho + ortho(${1:left}, ${2:right}, ${3:bottom}, ${4:top}, ${5:near}, ${6:far}); +snippet cam begin camera + beginCamera(); +snippet cam end camera + endCamera(); +snippet cam print camera + printCamera(); +snippet cam print camera projection + printProjection(); +snippet cam perspective camera + perspective(${1:fov}, ${2:aspect}, ${3:zNear}, ${4:zFar}); +snippet cam frustrum + frustrum(${1:left}, ${2:right}, ${3:bottom}, ${4:top}, ${5:near}, ${6:far}); + +#transformations +snippet trans rotate + rotate${1:X}(${1:angle}); +snippet trans translate + translate(${1:x}, ${2:y}${3:, }${4:z}); +snippet trans scale size + scale(${1:size}); +snippet trans scale + scale(${1:x}, ${2:y}${3:, }${4:z}); + +#coordinates +snippet coord + ${1:model/screen}${2:X}(${3:x}, ${4:y}, ${5:z}); + +#effects +snippet fx brightness + brightness(${1:color}); +snippet fx lerp color + lerpColor(${1:c1}, ${2:c2}, ${3:amt}); +snippet fx saturation + saturation(${1:color}); +snippet fx hue + hue(${1:color}); +snippet fx alpha + alpha(${1:color}); +snippet fx tint + tint(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet fx notint + noTint(); + +#pixel +snippet px set pixel + set(${1:x}, ${2:y}, ${3:color/image}); +snippet px update pixel + updatePixels(); +snippet px load pixel + loadPixels(); +snippet px pixels + pixels[${1:index}] +snippet px get pixel + get(${1:x}, ${2:y}${3:, }${4:width}${5:, }${6:height}); + +#geometric figures +snippet geof triangle + triangle(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}); +snippet geof line + line(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}); +snippet geof line 3D + line(${1:x1}, ${2:y1}, ${3:z1}, ${4:x2}, ${5:y2}, ${6:z2}); +snippet geof arc + arc(${1:x}, ${2:y}, ${3:width}, ${4:height}, ${5:start}, ${6:stop}); +snippet geof point + point(${1:x}, ${2:y}${3:, }${4:z}); +snippet geof quad + quad(${1:x1}, ${2:y1}, ${3:x2}, ${4:y2}, ${5:x3}, ${6:y3}, ${7:x4}, ${8:y4}); +snippet geof ellipse + ellipse(${1:x}, ${2:y}, ${3:width}, ${4:height}); +snippet geof rect + rect(${1:x}, ${2:y}, ${3:width}, ${4:height}); +snippet geof box + box(${1:width}, ${2:height}, ${3:depth}); +snippet geof sphere + sphere(${1:radius}); +snippet geof sphere details + sphereDetail(${1:n}); +snippet geof set smooth + smooth(); +snippet geof set no smooth + noSmooth(); + +#array operations +snippet arrop normal split + split("${1:str}"${2: , }${3:delimiter}); +snippet arrop split Tokens + splitTokens(${1:str}${2:, }${3:tokens}); +snippet arrop join + join(${1:strgArray}${2: , }${3:seperator}); +snippet arrop shorten + shorten(${1:array}); +snippet arrop concat + concat(${1:array1}, ${2:array2}); +snippet arrop subset + subset(${1:array}, ${2:offset}); +snippet arrop append + append(${1:array}, ${2:element}); +snippet arrop reverse + reverse(${1:array}); +snippet arrop splice + splice(${1:array}, ${2:value/array2}, ${3:index}); +snippet arrop sort + sort(${1:dataArray}${2:, }${3:count}); +snippet arrop expand + expand(${1:array}${2:, }${3:newSize}); +snippet arrop array copy + arrayCopy(${1:src}, ${2:dest}, ${3:, }${3:length}); + +#string operations +snippet strop str + str("${1:str}"); +snippet strop match + match(${1:str}, ${2:regexp}); +snippet strop trim + trim(${1:str}); +snippet strop nf + nf(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfs + nfs(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfp + nfp(${2:value}, ${3:left}${4:, }${5:right}); +snippet strop nfc + nfc(${1:value}${2:, }${3:right}); + +#convert +snippet convert unbinary + unbinary("${1:str}"}); +snippet convert hexadecimal + hex(${1:c}); +snippet convert unhex + unhex(${1:c}); +snippet convert binary + binary(${1:value}${2:, }${3:digits}); + +#image operations +snippet image load image + loadImage(${1:filename}); +snippet image image + image(${1:img}, ${2:x}, ${3:y}${4:, }${5:width}${6:, }${7:height}); +snippet copy copy + copy(${1:srcImg}${2:, }${3:x}, ${4:y}, ${5:width}, ${6:height}, ${7:dx}, ${8:dy}, ${9:dwidth}, ${10:dheight}); + + + +#containers +snippet bg + background(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +snippet pg + PGraphics pg; + pg = createGraphics(${1:width}, ${2:height}${3:, }${4:applet}); +snippet pimage + PImage(${1:width}, ${2:height}); + +#UTILS +#nofill +snippet nofill + noFill(); +#fill +snippet fill + fill(${1:value1}, ${2:value2}, ${3:value3}${4:, }${5:alpha}); +#red +snippet red + red(${1:color}); +#green +snippet green + green(${1:color}); +#blue +snippet blue + blue(${1:color}); +#status +snippet status + status(${1:text}); +#param +snippet param + param(${1:s}); +#link +snippet link + link(${1:url}${2:, }${3:target}); +#@param +snippet @ + @${1:param/return/private/public} ${1:parameter} ${2:description} diff --git a/snippets/puppet.snippets b/snippets/puppet.snippets new file mode 100644 index 0000000..f349932 --- /dev/null +++ b/snippets/puppet.snippets @@ -0,0 +1,155 @@ +# Snippets for use with VIM and http://www.vim.org/scripts/script.php?script_id=2540 +# +# Please contact R.I.Pienaar for additions and feedback, +# see it in action @ http://www.devco.net/archives/2009/09/22/vim_and_puppet.php + +# Language Constructs +snippet class + class ${1:`Filename('', 'name')`} { + ${2} + } +snippet node + node "${1:`Filename('', 'fqdn')`}" { + ${2} + } +snippet case + case $${1:variable} { + default: { ${2} } + } +snippet ife + if $${1:variable} { + ${2} + } else { + ${3} + } +snippet if + if $${1:variable} { + ${2} + } +snippet else + else { + ${1} + } +snippet ? + ? { + '${1}' => ${2} + } +# +# blocks etc and general syntax sugar +snippet [ + [ ${1} ]${2} +snippet > + ${1} => ${2} +snippet p: + "puppet://puppet/${1:module name}/${2:file name}" +# +# Functions +snippet alert + alert("${1:message}")${2} +snippet crit + crit("${1:message}")${2} +snippet debug + debug("${1:message}")${2} +snippet defined + defined(${1:Resource}["${2:name}"])${3} +snippet emerg + emerg("${1:message}")${2} +snippet extlookup Simple extlookup + extlookup("${1:variable}")${2} +snippet extlookup Extlookup with defaults + extlookup("${1:variable}", "${2:default}")${3} +snippet extlookup Extlookup with defaults and custom data file + extlookup("${1:variable}", "${2:default}", "${3:data source}")${4} +snippet fail + fail("${1:message}")${2} +snippet info + info("${1:message}")${2} +snippet inline_template + inline_template("<%= ${1} %>")${2} +snippet notice + notice("${1:message}")${2} +snippet realize + realize(${1:Resource}[${2:name}])${3} +snippet regsubst + regsubst(${1:hay stack}, ${2:needle}, "${3:replacement}")${4} +snippet inc + include ${1:classname}${2} +snippet split + split(${1:hay stack}, "${2:patten}")${3} +snippet versioncmp + versioncmp("${1:version}", "${2:version}")${3} +snippet warning + warning("${1:message}")${2} +# +# Types +snippet cron + cron{ "${1:name}": + command => "${2}", + user => "${3:root}", + ${4} => ${5} + } + +snippet exec + exec{ "${1:name}": + command => "${2:$1}", + user => "${3:root}", + ${4} => ${5} + } + +snippet user + user{ "${1:user}": + comment => "${2:$1}", + ensure => present, + managehome => true, + home => "${3:/home/$1}" + } + +snippet group + group{ "${1:group}": + ensure => ${2:present} + } + +snippet host + host{ "${1:hostname}": + ip => ${2:127.0.0.1} + } + +snippet mailalias + mailalias{ "${1:localpart}": + recipient => "${2:recipient}" + } + +snippet mount + mount{ "${1:destination path}": + ensure => ${2:mounted}, + device => "${3:device name or path}" + } + +snippet package + package{ "${1:package name}": + ensure => ${2:present} + } + +snippet yumrepo + yumrepo{ "${1:repo name}": + descr => "${2:$1}", + enabled => ${3:1} + } + +snippet define + define ${1} (${2}) { + ${3} + } + +snippet service + service{ "${1:service}": + enable => ${2:true}, + ensure => ${3:running}, + hasstatus => true, + } + +snippet file + file{ "${1:path}": + ${2} => ${3} + } + diff --git a/snippets/python.snippets b/snippets/python.snippets index 4386210..b3b1e9b 100644 --- a/snippets/python.snippets +++ b/snippets/python.snippets @@ -121,6 +121,8 @@ snippet ipdb # ipython debugger (pdbbb) snippet pdbbb import pdbpp; pdbpp.set_trace() +snippet pprint + import pprint; pprint.pprint(${1})${2} snippet " """ ${1:doc} diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index 199c1e3..26bdfa5 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -5,6 +5,7 @@ # #!/usr/bin/env ruby snippet #! #!/usr/bin/env ruby + # encoding: utf-8 # New Block snippet =b @@ -81,28 +82,23 @@ snippet cla class .. initialize .. end def initialize(${2:args}) ${3} end - - end snippet cla class .. < ParentClass .. initialize .. end class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} < ${2:ParentClass} def initialize(${3:args}) ${4} end - - end snippet cla ClassName = Struct .. do .. end ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} = Struct.new(:${2:attr_names}) do def ${3:method_name} ${4} end - - end snippet cla class BlankSlate .. initialize .. end class ${1:BlankSlate} instance_methods.each { |meth| undef_method(meth) unless meth =~ /\A__/ } + end snippet cla class << self .. end class << ${1:self} ${2} @@ -115,8 +111,6 @@ snippet cla- ${5} end - - end snippet mod module .. end module ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} @@ -527,13 +521,13 @@ snippet nam ${2} end snippet tas - desc "${1:Task description\}" + desc "${1:Task description}" task :${2:task_name => [:dependent, :tasks]} do ${3} end # block snippet b - {|${1:var}| ${2}} + { |${1:var}| ${2} } snippet begin begin raise 'A test exception.' @@ -554,7 +548,7 @@ snippet pry ############################################# # Rails snippets - for pure Ruby, see above # -############################################# +############################################# snippet art assert_redirected_to ${1::action => "${2:index}"} snippet artnp @@ -588,7 +582,7 @@ snippet crw snippet defcreate def create @${1:model_class_name} = ${2:ModelClassName}.new(params[:$1]) - + respond_to do |wants| if @$1.save flash[:notice] = '$2 was successfully created.' @@ -604,7 +598,7 @@ snippet defdestroy def destroy @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) @$1.destroy - + respond_to do |wants| wants.html { redirect_to($1s_url) } wants.xml { head :ok } @@ -617,7 +611,7 @@ snippet defedit snippet defindex def index @${1:model_class_name} = ${2:ModelClassName}.all - + respond_to do |wants| wants.html # index.html.erb wants.xml { render :xml => @$1s } @@ -626,7 +620,7 @@ snippet defindex snippet defnew def new @${1:model_class_name} = ${2:ModelClassName}.new - + respond_to do |wants| wants.html # new.html.erb wants.xml { render :xml => @$1 } @@ -635,7 +629,7 @@ snippet defnew snippet defshow def show @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) - + respond_to do |wants| wants.html # show.html.erb wants.xml { render :xml => @$1 } @@ -644,7 +638,7 @@ snippet defshow snippet defupdate def update @${1:model_class_name} = ${2:ModelClassName}.find(params[:id]) - + respond_to do |wants| if @$1.update_attributes(params[:$1]) flash[:notice] = '$2 was successfully updated.' @@ -775,15 +769,15 @@ snippet sha1 snippet sweeper class ${1:ModelClassName}Sweeper < ActionController::Caching::Sweeper observe $1 - + def after_save(${2:model_class_name}) expire_cache($2) end - + def after_destroy($2) expire_cache($2) end - + def expire_cache($2) expire_page end @@ -892,7 +886,7 @@ snippet migration def self.up ${2} end - + def self.down end end @@ -922,10 +916,10 @@ snippet cont ${2} end snippet bef - before(:${1:each}) do + before :${1:each} do ${2} end snippet aft - after(:${1:each}) do + after :${1:each} do ${2} end diff --git a/snippets/vim.snippets b/snippets/vim.snippets index 4b07cdb..329d1e9 100644 --- a/snippets/vim.snippets +++ b/snippets/vim.snippets @@ -41,3 +41,5 @@ snippet au " this one is which you're most likely to use? autocmd ${2:BufRead,BufNewFile} ${3:*.ext,*.ext3|} ${4} augroup end +snippet bun + Bundle '${1}'