code-snippets

PHP - How to count lines of code in an application [duplicate]

醉酒当歌 提交于 2019-12-03 00:51:32
This question already has answers here : count lines in a PHP project [closed] (7 answers) I need to count the number of lines of code within my application (in PHP, not command line), and since the snippets on the web didn't help too much, I've decided to ask here. Thanks for any reply! EDIT Actually, I would need the whole snippet for scanning and counting lines within a given folder. I'm using this method in CakePHP, so I'd appreciate seamless integration. To do it over a directory, I'd use an iterator. function countLines($path, $extensions = array('php')) { $it = new

Vim html.erb snippets?? snipMate Need a vim tip

杀马特。学长 韩版系。学妹 提交于 2019-12-02 23:21:07
When I'm in an html.erb file, I get no snipMate snippets. I would like both HTML and Ruby, or just HTML would be fine, How would I do this? Would I need to write a set of snippets? If so, is there a way of pulling in existing snippets without copying them? Is there a way of telling vim to go into html mode when it sees .html erb? Snippets are stored in directory called snippets somewhere in your ~/.vim folder. If you look there, there is usually one file per filetype, there is a c.snippets, a ruby.snippets, so it seems what you have to do is to create an erb.snippets there with what you want.

How to move Visual Studio's 'My Code Snippets' folder to another drive?

不想你离开。 提交于 2019-12-02 23:16:49
A simple question for which I couldn't find a setting or an answer: I relocated my Documents folder in Windows to another drive. How do I change the My Code Snippets folder path in Visual Studio 2012 from the default to the new location? The default is in my Documents folder on C:. C:\Users\Virtlink\Documents\ Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets But I moved my Documents folder to my drive D:, but Visual Studio didn't pick up on this change and forces the creation of the folder on C:. This causes some weird behavior with exclamation marks next to My Code Snippets in the

How to use the “sysout” snippet in Eclipse with selected text?

安稳与你 提交于 2019-12-02 22:13:46
I am aware of the Eclipse snippet "sysout" which is neatly replaced with System.out.println(); when tab-completed. This is very useful but sometimes, I need to wrap some existing code in a System.out.println(); In Eclipse internals, the template is defined as being able to wrap a "selected word". But how can I use the snippet with selected text since typing "sysout" obviously removes the selected text. Any idea? The sysout template acts upon entire Java statements. Highlight a statement in the editor. Hit CTRL-SPACE (or whatever you have set up for content assist.) Type sysout then hit enter.

Code Snippet Managers for Linux desktops? [closed]

吃可爱长大的小学妹 提交于 2019-12-02 21:09:37
In the spirit of https://stackoverflow.com/questions/3349990/code-snippet-managers-for-os-x What are some good code snippet managers for Linux? My quick search didn't turn up much. Eclipse, emacs, vim, Kate, and KDevelop all offer their own integrated snippet managers, but I'm looking for something more generic along the lines of CodeCollector or Snippets , ideally with the option of a CLI interface. Even a pure CLI tool would be acceptable (maybe even preferable). sleepynate Have you seen jCodeCollector? It's a significantly less complicated clone of CodeCollector, but is multiplatform (java)

Sphinx, reStructuredText show/hide code snippets

僤鯓⒐⒋嵵緔 提交于 2019-12-02 18:41:27
I've been documenting a software package using Sphinx and reStructuredText . Within my documents, there are some long code snippets. I want to be able to have them hidden as default, with a little "Show/Hide" button that would expand them ( Example ). Is there a standard way to do that? Kevin Horn I think the easiest way to do this would be to create a custom Sphinx theme in which you tell certain html elements to have this functionality. A little JQuery would go a long way here. If, however you want to be able to specify this in your reStructuredText markup, you would need to either get such

Cool tricks and expressive snippets with ruby collections/enumerables [closed]

寵の児 提交于 2019-12-02 18:39:21
What are your favorite code snippets with ruby collections? Preferably they should be discovery for you, be expressive, readable and introduce some fun in your coding practice. Pattern-matching in arrays (for local variables and parameters): (a, b), c = [[:a, :b], :c] [a,b,c] => [:a, :b, :c] (a,), = [[:a]] a => :a Assigning from non-arrays to multiple variables: abc, a, b =* "abc".match(/(a)(b)./) => ["abc", "a", "b"] nil1, =* "abc".match(/xyz/) => [] Initialize array elements with the same expression: 5.times.map { 1 } => [1,1,1,1] Array.new(5) { 1 } => [1,1,1,1,1] Initialize array with the

Replace parameter multiple times in Xcode code snippets

倖福魔咒の 提交于 2019-12-02 17:52:19
Can I create a custom snippet that takes a parameter that is replaced multiple times inside the code? I tried something like: <#class#> instanceOf<#class#>; but it doesn't replace both class placeholders when I insert the snippet and write over the first parameter. This is not possible in Xcode 4.x at the time of writing (Sept. 2011). If you want this feature back in Xcode 4.x, please go to bugreport.apple.com and report a duplicate for this rdar that I just preported: Summary: Xcode 4 snippets with tokens of same name should sync while filling one of them. Steps to Reproduce: 1. Define this

How do I setup/use ruby on rails snippets and autocomplete in sublime text 2?

会有一股神秘感。 提交于 2019-12-02 17:43:54
I would appreciate if someone could direct me to a website that shows how to do this.. Can't seem to find anything decent enough via google. This will be the first time I'm doing this kind of thing with a text editor.. It has got to the stage where typing out things like <%= %> is getting old and slow. I've got a rails snippet package and also ryan-on-rails package installed. Just confused with how to start using them. I'm on max osx - snow leopard Kind regards Update This helped me out. http://webtempest.com/sublime-text-2-how-to-create-snippets/ but I still need a little practice. I have a

VS Code Intellisense don't suggest snippet at first

懵懂的女人 提交于 2019-12-02 17:27:12
I want to use code snippets in VSCode. But when I type, for example, for in javascript file, the Intellisense doesn't suggest snippet "for-loop" - I need to manually scroll the dropdown and select it. Is there any way to make VSCode to suggest snippets at first? Thank you! UPD: I have found the person with same problem, but he has no answers - link You need to use editor.snippetSuggestions config option with "top" value. Please, see Customizing IntelliSense article for more tips and tricks. There is one more way to deal with this issue by setting "editor.tabCompletion": true, that way whenever