View request-mastodon-oauth.js
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
// routes/oauth/mastodon.js | |
const request = require('request'); | |
const authorize = (req) => { | |
// The authorization code returned from Mastodon on a successful login | |
const { code } = req.query; | |
console.log('(1) AUTHORIZATION CODE:', code); | |
// Token endpoint |
View mastodon-auth0.js
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(accessToken, ctx, cb) { | |
request.get( | |
'https://[MASTODON INSTANCE URL]/api/v1/accounts/verify_credentials', { | |
headers: { | |
'Authorization': `Bearer ${accessToken}` | |
} | |
}, | |
function(err, res, body) { | |
if (err) { | |
return cb(err); |
View caesars-cipher.js
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 rot13(str) { | |
// LBH QVQ VG! | |
//translate each letter of the string into unicode and push them to an array | |
var uniArr = []; | |
for (j = 0; j < str.length; j++) { | |
uniArr.push(str.charCodeAt(j)); | |
} | |
//add or subtract 13 letters or do nothing, depending on where the initial value falls in the ISO Latin-1 table |
View index.html
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"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> |
View fibonacci_number.js
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
// Fibonacci Number | |
// Objective: Find the n-Fibonacci number, | |
// the nth term of the Fibonacci Sequence, | |
// often denoted by F(n) | |
// For example, given the Fibonacci Sequence: | |
// 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377... | |
// F(8) = 21 | |
// F(20) = 6765 |
View merge_sort.js
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
/* Like quick sort, merge sort also uses a divide-and-conquer, | |
* recursive methodology to sort an array. It takes advantage | |
* of the fact that it is relatively easy to merge two arrays | |
* in sorted order as long as each is sorted in the first place. | |
* 1) Recursively split the input array in half until a sub-array | |
* with only one element is produced. | |
* 2) Merge each sorted sub-array together to produce the final | |
* sorted array. | |
*/ |
View quick_sort.js
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
/* Quick sort is an efficient, recursive divide-and-conquer | |
* approach to sorting an array. In this method, a pivot value | |
* is chosen in the original array. The array is then | |
* partitioned into two subarrays of values less than and | |
* greater than the pivot value. We then combine the result of | |
* recursively calling the quick sort algorithm on both | |
* sub-arrays. This continues until the base case of an empty | |
* or single-item array is reached, which we return. The | |
* unwinding of the recursive calls return us the sorted array. | |
*/ |
View selection_sort.js
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
/* Selection sort works by selecting the minimum value in a list | |
* and swapping it with the first value in the list. It then | |
* starts at the second position, selects the smallest value in | |
* the remaining list, and swaps it with the second element. It | |
* continues iterating through the list and swapping elements | |
* until it reaches the end of the list. | |
*/ | |
// METHOD 1: Using 2 `for` loops (ES5) | |
function selectionSort(array) { |
View bubble_sort.js
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
/* The bubble sort method starts at the beginning of | |
* an unsorted array and 'bubbles up' unsorted values | |
* towards the end, iterating through the array until | |
* it is completely sorted. It does this by comparing | |
* adjacent items and swapping them if they are out | |
* of order. The method continues looping through the | |
* array until no swaps occur, at which point the | |
* array is sorted. | |
*/ |
View insertion_sort.js
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
/* This method works by building up a sorted array at the beginning of | |
* the list. It begins the sorted array with the first element. Then it | |
* inspects the next element and swaps it backwards into the sorted | |
* array until it is in sorted position. It continues iterating through | |
* the list and swapping new items backwards into the sorted portion | |
* until it reaches the end. | |
*/ | |
'use strict'; | |
// insert - puts a number in the right spot in an array in ascending order |
NewerOlder