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

by Alistair, November 22, 2008 15:50, 3 refactorings, tagged with rails, blocks

Hello all. I've got the fol...

95d8510ef03567cd7d014d4790116b0d Talk
1
2
3
4
def test(a, b)
  capitalize_args
  puts a   # => Hello
...

Ruby Bindings on caller

by Tj Holowaychuk, November 22, 2008 06:16, 2 refactorings, tagged with binding

I dont really have a need f...

F1e3ab214a976a39cfd713bc93deb10f Talk
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...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
4
  NAME:
  
...

Ruby suppress ERB newlines

by Tj Holowaychuk, November 22, 2008 02:16, No refactoring, tagged with erb

Just plain-jane ERB. What d...

F1e3ab214a976a39cfd713bc93deb10f Talk
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...

8fa97b9513b66cccc2db021782863b3b Talk
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...

by Ceritium, November 20, 2008 22:09, 3 refactorings, tagged with array string loop each

Can this be done in one line?

7841fbf022cfe78bff34942b50c483e1 Talk
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 ...

8fa97b9513b66cccc2db021782863b3b Talk
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...

Avatar Talk
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...

6e585eb21989377a2669d19cca43f40d Talk
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...

by troethom, November 19, 2008 18:48, 3 refactorings, tagged with regex

I have written this regular...

628b75cc5fce9ab14d9e8584a0b3681c Talk
1
2
3
4
class Something
  
...

Ruby Caching Methods

by Tj Holowaychuk, November 19, 2008 05:23, 6 refactorings, tagged with cache

Is it possible to cache met...

F1e3ab214a976a39cfd713bc93deb10f Talk
1
2
3
<div id="showcase">
  <ul class="nav">
...

JavaScript Tab-Switching in jQuery

by Aupajo, November 19, 2008 00:45, No refactoring, tagged with javascript, tabs, jquery

Is there a better way?

Ca3dc3f93730afb41d6753d8bf010a38 Talk
1
2
3
4
#!/usr/bin/perl -w

use strict;
...

Perl Apache log file sorting

by hourback, November 18, 2008 16:22, 1 refactoring, tagged with apache, timestamp, epoch, logs

I have a huge amount of log...

066739a7a44b7fb8be64e73f9f4323cb Talk
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...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
describe Stock do

  it "should be valid when new" do
...

Ruby repeated code in rspec mode...

by scottmotte.myopenid.com, November 15, 2008 08:51, No refactoring, tagged with rspec, merb, model

how do i clean up this repe...

2fb54bca5a55a7a16f8f9c20c05ce7c2 Talk
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 ...

88f4aad84b5441c255cbe96a0fcc6319 Talk
1
2
3
4
main = do s <- getContents
          putStr (unlines (reverse (rotate (lines s))))

...

Haskell Cat90

by jarkko, November 11, 2008 22:53, 1 refactoring, tagged with haskell

Rotates text given in stdin...

630067ad4c10410798d1550152f20d41 Talk
1
2
3
class PropertiesController < ApplicationController
  before_filter :authorise_action
...

Ruby Condensing nested conditionals

by Nick, November 11, 2008 21:28, 4 refactorings, tagged with ruby rails condense conditions

The code below works, but f...

49de4cd2f26705785cbef2b15a9df7aa Talk
1
2
3
4
public static class DirectoryInfoExtensions
{
    public static void CopyTo(this String Source, String Destination, Boolean Overwrite)
...

C# DirectoryInfo.CopyTo

by GateKiller, November 11, 2008 17:10, 3 refactorings, tagged with C#, .net, directoryinfo, copyto

Because the .NET Framework ...

98c852e2d9b26249745ea92c72964d3f Talk
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...

23da7be57867a7eb54b583983c89b375 Talk
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 ...

1cd9c8984f2fdeb996130d54d62a98d9 Talk
1
2
3
4
public static class HtmlHelper {
    public static string StripHtmlComments(string html) {
        if (html == null) {
...

C# Strip Html Comments

by Haacked, November 11, 2008 01:14, 2 refactorings, tagged with html parse

Procedural style code to st...

Cdf546b601bf29a7eb4ca777544d11cd Talk
1
2
3
4
# Suppose I have San::Languages::JavaScript as the 'lang' local var below
# I want a string of 'JavaScript' from this example
...

Ruby Retrieve class name only

by Tj Holowaychuk, November 07, 2008 04:41, 1 refactoring

Im sure there is a better w...

F1e3ab214a976a39cfd713bc93deb10f Talk
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...

by ScriptFu, November 06, 2008 22:29, 3 refactorings, tagged with shell ruby permissions

This snippet is designed to...

097df7a744da527a58b40d21260f1f8d Talk
1
2
3
<ul>			  
...

Ruby View refactoring

by DG, November 06, 2008 07:01, 1 refactoring

In following code ul gettin...

51224bdd17878b3b19e8987e9bb336a2 Talk