1
2
3
4
def test_web_browser()
  if request.env["HTTP_USER_AGENT"][/Firefox\/3/]=="Firefox/3"
    return "Firefox3"
...

Ruby Code to detect the web browser

by dcadenas.blogspot.com, August 28, 2008 17:19, 9 refactorings

This is not my code but I w...

Acad2552784135c09b17c00853f5a6f8 Talk
1
2
3
4
<?php
class PropertyHandler 
{
...

PHP Base class for easy class p...

by antelopelovefan.com/id, August 28, 2008 12:35, No refactoring, tagged with php class properties

This class lets you handle ...

040ffc7f3327b05f01c54a8bef3ba60a Talk
1
2
3
4
try:
    if options.input_file:
        infile = open(options.input_file, 'r')
...

Python Your average file filter...

by agnul, August 27, 2008 17:22, 2 refactorings

From the useless speculatio...

Ee62f45441fbf8409dfd4adaa40a74aa Talk
1
2
3
4
data = data.gsub("\xA0", " ")
data = data.gsub("\x99", "(TM)")
data = data.gsub("\x97", "-")
...

Ruby simplify multiple gsub

by kenr, August 27, 2008 01:10, 11 refactorings, tagged with strings

I could put the search/repl...

60997be4fbb4f5719d6eb68a1eadee9a Talk
1
2
3
4
#!/usr/bin/python
# -*- coding: utf-8 -*-

...

Python Parse XML from Yahoo weathe...

by kael, August 26, 2008 17:27, No refactoring, tagged with python, dom, xml, rss

Is there a more efficient w...

Ec5a58db4acc016568e0293d283cbc2d Talk
1
2
3
4
#!/usr/bin/python
# -*- coding: utf-8 -*-

...

Python Base64 image encoding and i...

by kael, August 25, 2008 19:05, No refactoring, tagged with python, image, base64, hash, sha224

Is this a correct a way to ...

Ec5a58db4acc016568e0293d283cbc2d Talk
1
2
3
4
#!/usr/bin/python
# -*- coding: utf-8 -*-

...

Python Query TinyUrl the fastest way

by kael, August 25, 2008 18:44, No refactoring, tagged with python, http, tinyurl, urllib, urllib2

I'm looking for the fastest...

Ec5a58db4acc016568e0293d283cbc2d Talk
1
2
3
#!/usr/bin/perl -w
package Bdecode;
...

Perl Bencode decoder

by Chris Jester-Young, August 22, 2008 01:19, No refactoring, tagged with bencode, bdecode, torrent

The BitTorrent .torrent fil...

729442eea8d8548842a6e0947e333c7b Talk
1
2
3
<?php
function loadModel($model)
...

PHP model loader

by Ishkur, August 21, 2008 14:16, 5 refactorings, tagged with model loading

I'm doing a lot of work wit...

6dc0e9a07bcff97ac9b111f36e12f1f6 Talk
1
2
3

...

Ruby Link to if else simple cond...

by DG, August 20, 2008 09:43, 4 refactorings

Hi,

Are there any other ...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
class Test
  @@tries=0
  attr_reader :num
...

Ruby Code transactions

by John Sietsma, August 20, 2008 07:14, 5 refactorings, tagged with transact, rails

In a Rails controller I'm s...

37ce1520d319fa8095d05aa475951616 Talk
1
2
3
4
public static int[] zigzagify(int[] array, int xmax, int ymax) {
        int[] zz = new int[array.length]; //zigzag array
        if (array.length != xmax * ymax) {
...

Java Zig Zag ordering of array

by kane77, August 19, 2008 21:27, 3 refactorings, tagged with array, zigzag, ordering

This is the code that is su...

Eee5491d255814140670a5937d53aef3 Talk
1
2
3
4
#!/usr/bin/env python
# -*- coding: utf-8 -*-

...

Python Get function's attributes

by ielectric.myopenid.com, August 19, 2008 18:04, 1 refactoring, tagged with function, attribute

I bet there is some other, ...

Avatar Talk
1
2
3
4
def ask_words 
	array = []
	puts 'Enter words, blank row quits.'
...

Ruby Method for sorting

by onwinning.blogspot.com, August 19, 2008 17:14, 5 refactorings, tagged with noob, sorting, sort

This is exercise from Chris...

Avatar Talk
1
2
3
4
 @tags = ["Science","Tools","Physics"]

...

Ruby link_to for tags

by DG, August 19, 2008 12:44, 2 refactorings

Hi,
- I have @tags instanc...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
<% if @favorite_flag %>

<div class="float-l-r" > 
...

Ruby simple link_to_remote if el...

by DG, August 19, 2008 11:35, 2 refactorings

Hi,
- In following code sn...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
              <%if @user.city.blank?%>
...

Ruby Default value for user column

by DG, August 19, 2008 08:57, 5 refactorings

Hi,
- In users table city ...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
def self.isFavorite(userId,objId,objClass)
...

Ruby How to benchmark

by DG, August 19, 2008 07:01, 1 refactoring

How I should benchmark foll...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
 <% if @resource.favorites.length > 1 %>
...

Ruby simple pluralize

by DG, August 19, 2008 05:08, 3 refactorings

Hi,
There is a rails funct...

51224bdd17878b3b19e8987e9bb336a2 Talk
1
2
3
4
	public static String getRelativePath(File file, File relativeTo) throws IOException {
		/*
		 * windows seems in some cases not to stop getParent() at 'c:\', which I
...

Java get path of a File relative...

by lord alcol, August 18, 2008 17:23, No refactoring, tagged with java, file, path

I call:
File f = new File(...

A9c8a6d8eed437bb33d504cae365bf57 Talk
1
2
3
4
//msg is the string to show in the alert.
//obj is the input to focus
function msgFocus(msg, obj){
...

JavaScript Setting focus after alert

by danielks, August 18, 2008 16:53, 4 refactorings, tagged with focus firefox

I don't know why, after an ...

Avatar Talk
1
2
3
4
	public static boolean fileContentsEquals(File file1, File file2) {
		InputStream is1 = null;
		InputStream is2 = null;
...

Java fileContentsEquals

by lord alcol, August 18, 2008 09:09, 3 refactorings, tagged with java, io, file

This method checks if the c...

A9c8a6d8eed437bb33d504cae365bf57 Talk
1
2
3
4
<?php

class RequestFile
...

PHP Universal File Download Class

by Chris Dean, August 16, 2008 11:21, 3 refactorings, tagged with php, 5, universal, file, download, class

After finding different hos...

151e36cc7f789a4790c8ca437e3a1f60 Talk
1
2
3
4
  def html_truncate(text, length = 30, options = {})
    options.merge!(:break_on_word => true) unless options[:break_on_word]
    truncate_string = options[:truncate_string] ? options[:truncate_string] : "..."
...

Ruby ruby html_truncate

by roym, August 15, 2008 07:49, 1 refactoring

This is a rewrite of rails ...

0ef33c8569b50042f1ddb7dc51141e88 Talk
1
2
3
4
def fix_send_to_array(array)

  a = array.split(',')
...

Ruby CSV turn in to an array of ...

by nathan, August 15, 2008 06:48, 4 refactorings, tagged with short csv

Hello all,
I am trying to ...

B4ec694f9d955bee753559037aa1805a Talk