This file contains hidden or 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 saws() { | |
| AWS_CONFIG_FILE="$HOME/.aws/config" | |
| if [ ! -f "$AWS_CONFIG_FILE" ]; then | |
| echo "AWS config file not found: $AWS_CONFIG_FILE" | |
| return 1 | |
| fi | |
| local profile="$1" |
This file contains hidden or 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
| import { useState, useEffect, FunctionComponent } from 'react'; | |
| import { Page, GlobalLoader, SkeletonLoader, ProjectCard, RequestError } from './component'; | |
| import useAxios from '../helper/api'; | |
| const Dashboard: FunctionComponent = () => { | |
| const [projects, setProject] = useState(); | |
| const axios = useAxios(); | |
| const getProjects = () => | |
| axios.get('/projects/', { |
This file contains hidden or 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 benchmark | |
| start_time = Time.now | |
| yield | |
| end_time = Time.now | |
| end_time - start_time | |
| end | |
| # Be careful, pasting this into IRB will take a long time to print. | |
| # It's a loooong string. :) | |
| # long_string = "apple"*100000000 |
This file contains hidden or 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 destroy_message(string) | |
| #TODO: return the part a string without the message | |
| string.sub(/(.*:).*/,"\\1") | |
| end | |
| def destroy_message!(string) | |
| #TODO: remove the message from string destructively! | |
| string.sub!(/(.*:).*/,"\\1") | |
| end |
This file contains hidden or 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 to_pig_latin(word) | |
| word.sub(/([^aeiou]+)([aeiou]*\S*)/, "\\2\\1ay") | |
| end | |
| def to_pig_latin_sentence(sentence) | |
| words = sentence.split(" ") | |
| count = 0 | |
| words.map! do |word| | |
| count += 1 unless to_pig_latin(word) == word | |
| to_pig_latin(word) |
This file contains hidden or 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
| # Determine whether a string contains a Social Security number. | |
| def has_ssn?(string) | |
| !!(/.*\d{3}-\d{2}-\d{4}/ =~ string) | |
| end | |
| puts "has_ssn? returns true if it has what looks like a SSN" | |
| puts has_ssn?("please don't share this: 234-60-1422") == true | |
| puts "has_ssn? returns false if it doesn't have a SSN" | |
| puts has_ssn?("please confirm your identity: XXX-XX-1422") == false |
This file contains hidden or 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 shuffle(array) | |
| # Implement the shuffle method | |
| for i in 0..(array.length - 1) | |
| j = rand(i) | |
| array[j], array[i] = array[i], array[j] | |
| end | |
| array | |
| end | |
This file contains hidden or 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
| # TODO: Print the elements at indices 1, 3, 5, 7, etc. on separate lines. | |
| # You should make use of Enumerable#each_with_index | |
| def print_odd_indexed_integers(array) | |
| array.each_with_index do |value, index| | |
| puts value if index % 2 != 0 | |
| end | |
| end | |
| # TODO: Return the odd numbers from a list of integers. | |
| # You should make use of Enumerable#select |