Skip to content

Instantly share code, notes, and snippets.

@tiagodealmeida
tiagodealmeida / firstRepeatingLetter.js
Created April 19, 2017 11:50
firstRepeatingLetter function code challenge
var str = 'tyiyrHFTH';
function firstRepeatingLetter(string) {
var exp = /(.).*(\1)/g;
var res = exp.exec(string);
return res ? res[1] : string.length ? string[0] : null;
}
console.info(firstRepeatingLetter(str));
@tiagodealmeida
tiagodealmeida / fizzBuzz.js
Created April 19, 2017 11:45
fizzBuzz function code challenge
for (var i = 1; i <= 15; i++) {
if (i % 3 === 0 && i % 5 === 0) {
console.log("FizzBuzz");
}
else if (i % 3 === 0) {
console.log("Fizz");
}
else if (i % 5 === 0) {
console.log("Buzz");
}
@tiagodealmeida
tiagodealmeida / countries.json
Created February 10, 2017 16:59
List of countries with country code, name, currency code, population, capital and continent name in JSON format
{
"countries": {
"country": [
{
"countryCode": "AD",
"countryName": "Andorra",
"currencyCode": "EUR",
"population": "84000",
"capital": "Andorra la Vella",
"continentName": "Europe"
@tiagodealmeida
tiagodealmeida / cat.rb
Created November 1, 2016 16:29
task 3.5
class Pet
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
@tiagodealmeida
tiagodealmeida / cat.rb
Created October 31, 2016 16:28
task 3.4
class Cat
attr_reader :color, :breed
attr_accessor :name
def initialize(color, breed)
@color = color
@breed = breed
@hungry = true
end
def fav_foods
food_array = []
3.times do
puts "Name a favorite food."
food_array << gets.chomp
end
puts "You favorite foods are #{food_array.join(", ")}."
p food_array
food_array.each do |food|
puts "I like #{food} too!"
if (5+5==10)
puts "this is true"
else
puts "this is false"
end
@tiagodealmeida
tiagodealmeida / program.rb
Last active October 29, 2016 19:35
ruby for task 3.1
def greeting(name)
puts "Please enter your name:"
name = gets.chomp
puts "Hello" + " " + name
end
greeting("Tiago")
@tiagodealmeida
tiagodealmeida / work.js
Last active October 28, 2016 10:55
.js work for task 2.10
//work page
var works = [
{
title: "Your next project featured here",
pic: "img/screenshot_future.jpg",
url: "#contact",
text_color: "blue",
},
{
@tiagodealmeida
tiagodealmeida / index.html
Last active November 2, 2016 20:29
HTML for task 2.11
//twitter
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p =
/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js =
d.createElement(s);js.id=id;js.src=p+
'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore
(js,fjs);}}(document, 'script', 'twitter-wjs');
//facebook