Skip to content

Instantly share code, notes, and snippets.

View b-bot's full-sized avatar

b-bot

View GitHub Profile
@b-bot
b-bot / FizzBuzz.js
Created July 25, 2019 08:12
The solution to the basic "FizzBuzz" test used in first time interviews.
for (var i=1; i <= 100; i++) {
if (i % 15 == 0)
console.log("FizzBuzz");
else if (i % 3 == 0)
console.log("Fizz");
else if (i % 5 == 0)
console.log("Buzz");
else
console.log(i);
@b-bot
b-bot / Romanizer.js
Created July 25, 2019 08:09
Function to convert any number to roman numerals. eg. 10 = X
var numeralCodes = [["","I","II","III","IV","V","VI","VII","VIII","IX"], // Ones
["","X","XX","XXX", "XL", "L", "LX", "LXX", "LXXX", "XC"], // Tens
["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM"]]; // Hundreds
function convert(num) {
var numeral = "";
var digits = num.toString().split('').reverse();
for (var i=0; i < digits.length; i++){
numeral = numeralCodes[i][parseInt(digits[i])] + numeral;
}
@b-bot
b-bot / ordinalSuffix.js
Last active July 25, 2019 08:06
Get the ordinal suffix for any number you want converted to a day. ie. suffixes -st, -nd, -rd, -th in written ordinals (represented as 1st, 2nd, 3rd, 4th)
function ordinalSuffix(i) {
const j = i % 10,
k = i % 100;
if (j === 1 && k !== 11) {
return i + 'st';
}
if (j === 2 && k !== 12) {
return i + 'nd';
}
if (j === 3 && k !== 13) {
@b-bot
b-bot / Hacked Smoothscroll in JQuery.js
Created July 25, 2019 07:40
A quick and dirty way to add smoothscroll to all hashlinks in your file without adding additional dependancies.
$('a[href*="#"]:not([href="#"], [href="#carousel"])')
.click(function() {
if (location.pathname.replace(/^\//, '') ===
this.pathname.replace(/^\//, '') &&
location.hostname === this.hostname) {
var target = $(this.hash);
target = target.length ? target :
$('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
$ brew install putty
Place the two keys in the .ssh folder in the user directory.
Now convert the PPK keys to SSH keypairs
$ cd ~/.ssh
Private key generation:
$ puttygen id_rsa.ppk -O private-openssh -o id_rsa