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
#create an encryption algorithm (steps to mask a word) | |
encryption = {"a"=>"c", "b"=>"d", "c"=>"e", "d"=>"f", "e"=>"g", | |
"f"=>"h", "g"=>"i", "h"=>"j", "i"=>"k", "j"=>"l", | |
"k"=>"m", "l"=>"n", "m"=>"o", "n"=>"p", "o"=>"q", | |
"p"=>"r", "q"=>"s", "r"=>"t", "s"=>"u", "t"=>"v", | |
"u"=>"w", "v"=>"x", "w"=>"y", "x"=>"z", "y"=>"a", "z"=>"b"} | |
decryption = encryption.invert | |
#ask the user for a word |
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
# Step 1: Working with Arrays and Hashes | |
# Copy your solution from ex_teddit_conditional.rb in 02_Variables_Conditionals | |
# Create an empty stories array. This will be used to hold all stories we capture. | |
# Users enter the story as they do now, but it gets put in a hash instead. | |
# Update any reference to the story (upvotes, category and title) |
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
# We're going to add a remote data source to pull in stories from Mashable and Digg. | |
# http://mashable.com/stories.json | |
# http://digg.com/api/news/popular.json | |
# These stories will also be upvoted based on our rules. No more user input! | |
# Pull the json, parse it and then make a new story hash out of each story(Title, Category, Upvotes) | |
# Add each story to an array and display your "Front page" | |
require 'rest-client' | |
require 'json' |
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
=begin | |
Instructions | |
============ | |
1. Copy the code here: http://bit.ly/SLB5Ah | |
2. Fix it. | |
3. Make up your own city names using an array called 'cities'. | |
4. Print the length of the characters of each person's name. | |
5. Ask the user for their name and where they are from. | |
6. Your final output should look like the following: |
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
<!doctype html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Example of Markup using AMCSS</title> | |
</head> | |
<body> | |
<!-- Example Template --> | |
<div namespace-Module-Component="region section/layout style" id="specific-name"> | |
<p>content</p> |
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"=>"c", "b"=>"d", "c"=>"e", "d"=>"f", "e"=>"g", | |
"f"=>"h", "g"=>"i", "h"=>"j", "i"=>"k", "j"=>"l", | |
"k"=>"m", "l"=>"n", "m"=>"o", "n"=>"p", "o"=>"q", | |
"p"=>"r", "q"=>"s", "r"=>"t", "s"=>"u", "t"=>"v", | |
"u"=>"w", "v"=>"x", "w"=>"y", "x"=>"z", "y"=>"a", "z"=>"b"} |
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
const generateId = () => Math.floor(Math.random() * Date.now()) | |
/* | |
* This function accepts an array of objects as its only argument. It will use the keys | |
* from the first object (not recursively) to create the header row of the .csv file. | |
* | |
* Returns: a formatted string, which can be fed directly into `downloadFile()` | |
*/ | |
const convertToCSV = (data = []) => { | |
let csvContent = 'data:text/csv;charset=utf-8,' |
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
const isLocal = process.env.ENV === 'dev'; | |
const isTest = process.env.ENV === 'test'; | |
const isProd = process.env.ENV === 'prod'; | |
const featureFlags = { | |
NewCampaignEdit: () => !isProd, | |
}; | |
const isFeatureEnabled = (name = '') => | |
{}.hasOwnProperty(featureFlags, name) && featureFlags[name](); |
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
import { useCallback, useEffect } from 'react'; | |
export type MediaQuery = MediaQueryListEvent['media']; | |
export type MediaQueryCallback = (event: MediaQueryListEvent) => void; | |
export function useMediaQuery(mediaQuery: MediaQuery, callback: MediaQueryCallback) { | |
const handleMediaQuery = useCallback((event: MediaQueryListEvent) => { | |
if (event.media === mediaQuery) { | |
callback(event); | |
} |