Send this to a friend
a simple sample
1
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 }
for (var i in holder) {
if(typeof(holder[i])=="movieclip" && holder[i]._name.substr(0,4)=="foo_") {
holder[i].removeMovieClip();
}
}
for (var i=0;i<noOfclips;i++) {
var clip=_root["mc"+i];
clip.removeMovieClip();
}
for (var n in this) {
removeMovieClip(this[n]);
}
Send this to a friend
Traduz palavras/frases/textos usando a API do Google, usei aqui http://github.com/rafaelss/shoes-translator
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
require 'rest_client'
require 'json'
require 'cgi'
word = CGI.escape("hello world")
response = RestClient.get "http://ajax.googleapis.com/ajax/services/language/translate?v=1.0&q=#{word}&langpair=en%7Cpt"
json = JSON.parse(response)
status = json['responseStatus']
if status == 200
puts json['responseData']['translatedText']
else
puts "(#{responseStatus}) erro ao traduzir #{word}"
end
Send this to a friend
a “hello world” program in javascript
Send this to a friend
1 ALTER TABLE tablename AUTO_INCREMENT = 1
ALTER TABLE tablename AUTO_INCREMENT = 1
Send this to a friend
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
require "rubygems"
require "activesupport"
require "unicode"
class String
def as_time
str = self.dup
str.downcase!
str.squish!
str = Unicode.normalize_KD(self).gsub(/[^\x00-\x7F]/n,'')
now = Time.now
if str == 'hoje'
Date.today.to_time
elsif str == 'agora'
Time.now
elsif str == 'amanha'
Date.tomorrow.to_time
elsif str == 'ontem'
Date.yesterday.to_time
elsif str == 'anteontem'
2.days.ago
elsif str == 'depois de amanha'
2.days.from_now
elsif str =~ /^proxim[oa] (semana|dia|mes|ano)$/
case $1
when 'semana' then now.next_week
when 'dia' then Date.tomorrow.to_time
when 'mes' then now.next_month
when 'ano' then now.next_year
end
elsif str =~ /^(mes|semana|ano) que vem/
case $1
when 'mes' then now.next_month
when 'semana' then now.next_week
when 'ano' then now.next_year
end
elsif str =~ /^(mes|semana|ano) passad[ao]/
case $1
when 'mes' then now.last_month
when 'semana' then now.beginning_of_week
when 'ano' then now.last_year
end
elsif str =~ /^de (tarde|manha|noite)/
case $1
when 'noite' then now.beginning_of_day + 20.hours
when 'tarde' then now.beginning_of_day + 15.hours
when 'manha' then now.beginning_of_day + 9.hours
end
elsif str =~ /^daqui h?a pouco/
1.hour.from_now
elsif str =~ /^daqui(?: h?a)? ([0-9]+) (dias?|mes(?:es)?|semanas?|anos?|horas?|minutos?)/
num = $1.to_i
interval = $2.gsub(/e?s$/, '')
names = {
'dia' => :day,
'mes' => :month,
'semana' => :week,
'ano' => :year,
'hora' => :hour,
'minuto' => :minute
}
num.send(names[interval]).from_now
end
end
end
Send this to a friend
1 validates_format_of :company_url, :with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?)/
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
validates_format_of :company_url, :with => /((http|https):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?)/
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :on => :create, :message=>"has an invalid format"
validates_format_of :email, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :message => 'email must be valid'
validates_format_of :login, :with => /\w+@\w+\.\w{2}/