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
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |
android:shape="rectangle" android:padding="0dp"> | |
<solid android:color="#E0E0E0"/> | |
<corners | |
android:bottomRightRadius="16dp" | |
android:bottomLeftRadius="16dp" | |
android:topLeftRadius="16dp" | |
android:topRightRadius="16dp"/> | |
</shape> |
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
<vector xmlns:android="http://schemas.android.com/apk/res/android" | |
android:height="24dp" | |
android:width="24dp" | |
android:viewportWidth="24" | |
android:viewportHeight="24"> | |
<path android:fillColor="#98000000" android:pathData="M12,2C17.53,2 22,6.47 22,12C22,17.53 17.53,22 12,22C6.47,22 2,17.53 2,12C2,6.47 6.47,2 12,2M15.59,7L12,10.59L8.41,7L7,8.41L10.59,12L7,15.59L8.41,17L12,13.41L15.59,17L17,15.59L13.41,12L17,8.41L15.59,7Z" /> | |
</vector> |
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 startServer() { | |
loadValidWords(function() { | |
console.log("Available words: " + words.length); | |
var newURL = shortenURL("https://medium.com/365-days-of-coding"); | |
console.log("New URL: " + newURL); | |
var oldURL = getURLFromShortened(newURL); | |
console.log("Old URL: " + oldURL); | |
removeShortenedURL(newURL); |
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
/** | |
* Deletes the shortened URL record associated with the given shortenedURL, | |
* returning the short URL word used back to the word pool. | |
* shortenedURL - A shortened URL generated by this program instance | |
*/ | |
function removeShortenedURL(shortenedURL) { | |
var word = shortenedURL.replace(baseDomain, ""); | |
delete urlDictionary[word]; | |
words.push(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
/** | |
* Returns the saved URL given the shortened URL (generated by this program) | |
* shortenedURL - A shortened URL generated by this program instance | |
*/ | |
function getURLFromShortened(shortenedURL) { | |
return urlDictionary[shortenedURL.replace(baseDomain, "")]; | |
} |
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
// Predefined constants | |
const baseDomain = "https://mywebsite.com/" | |
// Cached global variables | |
var urlDictionary = {} | |
/** | |
* Returns a shortened version of the given `url`, which is saved for later | |
* retrieval. | |
* url - The url to shorten |
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
// Predefined constants | |
const wordFilePath = "resources/google-10000-english-usa-no-swears.txt"; | |
const minWordLength = 3; | |
const maxWordLength = 6; | |
// Cached global variables | |
var words = [] | |
/** | |
* Loads a list of words from the file at `wordFilePath`, which should contain |
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
// Module dependencies | |
const fs = require('fs'); // Used for opening the word file | |
const lineReader = require('readline'); // Used for buffering the file line by line |
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
var result = document.evaluate("//text()", document.body, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = 0; i < result.snapshotLength; ++i) { | |
var node = result.snapshotItem(i); | |
if ((node.textContent+"").match(/\w/)&&node.parentNode.nodeName != "STYLE") { | |
node.textContent = node.textContent.replace(/[A-Z0-9]/g, "X").replace(/[a-z]/g, "x"); | |
} | |
} | |
void 0 |
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
data = [ 2, 4, 6 ] | |
total = 0 | |
average = 0 | |
n = 0 | |
for value in data: | |
n += 1 | |
total += value | |
average = total / n | |
print "average:", average |