1 2 3 4
int max = rand(); // or any init value int min = rand(); // or any init value int tmp = rand(); // or any init value ...
C How to find max, min of thr...
by Tien Dung,
November 18, 2008 12:33,
4 refactorings
I tried to use as less vari...
1 2 3 4
class Publication < ActiveRecord::Base def publisher_name ...
Ruby Similar virtual attributes ...
by foxdemon,
November 20, 2008 13:42,
4 refactorings, tagged with getter, setter, virtual attributes
My Publication class has a ...
1
/(?<part>(w(?!ww)|w(?=www)|w(?=[a-z0-9]+ww)|ww(?=[a-z0-9]+w)|www[a-z0-9]+|[a-vx-z0-9])[a-z0-9]*)\.example\.com/
Ruby Shortest regular expression...
I have written this regular...
1 2 3 4
select = [] joins = [] %w[first second third forth].each{ |semester| joins << ":pdp_#{semester}_semester"; (1..5).each{ |n| select << "pdp_#{semester}_semesters.objetive_#{n} AS #{semester}_objetive_#{n}" }} ...
Ruby Arrays, loops, strings...
Can this be done in one line?
1 2 3 4
def field_row(options={}, &block) concat("<div class="field_row">", block.binding) concat(capture(&block), block.binding) ...
Ruby Cheap ruby block templating
Hello all. I've got the fol...
1 2 3 4
/// <summary> /// Test to see if the type can be XML serialized /// </summary> ...
C# Check type is XML Serializable
by sbehnke.myopenid.com,
November 19, 2008 22:23,
2 refactorings
I need a fast method to che...
1 2 3 4
def test(a, b) capitalize_args puts a # => Hello ...
Ruby Bindings on caller
I dont really have a need f...
1 2 3 4
#!/usr/bin/perl -w use strict; ...
Perl Apache log file sorting
I have a huge amount of log...
1 2 3
<div id="showcase"> <ul class="nav"> ...
JavaScript Tab-Switching in jQuery
Is there a better way?
1 2 3
<div id="slideshow" style="background:#FFF"> <h2 class="slideshowTitle">Around the World with Language</h2> ...
JavaScript Serena Collage slideshow
by tbeseda,
November 19, 2008 21:53,
No refactoring, tagged with serena, collage, serenacollage, slideshow, javascript
Creating a slideshow in our...
1 2 3 4
def author_names=(authors) # authors - a list of names, e.g. "Author1 ,Author2" new_author_names = authors.split(',').each {|a| a.strip!} #e.g. ["Author1","Author2"] ...
Ruby Keeping the database clean
by foxdemon,
November 21, 2008 14:31,
No refactoring
I have a simple Author mode...
1 2 3 4
def monitor(uri) Thread.new(uri) do |uri| begin ...
Ruby Initial script execution ve...
by Tj Holowaychuk,
November 22, 2008 02:27,
No refactoring
Below is a little snippit o...
1 2 3 4
def factorial( n ) if !(n.is_a? Integer) raise ArgumentError, "argument must be a positive integer" ...
Ruby A simple factorial program.
by lordzoner.myopenid.com,
November 12, 2008 02:16,
7 refactorings, tagged with short, ruby, factorial
I'm quite new to Ruby, and ...
1 2 3 4
<?php /* E.g: ...
PHP remove http from url string
by armano.myopenid.com,
November 11, 2008 04:09,
6 refactorings, tagged with short url, url, remove http
Ive made a function simply ...
1 2 3
class PropertiesController < ApplicationController before_filter :authorise_action ...
Ruby Condensing nested conditionals
The code below works, but f...
1 2 3 4
public static class DirectoryInfoExtensions { public static void CopyTo(this String Source, String Destination, Boolean Overwrite) ...
C# DirectoryInfo.CopyTo
Because the .NET Framework ...
1 2 3 4
public static class HtmlHelper { public static string StripHtmlComments(string html) { if (html == null) { ...
C# Strip Html Comments
Procedural style code to st...
1 2 3 4
// For faster converting of dates to strings char* sLeadingZeroIntegerValues[] = { "00","01","02","03","04","05","06","07","08","09", ...
C++ Stream ADODB recordset into...
by ctrager.blogspot.com,
November 11, 2008 12:30,
1 refactoring, tagged with C++, COM, ADODB, STL, speed
Can we make the code betwee...
1 2 3 4
main = do s <- getContents putStr (unlines (reverse (rotate (lines s)))) ...
Haskell Cat90
Rotates text given in stdin...
1 2 3 4
describe Stock do it "should be valid when new" do ...
Ruby repeated code in rspec mode...
how do i clean up this repe...
1 2 3
class PeopleController < ApplicationController ...
Ruby Re-use code for new and cre...
Hello,
I have a 'people'...
1 2 3 4
public static class DependencySorter<T> { public static IEnumerable<T> Sort(Dictionary<T, IEnumerable<T>> dependencies) ...
C# Sorting by dependencies
This code sorts a collectio...
1 2 3 4
# [user@host ~]$ ls -l blah # -rwxr--r-- 1 user users 0 2008-11-06 15:20 foo ...
Ruby Pretty output of permission...
This snippet is designed to...
Is it possible to cache met...