code-snippets

List of Functional code snippets for Procedural Programmers?

Sometimes I still get stuck trying to translate procedural code into functional code. Is there a list of functional idioms/snippets that are mapped to procedural idioms/snippets? Edit Since there doesn't seem to be a centralized website of these snippets, I am turning this into a community wiki. Please paste any procedural -> function...

Handy F# snippets

There are already two questions about F#/functional snippets. However what I'm looking for here are useful snippets, little 'helper' functions that are reusable. Or obscure but nifty patterns that you can never quite remember. Something like: open System.IO let rec visitor dir filter= seq { yield! Directory.GetFiles(dir, filter)...

vs 2008 broken snippets functionality

Is there a way to reset to the original vb.net snippets that came along with visual studio 2008? I recently installed a purchased third party lib, that managed to break almost all the default snippets. I can see that the snippets do physically exist in C:\Program Files\Microsoft Visual Studio 9.0\VB\Snippets\1033 but only the followi...

Visual Studio - quick key or snippet for <% %>

My goal is to be able to quickly type this: <%= %> Can anyone suggest a way to make it easier within Visual Studio to insert the HTML code escape block. (I am not even sure the name of this piece of code!) I realize that typing <% in the code editor will autocomplete the escape block for me, but perhaps there's an easier way to input...

How can I delete a snippet in Visual Studio C# Express?

I've added a number of snippets in Visual Studio C# Express. Many are in the list double and I want to delete them. When the cursor is on the FOLDER called "MySnippets" the delete button is active. But when the cursor is on an individual snippet, the delete button is grayed out. I assume this is a bug, so are snippets saved in an XML...

generic code snippets / templates in eclipse

hi, i'm currently evaluating eclipse after using textmate for all my development for many years. what i miss in eclipse and what i can't find any solution for are some kind of generic templates: i'm using PDT for my javascript and php development, and it supports code-templates. however , in my projects i'm writing large amounts of she...

What is the best way to insert macros, snippets or code blocks into XAML view?

I would like to make a time-saving snippet to pop in blocks of XAML like this and then just change the values (like you can in code with e.g. "cw"-TAB or "foreach"-TAB): <Style x:Key="FirstCellStyle" TargetType="{x:Type Border}"> <Setter Property="BorderBrush" Value="Red"/> <Setter Property="MinWidth" Value="50"/> </Style> But...

Visual Studio Snippets - How to specify foreach loop's collection

When using the Visual Studio shortcut/snippets is it possible to specify the collection in advance/automagically, rather than fill in the green boxes afterwards? In this case, I'm trying to come up with something like the following with the fewest possible number of keystrokes: foreach (ListItem item in ListBox1.Items) { // } For...

Learn how to make Flair for my users (javascript snippets)

I wanted to give my users a little piece of JavaScript or HTML code that they could put on their site and show information about them. Kind of like StackOverFlows new feature Flair. I have an idea of how to code it. I was going to give them some JS with a HTML that had a DIV id="MySite_Info". Then the JS would go to my site and pull som...

Which one is "better" code snippet?

Which code snippet is better? and How? ['Better' on the basis of, readability, debug, code standards etc...,] Dim Name As String = Employee.Name or Dim Name As String Name = Employee.Name ...

Is this possible with Visual Studio snippets?

I use a modified form of TODO comment (SteveC_TODO) that allows me to group my own todos together in the task list. Yesterday I thought it would be nice to modify the refactoring snippets to add a todo comment to the usual NotImplemented exception. I modified the Method Stub - Body snippet to this $signature$ { //SteveC_TODO: impleme...

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

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 sele...

Insert current datetime in Visual Studio Snippet

Does anyone know of a way that I can insert the current date & time in a visual studio 2008 snippet? What I want is something like this in the body of my .snippet file... <Code Language="csharp"> <![CDATA[ // $DateTime$ // more code here for my snippet... </Code> ...

Are there any alternatives to FastSharp?

Are there any alternatives to Matt Manela's FastSharp tool? I have a vague recollection that there was at least one alternative. Here FastSharp is the download link. ...

VS2008 XML Code Snippets Not Working

I added a folder to the Code Snippets Manager, opened the Parent.snippet file for use as a template, edited it as below, and saved it to my "XML Snippets" folder. Now, whenever I try to use a snippet, the editor inserts a comment (<!-- -->) instead of the snippet contents... FOR ANY snippet, the VS2008 original snippets, my snippet - do...

is there an online javaScript code snippets resource that lets you run code?

is there an online javaScript code snippets resource that lets you run code? this would especially be useful for example code when trying to answer questions on SO! thanks, Josh ...

Tools for managing Text Templates / Boilerplate Code or Snippets ?

I am looking for freely available tools to help manage text templates (e.g. for writing emails or other letters), boilerplate code and other snippets. Preferably something open source or at least freeware. Ideally, it would not be specific to managing source code, but would generally help manage all sorts of ASCII chunks (or maybe ev...

Write C# snippets that end by hitting TAB

The C# code snippets I create can only be ended by hitting Enter, while the built-in snippets such as 'struct' can be completed by tabbing through the custom fields. It's not a big issue but it is annoying. I tried copying the entire XML for the struct snippet into my own, replacing only the shortcut name. Even so I had to hit Enter to ...

Does anyone have a PHP snippet of code for grabbing the first "sentence" in a string?

If I have a description like: "We prefer questions that can be answered, not just discussed. Provide details. Write clearly and simply." and all I want is "We prefer questions that can be answered, not just discussed." I figure I would search for a regular expression, like "[.!\?]", determine the strpos and then do a substr from the ...

How to add date into C# snippet

I would like to add to my c# Visual C# Express (no macros) snippet current date and time tag. How to do it? When I will use intellisense to create code with this snippet I would like to have current date and time put into code. ...