you are in: codestackercodes [RSS]

remove all movieclips Delicious Email

a simple sample

show/hide lines
   1  // 3 solutions
   2  
   3  for (var i in holder) {
   4      if(typeof(holder[i])=="movieclip" && holder[i]._name.substr(0,4)=="foo_") {
   5             holder[i].removeMovieClip();
   6      }
   7  }
   8  
   9  for (var i=0;i<noOfclips;i++) {
  10      var clip=_root["mc"+i];
  11      clip.removeMovieClip();
  12  }
  13  
  14  for (var n in this) { 
  15      removeMovieClip(this[n]); 
  16  }
created by anonymous — 04 July 2008 — get a short url — tags: actionscript flash movieclip embed

Traduz textos usando o google Delicious Email

Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator

show/hide lines
   1  require 'rest_client'
   2  require 'json'
   3  require 'cgi'
   4  
   5  word = CGI.escape("hello world")
   6  response = RestClient.get "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{word}&langpair=en%7Cpt"
   7  json = JSON.parse(response)
   8  status = json['responseStatus']
   9  if status == 200
  10      puts json['responseData']['translatedText']
  11  else
  12      puts "(#{responseStatus}) erro ao traduzir #{word}"
  13  end
created by rafaess — 03 July 2008 — get a short url — tags: api google json rest ruby tradutor embed

"hello world" Delicious Email

a “hello world” program in javascript

show/hide lines
   1  alert("hello world")
created by anonymous — 02 July 2008 — get a short url — tags: helloworld embed

resets autoincrement (mysql) Delicious Email

show/hide lines
   1  ALTER TABLE tablename AUTO_INCREMENT = 1
created by leozera — 02 July 2008 — get a short url — tags: mysql sql embed

Chronic-like in Portuguese Delicious Email

show/hide lines
   1  require "rubygems"
   2  require "activesupport"
   3  require "unicode"
   4  
   5  class String
   6    def as_time
   7      str = self.dup
   8      str.downcase!
   9      str.squish!
  10      str = Unicode.normalize_KD(self).gsub(/[^\x00-\x7F]/n,'')
  11      
  12      now = Time.now
  13  
  14      if str == 'hoje'
  15        Date.today.to_time
  16      elsif str == 'agora'
  17        Time.now
  18      elsif str == 'amanha'
  19        Date.tomorrow.to_time
  20      elsif str == 'ontem'
  21        Date.yesterday.to_time
  22      elsif str == 'anteontem'
  23        2.days.ago
  24      elsif str == 'depois de amanha'
  25        2.days.from_now
  26      elsif str =~ /^proxim[oa] (semana|dia|mes|ano)$/
  27        case $1
  28          when 'semana' then now.next_week
  29          when 'dia' then Date.tomorrow.to_time
  30          when 'mes' then now.next_month
  31          when 'ano' then now.next_year
  32        end
  33      elsif str =~ /^(mes|semana|ano) que vem/
  34        case $1
  35          when 'mes' then now.next_month
  36          when 'semana' then now.next_week
  37          when 'ano' then now.next_year
  38        end
  39      elsif str =~ /^(mes|semana|ano) passad[ao]/
  40        case $1
  41          when 'mes' then now.last_month
  42          when 'semana' then now.beginning_of_week
  43          when 'ano' then now.last_year
  44        end
  45      elsif str =~ /^de (tarde|manha|noite)/
  46        case $1
  47          when 'noite' then now.beginning_of_day + 20.hours
  48          when 'tarde' then now.beginning_of_day + 15.hours
  49          when 'manha' then now.beginning_of_day + 9.hours
  50        end
  51      elsif str =~ /^daqui h?a pouco/
  52        1.hour.from_now
  53      elsif str =~ /^daqui(?: h?a)? ([0-9]+) (dias?|mes(?:es)?|semanas?|anos?|horas?|minutos?)/
  54        num = $1.to_i
  55        interval = $2.gsub(/e?s$/, '')
  56  
  57        names = {
  58          'dia' => :day,
  59          'mes' => :month,
  60          'semana' => :week,
  61          'ano' => :year,
  62          'hora' => :hour,
  63          'minuto' => :minute
  64        }
  65        
  66        num.send(names[interval]).from_now
  67      end
  68    end
  69  end
created by fnando — 02 July 2008 — get a short url — tags: activesupport chronic date normalization time embed

validation sample Delicious Email

show/hide lines
   1  validates_format_of :company_url, :with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?)/ # valida URL
   2  validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :on => :create, :message=>"has an invalid format" 
   3  validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => 'email must be valid'
   4  validates_format_of :login, :with => /\w+@\w+\.\w{2}/
   5  
created by anonymous — 17 June 2008 — get a short url — tags: rails regex validation embed
Displaying records 181 - 186 of 186