Skip to content

Instantly share code, notes, and snippets.

View rjmccallumbigl's full-sized avatar
🌞

Ryan McCallum rjmccallumbigl

🌞
View GitHub Profile
// Bonfire: Find the Longest Word in a String
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-find-the-longest-word-in-a-string?solution=function%20findLongestWord(str)%20%7B%0A%20%20%0A%20%20var%20myArray%20%3D%20str.split(%22%20%22)%3B%0A%20%20var%20long%20%3D%200%3B%0A%20%20%0A%20%20%2F%2Freturn%20myArray%5B0%5D%3B%0A%20%20%0A%20%20for%20(var%20i%20%3D%200%3B%20i%20%3C%20myArray.length%3B%20i%2B%2B)%7B%0A%20%20%20%20%0A%20%20%20%20if%20(myArray%5Bi%5D.length%20%3E%20long)%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20long%20%3D%20myArray%5Bi%5D.length%3B%0A%20%20%20%20%20%20%0A%20%20%20%20%7D%0A%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20%2F%2Freturn%20str.length%3B%0A%20%20return%20long%3B%0A%7D%0A%0AfindLongestWord(%22What%20if%20we%20try%20a%20super-long%20word%20such%20as%20otorhinolaryngology%22)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function findLongestWord(str) {
var myArray = str.split(" ");
var long = 0;
// Bonfire: Return Largest Numbers in Arrays
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-return-largest-numbers-in-arrays?solution=function%20largestOfFour(arr)%20%7B%0A%20%20%2F%2F%20You%20can%20do%20this!%0A%20%20%0A%20%20var%20array%20%3D%20%5B%5D%3B%0A%20%20var%20i%20%3D%200%3B%0A%20%20var%20j%20%3D%200%3B%0A%20%20var%20x%20%3D%200%3B%0A%20%20var%20y%20%3D%200%3B%0A%20%20%0A%20%20%2F%2Freturn%20arr%3B%0A%20%20%0A%20%20for%20(i%20%3D%200%3B%20i%20%3C%204%3B%20i%2B%2B)%7B%0A%20%20%20%20%0A%20%20%20%20x%20%3D%200%3B%0A%20%20%20%20%0A%20%20%20%20for%20(j%20%3D%200%3B%20j%20%3C%204%3B%20j%2B%2B)%7B%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20if%20(arr%5Bi%5D%5Bj%5D%20%3E%20x)%7B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20x%20%3D%20arr%5Bi%5D%5Bj%5D%3B%20%0A%20%20%20%20%0A%20%20%20%20%20%20%20%20%2F%2Freturn%20x%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%0A%20%20%20%20%20%20array%5Bi%5D%20%3D%20x%3B%0A%
// Bonfire: Confirm the Ending
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-confirm-the-ending?solution=function%20end(str%2C%20target)%20%7B%0A%20%20%2F%2F%20%22Never%20give%20up%20and%20good%20luck%20will%20find%20you.%22%0A%20%20%2F%2F%20--%20Falcor%0A%20%20%0A%20%20var%20splitArray%20%3D%20str.split(%22%22)%3B%20%20%0A%20%20var%20i%20%3D%200%3B%0A%20%20%0A%20%20var%20sub%20%3D%20str.substr(-target.length)%3B%0A%20%20%0A%20%20%2F%2Freturn%20the%20bool%20if%20last%20char%20matches%20or%20not%0A%20%20%2F*if%20(splitArray%5BsplitArray.length-1%5D%20%3D%3D%20target)%7B%0A%20%20%20%20%0A%20%20%20%20return%20true%3B%0A%20%20%20%20%0A%20%20%7D%20*%2F%0A%20%20%0A%20%20%2F%2Freturn%20splitArray%5BsplitArray.length-1%5D%3B%0A%20%20%0A%20%20%0A%20%20if%20(sub%20%3D%3D%20target)%20%7B%0A%20%20%20%20%0A%20%20%20%20return%20true%3B%0A%20%20%20%20%0A%20%20%7D%20else%20%7B%0A%20%20%20%20%0A%20%20%20%20return%20false%3B%0A%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20%0A%20%20%0A%20%2
// Bonfire: Repeat a string repeat a string
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-repeat-a-string-repeat-a-string?solution=function%20repeat(str%2C%20num)%20%7B%0A%20%20%2F%2F%20repeat%20after%20me%0A%20%20%0A%20%20var%20i%20%3D%200%3B%0A%20%20var%20sentence%20%3D%20%22%22%3B%0A%20%20%0A%20%20while%20(i%20%3C%20num)%7B%0A%20%20%20%20%0A%20%20%20%20sentence%20%3D%20sentence.concat(str)%3B%0A%20%20%20%20i%2B%2B%3B%0A%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20return%20sentence%3B%0A%7D%0A%0Arepeat(%22abc%22%2C%203)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function repeat(str, num) {
// repeat after me
var i = 0;
var sentence = "";
// Bonfire: Truncate a string
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-truncate-a-string?solution=function%20truncate(str%2C%20num)%20%7B%0A%20%20%2F%2F%20Clear%20out%20that%20junk%20in%20your%20trunk%0A%20%20%0A%20%20var%20short%20%3D%20str%3B%0A%20%20var%20fromEnd%20%3D%200%3B%0A%20%20%0A%20%20%2F%2Freturn%20result%20if%20shorter%0A%20%20if%20(short.length%20%3C%20num)%7B%0A%20%20%20%20%0A%20%20%20%20return%20short%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20%2F%2Freturn%20result%20if%20shorter%20than%203%20characters%0A%20%20%0A%20%20if%20(short.length%20%3C%3D%203)%7B%0A%20%20%20%20%0A%20%20%20%20short%20%3D%20str.slice(0%2C%20num)%3B%0A%20%20%20%20short%20%3D%20short.concat(%22...%22)%3B%0A%20%20%20%20return%20short%3B%0A%20%20%20%20%20%20%20%20%0A%20%20%7D%0A%20%20%0A%20%20%2F%2Fshorten%20string%20to%20n%20number%20of%20characters%0A%20%20if%20(short.length%20%3E%20num)%7B%0A%20%20%20%20%0A%20%20%20%20%2F%2Ffind%20out%20if%20we%20need%20to%20
// Bonfire: Slasher Flick
// Author: @rjmccallumbigl
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick?solution=function%20slasher(arr%2C%20howMany)%20%7B%0A%20%20%2F%2F%20it%20doesn%27t%20always%20pay%20to%20be%20first%0A%20%20%0A%20%20var%20removed%3B%0A%20%20%0A%20%20removed%20%3D%20arr.splice(0%2C%20howMany)%3B%0A%20%20%0A%20%20return%20arr%3B%0A%7D%0A%0Aslasher(%5B1%2C%202%2C%203%5D%2C%202)%3B%0A
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
// it doesn't always pay to be first
var removed;
@Bajena
Bajena / Oauth.gs
Created June 23, 2018 19:16
Google script functions for performing simple Spotify Oauth flow
var oauth = {};
/** @const */
oauth.OAUTH_CLIENT_ID = 'OAUTH_CLIENT_ID';
/** @const */
oauth.OAUTH_CLIENT_SECRET = 'OAUTH_CLIENT_SECRET';
/**
* This builds an OAuth2 service for connecting to Spotify
@LindaLawton
LindaLawton / GmailSendMail.psi
Last active December 6, 2021 05:18
Step by step guild to using power shell to get a Google access token.
clear-host;
#Remove-Variable * -ErrorAction SilentlyContinue
#get-item Variable:*
#Get-Variable | Select-Object -ExpandProperty Name
. C:\Users\linda_l\Desktop\PowerShell\GoogleOauth.ps1
Add-Type -Path "C:\Users\linda_l\Documents\visual studio 2015\Projects\TestingLibrary\packages\AE.Net.Mail.1.7.10.0\lib\net45\AE.Net.Mail.dll"
Add-Type -AssemblyName System.IO
Add-Type -AssemblyName System.Text.Encoding
@tanaikech
tanaikech / submit.md
Last active August 12, 2022 06:31
Report: Documentation Comments including JsDoc for Functions of Google Apps Script

Report: Documentation Comments including JsDoc for Functions of Google Apps Script

This is a report for the documentation comments for the functions of Google Apps Script.

When the documentation comments for functions of Google Apps Script are considered, you will think JsDoc. At Google Apps Script, a part of JsDoc can be used. But, in this report, I would like to introduce the documentation comments including JsDoc.

Sample situations

Sample 1

@alexjebens
alexjebens / ghost-network-adapters-devcon.ps1
Last active September 2, 2022 17:33
Removing Ghost Network Adapters with Windows SDK devcon.exe
param(
# Path to devcon.exe
[string]$devconPath = "C:\Program Files (x86)\Windows Kits\8.0\Tools\x64\devcon.exe"
)
<#
.Synopsis
Helper function to seperate devcon output between device id and name
#>
function Convert-ToDevice {
[CmdletBinding()]