<?php
/*
$foo = {
...

PHP JSON Literals in PHP

by Adam, May 31, 2011 22:13, 2 refactorings, tagged with json, preprocessor, variables

On a forum I was reading, s...

A8d3f35baafdaea851914b17dae9e1fc Talk
class Commentor
  def comment_type
    self.class.to_s.downcase
...

Ruby On Too many assignments and co...

by Adam, August 29, 2008 21:03

I couldn't quite discern wh...

A8d3f35baafdaea851914b17dae9e1fc Talk
def test_web_browser
  %w(Firefox/3 Firefox/2 MSIE\ 6 MSIE\ 7 Opera).detect do |agent|
    request.user_agent =~ Regexp.new(agent)
...

Ruby On Code to detect the web browser

by Adam, August 28, 2008 22:02

@Nicolás - I don't think t...

A8d3f35baafdaea851914b17dae9e1fc Talk
class Normalizer < Struct.new(:string)
  REPLACEMENTS = {
    0x92 => "&#39;",
...

Ruby On simplify multiple gsub

by Adam, August 28, 2008 18:50
A8d3f35baafdaea851914b17dae9e1fc Talk
def test_web_browser
  catch(:match) do
    ["Firefox/3", "Firefox/2", "MSIE 6", "MSIE 7", "Opera"].each do |ua|
...

Ruby On Code to detect the web browser

by Adam, August 28, 2008 18:32 Star_full
A8d3f35baafdaea851914b17dae9e1fc Talk
"\xBD + \xBC".chars.normalize.to_s
=> "1/2 + 1/4"

Ruby On simplify multiple gsub

by Adam, August 27, 2008 13:42 Star_fullStar_fullStar_fullStar_fullStar_full

Perhaps I wasn't clear with...

A8d3f35baafdaea851914b17dae9e1fc Talk
data.chars.normalize!

Ruby On simplify multiple gsub

by Adam, August 27, 2008 04:07 Star_fullStar_fullStar_fullStar_fullStar_full

Why not use ActiveSupport::...

A8d3f35baafdaea851914b17dae9e1fc Talk
require 'transaction/simple/group'

def transact(objects, action)
...

Ruby On Code transactions

by Adam, August 20, 2008 14:06 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
<span class="bluelinks-allsmall">
	<% if user.normal? %>
...

Ruby On Link to if else simple cond...

by Adam, August 20, 2008 13:51 Star_fullStar_fullStar_fullStar_full

You should be using named r...

A8d3f35baafdaea851914b17dae9e1fc Talk
//msg is the string to show in the alert.
//obj is the input to focus
function msgFocus(msg, obj){
...

JavaScript On Setting focus after alert

by Juha Hollanti, August 20, 2008 11:19

Form elements can be disabl...

A623216a5d2384489e012478c555d167 Talk
def sort(array)
  array.inject([]) do |sorted,element|
    small, large = sorted.partition { |item| item < element }
...

Ruby On Method for sorting

by Adam, August 20, 2008 05:21 Star_fullStar_fullStar_fullStar_fullStar_full

Here is your sort algorithm...

A8d3f35baafdaea851914b17dae9e1fc Talk
module ApplicationHelper
  def present(object)
...

Ruby On Default value for user column

by Adam, August 20, 2008 04:22 Star_fullStar_fullStar_fullStar_full

I disagree with the others ...

A8d3f35baafdaea851914b17dae9e1fc Talk
puts "Enter words, blank row quits."        

while !(line = gets.chomp).empty?
...

Ruby On Method for sorting

by Adam, August 19, 2008 17:43

Although I understand that ...

A8d3f35baafdaea851914b17dae9e1fc Talk
def self.favorite?(object)
  if reflection = object.class.reflect_on_association(:favorites)
    send("find_by_#{reflection.primary_key_name}", object)
...

Ruby On How to benchmark

by Adam, August 19, 2008 15:43 Star_fullStar_fullStar_fullStar_fullStar_full

Use script/performance/benc...

A8d3f35baafdaea851914b17dae9e1fc Talk
<%= pluralize(@resource.favorites.length, "Favorite") %>

Ruby On simple pluralize

by Adam, August 19, 2008 14:16 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
require "csv"
require "enumerator"

...

Ruby On CSV turn in to an array of ...

by Adam, August 15, 2008 13:23 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk

PHP On Getter and Setter

by Juha Hollanti, August 15, 2008 09:47

"Should you create a getter...

A623216a5d2384489e012478c555d167 Talk
class Report < ActiveRecord::Base
  %w[hits uniques].each { |const| const_set(const.upcase, const) }
end

Ruby On A shorter way to declare cl...

by Adam, August 14, 2008 20:13 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk
require "enumerator"

artists = [ 1, 2, 3 ]
...

Ruby On Split an array into half

by Adam, August 14, 2008 14:03 Star_fullStar_fullStar_fullStar_fullStar_full
A8d3f35baafdaea851914b17dae9e1fc Talk

PHP On Resize image to canvas

by Juha Hollanti, August 14, 2008 08:11

Checking for GD lib might a...

A623216a5d2384489e012478c555d167 Talk

PHP On Adding seconds to a MySQL t...

by Juha Hollanti, August 13, 2008 13:53

Wow, that's neat! And you'r...

A623216a5d2384489e012478c555d167 Talk
/**
 * Scale an image according to input canvas dimensions. 
 * No cropping will occur, the scaled image is "centered" to canvas.
...

PHP Resize image to canvas

by Juha Hollanti, August 13, 2008 11:50, 5 refactorings, tagged with image, php

The built in image function...

A623216a5d2384489e012478c555d167 Talk
echo '<qdapi>';
foreach($payload as $key => $value) {
    echo "<$key>$value</$key>";
...

PHP On Array and ForEach Loop

by Juha Hollanti, August 12, 2008 19:26

Yeah you're right, parsing ...

A623216a5d2384489e012478c555d167 Talk

ActionScript On Isometric X/Y Grid pattern ...

by Juha Hollanti, August 12, 2008 10:28

Umm, i don't know what you'...

A623216a5d2384489e012478c555d167 Talk

PHP On Adding seconds to a MySQL t...

by Juha Hollanti, July 15, 2008 19:42

Good stuff!

Gotta hate mys...

A623216a5d2384489e012478c555d167 Talk