code-snippets

Textmate snippet to add file name and path in comment?

I'm using an existing snippet in Textmate to reduce the repetition of creating controllers and models. The snippet works great, but I'd love to add a comment to the end of each file. For example: /* End of file filename.php */ /* Location: ./system/application/controllers/filename.php */ The first line is easy: /* End of file ${TM_...

Code snippet plugin

Are there any good code snippet plugins for visual studio? I want a plugin which can use a online snippet site (such as snipplr). It should be easy to both find and upload snippets. ...

Is it possible to insert a code snippet inside the ASP.NET <% %> tag using a shortcut?

The regular way (typing the shortcut followed by the Tab key) doesn't seem to work. If not, maybe there's some other way of inserting snippets not using the mouse, with as few keystrokes as possible? What language should be specified in the "language" attribute of the "Code" element in the .snippet file? I use VS2010. ...

Convert a Python snippet to PHP?

Can anyone translate my small Python snippet to PHP? I'm not a familiar with both languages. :( matches = re.compile("\"cap\":\"(.*?)\"") totalrewards = re.findall(matches, contents) print totalrewards Thank you for those who'd help! :( ...

Android Clickable ListView - creating a dynamic MultiRow ListView

Following the snippet link text on androidsnippets.org, Creating a Multi-Row/Multi-Column ListView is pretty straight forward. The question is, how do you create a Multi-Row ListView, with different Views/Items for each row, based on the ArrayAdapter/Data populating the List? ...

Runtime Revolution simple but hard question...

Can anyone convert this RunRev function to a usable PHP function? I'm not an expert when it comes to PHP so I hope somebody helps me... Here is the RunRev code snippet, -> http://paste-it.net/public/n8a6437/ I hope somebody helps me... ...

Personal archive tool, looking for suggestions on improving the code

i've written a tool in python where you enter a title, content, then tags, and the entry is then saved in a pickle file. it was mainly designed for copy-paste functionality (you spot a piece of code you like on the net, copy it, and paste it into the program), not really for handwritten content, though it does that with no problem. i ma...

VS 2010 custom code snippet loses focus when typing

I created a custom HTML code snippet in Visual Studio 2010 to insert a form field with label, textbox and RequiredFieldValidator. I specified Declaration tags for the control IDs, label text and validator ErrorMessage property. The snippet has been imported into the My HTML Snippets folder with the Code Snippet Manager in VS 2010. When ...

Emacs: Enter commands like in gedit

Hey, in gedit it's possible to define so-called "snippets" for simpler input. For example, there is a snippet while. This means: If you type while -> (-> stands for tab key). And gedit automatically converts it to the following (including correct indentation): while (condition){ } In vim (in conjunction with latex-suite) I saw the ...

Code Examples For Programming Languages

When you are designing a new programming language, or comparing existing programming languages, what types of code examples should you write? They should: emphasize the important features of the language(s) take considerations into important/common features allow learning by examples. Also, list some simple algorithms that worth to b...

Code Snippet Managers for OS X?

What are some good code snippet managers for OS X? ...

How to automatically generate code that has to be written for every method?

I'm working on a project and every single method I write starts off identical to: public blah blah() // my method signature { Tracing.StartOfMethod("Repositroy"); // I'll declare variables as needed try { // the content here differs for every method } catch (Exception ex) { ErrorSignal.FromC...

Can't install yasnippet?

I tried to install yasnippet using the "normal install" protocol given here. After placing the yasnippet-0.6.1c folder in ~/.emacs.d/plugins/, I tried to eval the following in my .emacs: (add-to-list 'load-path "~/.emacs.d/plugins/yasnippet-0.6.1c") (require 'yasnippet) ;; not yasnippet-bundle (yas/initialize) (yas/load-d...

OpenLayers API Documentation

Hi! I'm doing a project using OpenStreetMap. There is this one working code snippet that I found that I'm using for adding markers: ... styleMap: new OpenLayers.StyleMap( graphicYOffset: -25, // shift graphic up 28 pixels label : "${name}", // Set the external graphic and background graphic images. externalGraphic: "${icon}", b...

Extract snippet out of HTML with Ruby?

I need to show the first 100 characters of an HTML text, which means, I have to pick the first 100 characters that are not tags and then close any open tags leaving a balanced HTML. Is there any library that can do it? Or is there any trivial way to do it that I am missing? The text is originally written in Textile which can and does co...

Code Snippet Managers for Linux desktops?

In the spirit of http://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 CodeC...

Intentionally Buggy Code (Python)

This is a strange request but I'm looking for buggy Python code. I want to learn more about bugs and debuggers and I need some buggy code to work with. Unfortunately, all the code I've written is short and bug-free (so far). Preferably it's not GUI stuff (b/c I'm just starting to learn it) but anything's good. Thanks in advance ...

how asp.net gets surrounding code on error

Does anybody know how ASP.NET loads code snippet (i.e. the code you write including comments) on exception and displays it to user. It is the error screen with code snippet in yellow where the line where the occurs is highlighted in red. ...

Folder imported in Code Snippets Manager not showing in text editor - Visual Studio 2010

In the Code Snippet Manager I chose "Language: Visual C#" and added a folder containing one .snippet file I created. Then, when editing a .cs file, I try to insert a snippet using ctrl+k ctrl+x but my newly added folder does not show in the list. I'm I missing something? Do you have to specifically tell IntelliSense which snippets you ...

VS 2008 Code Snippets - Removing an entire folder

OK, this is somewhat frustrating. We have a folder containing custom code snippets used by our company to ensure coding standards and the like. I was documenting the process of actually adding said folder to Visual Studio 2008, when I accidentally added the wrong folder (I added the folder one level up). Since we have both C# and VB s...