1
2
3
4
$(document).ready(function(){
  var resultsMax = 15;

...

JavaScript On Split text into unordered l...

by Tien Dung, January 26, 2009 08:19 Star_fullStar_fullStar_fullStar_fullStar_full
5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
jQuery.fn.checkNext = function() {
  if (this.is(':selected')) {
    this.attr('selected', false);
...

JavaScript On Check next option in select...

by Tien Dung, January 26, 2009 01:22 Star_fullStar_fullStar_fullStar_fullStar_full

Simo refactoring is great. ...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
times = [
  null,
  '7:00AM ',
...

JavaScript On Writing a loop to create a ...

by Tien Dung, December 11, 2008 08:35 Star_fullStar_fullStar_fullStar_fullStar_full
5071c5b861341c0dcfcf6ac86327701f Talk

C On How to find max, min of thr...

by Tien Dung, November 20, 2008 00:01

Hi Eineki, please explain h...

5071c5b861341c0dcfcf6ac86327701f 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, 15 refactorings

I tried to use as less vari...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
function getAnchor(default) {
  default = default || 'news';
  return document.location.toString().split( '#' )[1] || default;
...

JavaScript On Small Javascript Code

by Tien Dung, October 06, 2008 22:23 Star_fullStar_fullStar_fullStar_fullStar_full

You can't do ||= in JavaScript

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
    Q("#toggler").click(function() {
        var mode = this.mode;
        this.mode = !mode;
...

JavaScript On Toggle "Check all / Un...

by Tien Dung, October 06, 2008 22:19 Star_fullStar_fullStar_fullStar_full

Use true/false instead of u...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
// Don't know why you need hash > 0 and page.length > 1
// In case you don't need those conditions
var page = document.location.toString().split("#")[1];
...

JavaScript On Small Javascript Code

by Tien Dung, October 06, 2008 04:21 Star_fullStar_fullStar_fullStar_full
5071c5b861341c0dcfcf6ac86327701f Talk

Ruby On Cleaner Ruby

by Tien Dung, September 22, 2008 01:53

@Adam: cool refactoring :D

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
def square(number)
  return number**2
end
...

Ruby On Conditional Assignment

by Tien Dung, September 22, 2008 01:27 Star_fullStar_fullStar_fullStar_fullStar_full

temp variable based version...

5071c5b861341c0dcfcf6ac86327701f Talk

Ruby On Conditional Assignment

by Tien Dung, September 22, 2008 00:01

Hi Daniel, can you ask Marc...

5071c5b861341c0dcfcf6ac86327701f Talk

Ruby On Conditional Assignment

by Tien Dung, September 21, 2008 22:31

Thanks Daniel. I found the ...

5071c5b861341c0dcfcf6ac86327701f Talk

Ruby On Conditional Assignment

by Tien Dung, September 21, 2008 16:19

Don't know who vote 1 star ...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
def square(number)
  return number**2
end
...

Ruby On Conditional Assignment

by Tien Dung, September 21, 2008 15:58 Star_fullStar_fullStar_fullStar_full

Refactor Amos King .max fun...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
def square(number)
  return number**2
end
...

Ruby On Conditional Assignment

by Tien Dung, September 21, 2008 15:43 Star_fullStar_full

I prefer using temp variabl...

5071c5b861341c0dcfcf6ac86327701f Talk

Ruby On require_dependency

by Tien Dung, September 21, 2008 00:13

Thanks for your help guys :...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
def equate(level)
  (level + 300 * (2 ** (level / 7.0))).floor
end
...

Ruby On Cleaner Ruby

by Tien Dung, September 20, 2008 23:57

Man, you made your code ove...

5071c5b861341c0dcfcf6ac86327701f Talk
1
# Duplicated post, please help to delete

Ruby On Cleaner Ruby

by Tien Dung, September 20, 2008 23:34 Star_full
5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
class Listing < ActiveRecord::Base
  require_dependency "listing/property_related"
  require_dependency "listing/price_related"
...

Ruby require_dependency

by Tien Dung, September 18, 2008 01:08, 3 refactorings

Rails require_dependency usage

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
function state_classes(updateall) {
    var value = display.value * 1, tempcolor;
    var element, state, 
...

JavaScript On Color elements by state of ...

by Tien Dung, September 16, 2008 06:44

or using eval(..)

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
function state_classes(updateall) {
    var value = display.value * 1, tempcolor;
    var element, state, states = ["Unknown", "Gas", "Liquid", "Solid"];
...

JavaScript On Color elements by state of ...

by Tien Dung, September 16, 2008 00:52
5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
function saveAndSet(obj, newValues) {
  var oldValues = {};
  for (var p in newValues) 
...

JavaScript On Setting focus after alert

by Tien Dung, August 19, 2008 00:41

Hi Daniel,

I create a sav...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
class UsersController < ApplicationController
  def index
    @users = find_all_and_order_by(params[:order_by])
...

Ruby On showing records in Ascendin...

by Tien Dung, August 06, 2008 14:07

Hi DG,

1) We should not pu...

5071c5b861341c0dcfcf6ac86327701f Talk
1
2
3
4
/**
 * http://www.openjs.com/scripts/events/keyboard_shortcuts/
 * Version : 2.01.B
...

JavaScript On Handling Keyboard Shortcuts...

by Tien Dung, August 06, 2008 07:22

My final attempt :)

5071c5b861341c0dcfcf6ac86327701f Talk
1
times -= events.map(&:datetime)

Ruby On two for loops cleanup?

by Tien Dung, July 31, 2008 02:05

Shortest version :)

5071c5b861341c0dcfcf6ac86327701f Talk