From 90177034e3f7f8a70e4810866cc329f97a6dba36 Mon Sep 17 00:00:00 2001 From: Eustaquio Rangel Date: Fri, 2 Mar 2012 16:23:09 -0300 Subject: [PATCH 01/12] Removed some Ruby duplicated snippets and fixed the migration snippet to don't use a non-existent function. --- snippets/ruby.snippets | 61 ++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 35 deletions(-) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index a607946..e206f1b 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -680,8 +680,6 @@ snippet logi logger.info { "${1:message}" }${2} snippet logw logger.warn { "${1:message}" }${2} -snippet mac - add_column :${1:table}, :${2:column}, :${3:type} snippet mapc ${1:map}.${2:connect} '${3:controller/:action/:id}' snippet mapca @@ -696,37 +694,12 @@ snippet mapwo end snippet mbs before_save :${1:method} -snippet mcc - change_column :${1:table}, :${2:column}, :${3:type} -snippet mccc - t.column :${1:title}, :${2:string} snippet mcht change_table :${1:table_name} do |t| ${2} end -snippet mcol - remove_column :${1:table}, :${2:column} -snippet mct - create_table :${1:table_name} do |t| - t.column :${2:name}, :${3:type} - end -snippet migration - class ${1:`Snippet_MigrationNameFromFilename()`} < ActiveRecord::Migration - def self.up - ${2} - end - - def self.down - end - end snippet mp map(&:${1:id}) -snippet mrc - remove_column :${1:column} -snippet mrmc - remove_column :${1:table}, :${2:column} -snippet mrnc - rename_column :${1:table}, :${2:old}, :${3:new} snippet mrw mattr_accessor :${1:attr_names} snippet oa @@ -854,13 +827,6 @@ snippet tcts snippet tctss t.timestamps ${1} -snippet trc - t.remove :${1:column} -snippet tre - t.rename :${1:old_column_name}, :${2:new_column_name} - ${3} -snippet tref - t.references :${1:model} snippet va validates_associated :${1:attribute} snippet vao @@ -905,8 +871,33 @@ snippet mac add_column :${1:table_name}, :${2:column_name}, :${3:data_type} snippet mrc remove_column :${1:table_name}, :${2:column_name} -snippet mrenc +snippet mrnc rename_column :${1:table_name}, :${2:old_column_name}, :${3:new_column_name} +snippet mcc + change_column :${1:table}, :${2:column}, :${3:type} +snippet mccc + t.column :${1:title}, :${2:string} +snippet mct + create_table :${1:table_name} do |t| + t.column :${2:name}, :${3:type} + end +snippet migration + class ${1:class_name} < ActiveRecord::Migration + def self.up + ${2} + end + + def self.down + end + end + +snippet trc + t.remove :${1:column} +snippet tre + t.rename :${1:old_column_name}, :${2:new_column_name} + ${3} +snippet tref + t.references :${1:model} #rspec snippet it From 008f3d9a65f6ffaed0069186ac662fc21d854589 Mon Sep 17 00:00:00 2001 From: Tyler Ball Date: Wed, 30 Nov 2011 09:24:07 -0500 Subject: [PATCH 02/12] removing empty line to prevent context tag from inserting a newline after itself --- snippets/htmldjango.snippets | 1 - 1 file changed, 1 deletion(-) diff --git a/snippets/htmldjango.snippets b/snippets/htmldjango.snippets index 6bff8c1..c87b5ee 100644 --- a/snippets/htmldjango.snippets +++ b/snippets/htmldjango.snippets @@ -8,7 +8,6 @@ snippet %% {% end$1 %} snippet { {{ ${1} }}${2} - # Template Tags snippet autoescape From e9eacc69d838975d86efc7421d0ede46ca4f642c Mon Sep 17 00:00:00 2001 From: Eustaquio Rangel Date: Mon, 5 Mar 2012 15:05:50 -0300 Subject: [PATCH 03/12] Seems to be a good time to create snippets for attr_protected and attr_accessible, right? ;-) --- snippets/ruby.snippets | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/snippets/ruby.snippets b/snippets/ruby.snippets index e206f1b..1ae0779 100644 --- a/snippets/ruby.snippets +++ b/snippets/ruby.snippets @@ -152,6 +152,10 @@ snippet w # attr_accessor snippet rw attr_accessor :${1:attr_names} +snippet atp + attr_protected :${1:attr_names} +snippet ata + attr_accessible :${1:attr_names} # include Enumerable snippet Enum include Enumerable From 6c886e2864287cfe64b17e93a4cb932e52046e75 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 27 Nov 2011 14:46:51 +1300 Subject: [PATCH 04/12] make sure $@ is localized for evals as perl "Modern Perl" --- snippets/perl.snippets | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 78ec125..25b12a1 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -47,10 +47,11 @@ snippet xunless ${1:expression} unless ${2:condition};${3} # Try/Except snippet eval + local $@; eval { ${1:# do something risky...} }; - if ($@) { + if (my $e = $@) { ${2:# handle failure...} } # While Loop From 827755ad89b805a9b2fa4910a57195aa2ec2e6a3 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 08:58:12 +1300 Subject: [PATCH 05/12] subroutine pod snippet with "=cut" For when someone wants to put the pod next to the subroutine definition --- snippets/perl.snippets | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 25b12a1..9c40051 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -215,6 +215,15 @@ snippet psub ${2:Summary....} +# Heading for inline subroutine pod +snippet psubi + =head2 ${1:MethodName} + + ${2:Summary...} + + + =cut + # Subroutine signature snippet parg From a8e879d9d8cdc11f682dd0f58dc82d419c8dc7dc Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 09:02:04 +1300 Subject: [PATCH 06/12] Added a snippet for Test::Routine style tests Also put in a more descriptive comment for Test::Class related snippet --- snippets/perl.snippets | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 9c40051..05882db 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -310,7 +310,7 @@ snippet override # use test classes snippet tuse use Test::More; - use Test::Deep; + use Test::Deep (); use Test::Exception; # local test lib @@ -326,7 +326,7 @@ snippet trunner use ${1:test_class}; $1->runtests(); -#testclass +# Test::Class-style test snippet tsub sub t${1:number}_${2:test_case} :Test(${3:num_of_tests}) { my $self = shift; @@ -334,6 +334,12 @@ snippet tsub } +# Test::Routine-style test +snippet trsub + test ${1:test_name} => { description => '${2:Description of test.}'} => sub { + my ($self) = @_; + ${3:# test code} + }; #prep test method snippet tprep From fafa4a7147004fa43e7ba5d6df9031a7c58fef63 Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 08:59:25 +1300 Subject: [PATCH 07/12] Cleanup - Moose parent class name should be enclosed in quotes --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 05882db..2670e49 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -267,7 +267,7 @@ snippet moosecl package ${1:ClassName}; use Moose; - #extends ${2:# ParentClass}; + #extends '${2:# ParentClass}'; ${6:# body of class} From 750f80fb7722cd3e2eedbf82dfd046a51db0257a Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 09:40:53 +1300 Subject: [PATCH 08/12] added myself to AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index 13cba33..e985d7e 100644 --- a/AUTHORS +++ b/AUTHORS @@ -34,3 +34,4 @@ marutanm msanders Povilas Balzaravičius Pawka Dmitry Dementev +Travis Holton From 9a18690ef3c0d804cbdc97f3d5ba994a69e53acb Mon Sep 17 00:00:00 2001 From: William Travis Holton Date: Sun, 11 Mar 2012 11:24:03 +1300 Subject: [PATCH 09/12] removing ; from end of package subroutine calls --- snippets/perl.snippets | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 2670e49..6fc7346 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -134,19 +134,19 @@ snippet begin # call package function with some parameter snippet pkgmv - __PACKAGE__->${1:package_method}(${2:var}); + __PACKAGE__->${1:package_method}(${2:var}) # call package function without a parameter snippet pkgm - __PACKAGE__->${1:package_method}(); + __PACKAGE__->${1:package_method}() # call package "get_" function without a parameter snippet pkget - __PACKAGE__->get_${1:package_method}(); + __PACKAGE__->get_${1:package_method}() # call package function with a parameter snippet pkgetv - __PACKAGE__->get_${1:package_method}(${2:var}); + __PACKAGE__->get_${1:package_method}(${2:var}) # complex regex snippet qrx From 92d94e89b186ce643237e3ee3dbac3d8d80f0320 Mon Sep 17 00:00:00 2001 From: Ryan Bright Date: Sun, 18 Mar 2012 19:44:33 -0400 Subject: [PATCH 10/12] Changed the CoffeeScript snippet to use the filename as the default class name. --- snippets/coffee.snippets | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/snippets/coffee.snippets b/snippets/coffee.snippets index d7a30f2..dfe3658 100644 --- a/snippets/coffee.snippets +++ b/snippets/coffee.snippets @@ -30,20 +30,22 @@ snippet bfun ${2:// body...} # Class snippet cla class .. - class ${1:ClassName} - ${2:// body...} + class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} + ${2} snippet cla class .. constructor: .. - class ${1:ClassName} + class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} constructor: (${2:args}) -> - ${3:// body...} + ${3} + ${4} snippet cla class .. extends .. - class ${1:ClassName} extends ${2:Ancestor} - ${3:// body...} + class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} + ${3} snippet cla class .. extends .. constructor: .. - class ${1:ClassName} extends ${2:Ancestor} + class ${1:`substitute(Filename(), '\(_\|^\)\(.\)', '\u\2', 'g')`} extends ${2:ParentClass} constructor: (${3:args}) -> - ${4:// body...} + ${4} + ${5} # If snippet if From af0c4dac622eca3110d29e68524ebb3ea2f44d19 Mon Sep 17 00:00:00 2001 From: Steven Humphrey Date: Mon, 19 Mar 2012 19:04:44 +0000 Subject: [PATCH 11/12] Changed hash bang line to env perl like other snippets. This allows the use of non-system perls. --- snippets/perl.snippets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/perl.snippets b/snippets/perl.snippets index 6fc7346..4ba985d 100644 --- a/snippets/perl.snippets +++ b/snippets/perl.snippets @@ -1,6 +1,6 @@ # #!/usr/bin/perl snippet #! - #!/usr/bin/perl + #!/usr/bin/env perl # Hash Pointer snippet . From f71665d3b20c08372e855846ca64da71f2c5d561 Mon Sep 17 00:00:00 2001 From: Srijan Choudhary Date: Fri, 23 Mar 2012 02:14:12 +0530 Subject: [PATCH 12/12] Added APACHE License 2.0 according to instructions here: http://www.apache.org/licenses/LICENSE-2.0.html#apply --- snippets/_.snippets | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/snippets/_.snippets b/snippets/_.snippets index 169797a..b99f454 100644 --- a/snippets/_.snippets +++ b/snippets/_.snippets @@ -196,5 +196,22 @@ snippet MIT DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - + + ${3} +snippet APACHE + ${1:one line to give the program's name and a brief description} + Copyright `strftime("%Y")` ${2:copyright holder} + + 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. + ${3}