code-snippets

Creating a new Guid inside a code snippet using c#

I want to make an intellisense code snippet using Ctl K + Ctl X that actually executes code when it runs... for example, I would like to do the following: <![CDATA[string.Format("{MM/dd/yyyy}", System.DateTime.Now);]]> But rather than giving me that string value, I want the date in the format specified. Another example of what I wa...

Can I define custom "surround with" templates in Visual Studio 2008?

Can I define custom "surround with" templates in Visual Studio 2008? ...

Multiple CodeSnippet in an XML .snippet file

I'm attempting to supplement the help features for my code by providing other developers with code snippets. These produce skeletons of code which demonstrate how to use/call my classes or methods. I've created a .snippet file and have placed it in the "%Visual Studio Folder%\Code Snippets\Visual Basic\My Snippets" folder. I've used the...

Very simple map implemention in C (for caching purpose) ?

I have a program that read urls in a file and does a gethostbyname() on each URL host. This call is quite consuming. I want to cache them. Is there a very simple map-base code snippet in C out there that I could use to do the caching? (I just don't want to reinvent the wheel). It has to have the following points : Open-source with ...

Best language for a personal code library?

I'd like to begin a personal code library to contain all the small utility functions I use on a daily basis but can't find elsewhere on the 'net (I work in a specialized field). In my work, I switch pretty often between different products, so I want something flexible enough that I won't need to recode it over and over again. My paramet...

Lift: how to retrieve the current logged in user?

I'm starting to learn Lift and I'm stuck. I have problem with simple snippet: class Util { def in(html: NodeSeq) : NodeSeq ={ if (User.loggedIn_?) Helpers.bind("user", html, "name" -> User.currentUser.map(_.lastName).open_!) else NodeSeq.Empty } It should inject current User name, but ...

Visual Studio 2008 Team System Upgrade Removes Code Snippets

I've been using VS 2008 for several months now and received a copy of VSTS 08 from work and installed without any issues. I upgraded VS 08 to VSTS 08 by running the VSTS installer without uninstalling VS 08. A few hours of after the install, I attempted to create a snippet in a VB project (Try Catch: Ctrl+K,Ctrl+X) and nothing happened. ...

Code snippet library for a team

I would like a general purpose code snippets library, that I could use to store bits of code for any language, organized in folders. When any developer on the network adds a snippet, it should get transferred to others. How can I do this simply? Any app that could be used for sharing libraries of text should be okay too. ...

how to generate the snippet like generated by google with PHP and MySQL?

Say,it just returns the snippet around which the searching keyword exists. And part of the text is replaced by "...". Is it possible to achieve that goal with PHP and MySQL? ...

Displaying code snippets in wordpress.

Ok, not technically a programming question but I want a plugin for my wordpress blog that displays code snippets. Can anyone here recommend a good one? Also, do you guys know which one Jeff uses on codinghorror. That one looks really good. Thanks. ...

How can I make a code snippet and add it to the Snippet intellisense in Visual Studio?

I'm curious if this is even possible. ...

How to use sphinx plugin for MySQL to implement fulltext search with PHP?

Can someone provide a demo here? And how to retrieve the matching snippet at the same time? ...

Code Snippet can't be added to snippet library in Visual C# Express '08.

This snippet is added fine: http://pastebin.com/m5f7f2dce And this is the one I'm trying to add into my IDE: http://pastebin.com/m61321572 But I recieve an "invalid snippet" error. I don't see anything different about the two except for the declaration area. Any help? ...

Open source code snippet repository

Does anyone know of a good and simple open source code snippet repository? Ive seen many that are free services, but I want to host it myself. A few google searches just find the free services. ...

How to write my own Global Snippets program with .NET?

I want to write my own global snippets tool for Windows XP and higher. This would be an always running in the background tool that would pop-up on a globally-defined hotkey, allow me to select a snippet with substitution arguments, and then paste the expanded snippet into the text input of whatever control I had been in when activated i...

Insert a snippet from a Visual Studio macro

I have a situation where I want to run a Visual Studio macro that has the user type something in an InputBox, then inserts a snippet and includes that text somewhere in it. Unfortunately, I can't figure out how to insert the snippet from macro code. It seems like it'd be something like DTE.ExecuteCommand("Edit.InvokeSnippetFromShortcu...

Is there a way in C# to access object properties in old, Pascal "with" keyword way?

This is the Pascal sample I want to achieve in C#: With myBook do Begin Title := 'Some Book'; Author := 'Victor John Saliba'; ISBN := '0-12-345678-9'; Price := 25.5; End; ...

TinyMCE + Wrapping code snippets

Is there a tinymce plugin that wraps text within the tag? Something similar to the formatting option from the WYSIWYG of SO ...

Can we make this snippet groovier?

Hey, are there any improvements where i can improve this code? Maybe there are some groovy language features? This snippet flattens a xml file to: node/node/node def root = new XmlParser().parse("src/your_xml.xml") root.depthFirst().each { n -> def name = n.name() while(n?.parent()){ name = "${n?.parent()?.name()}/${name}"; n =...

A VS 2008 code snippet doesn't get inserted fully

I have the Javascript one liner below as a code snippet in VS 2008 SP1. When I insert it in the code (C#) window, only 'var SelectedVal =' gets inserted, instead of the whole statement. Also.. is there a way to get the Insert Snippet to show up in the context menu when in aspx editor window? Code Snippet: var SelectedVal = $('#<%=DropD...