This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//remove n number of elements from an array, largest to smallest | |
function removeLargest(arr,n){ | |
for (var i = 0; i < n; i ++){ | |
var sorted = Math.max.apply(null, arr); | |
//run through array, funding largest | |
var rem = arr.splice(arr.indexOf(sorted),1); | |
//remove largest | |
} console.log(arr); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function add(arr){ | |
sum = 0 | |
arr.forEach(function(num){ | |
sum += num; | |
}); console.log(sum); | |
} | |
add([1,2,3,4,5]) | |
add([-1,0,2]) | |
add([3,3,3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#A command-line app that suggests fresh foods | |
#based on user's location and the current month. | |
#The app automatically retrieves date and asks | |
#user for their region in the continental US. | |
#Ideas for expansion and improvements: | |
#allow user to choose alternate date, | |
#sort results by fruit and veg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cd /Users/rachel/dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def image_list(file_path) | |
puts Dir.entries(file_path) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def emoji_finder(file_path) | |
Dir.foreach(file_path) {|pic| | |
if pic[-3..-1] == 'png' | |
puts pic | |
end | |
} | |
end | |
emoji_finder('/Users/rachel/dev/EmojiFinder/ProfileImages') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
searchURL = "https://api.spotify.com/v1/search?q=#{artist_name}&type=artist" | |
response = RestClient.get(searchURL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@artist_data = JSON.parse(response)["artists"]["items"][0] | |
top_tracks_url = "https://api.spotify.com/v1/artists/#{@artist_data["id"]}/top-tracks?country=US" | |
top_tracks_results = JSON.parse(RestClient.get(top_tracks_url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client_token = Base64.strict_encode64("#{ENV['spotify_id']}:#{ENV['spotify_secret']}") | |
spotify_token = RestClient.post("https://accounts.spotify.com/api/token",{"grant_type": "client_credentials"}, {"Authorization": "Basic #{client_token}"}) | |
parsed_token = JSON.parse(spotify_token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tracks = RestClient.get(query_url, {"Authorization": "Bearer #{parsed_token["access_token"]}"}) | |
parsed_tracks = JSON.parse(tracks) |
OlderNewer