Skip to content

Instantly share code, notes, and snippets.

Ian Adams ian128K

Block or report user

Report or block ian128K

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ian128K
ian128K / firstlettercapitalise.js
Created Oct 2, 2014
Function for capitalising the first letters in a sentence
View firstlettercapitalise.js
function FirstLetterCapitalise(message) {
if((typeof message === "undefined") || (typeof message !== "string")) {
return "You have to pass in a string.";
} else {
var buffer, blength, newbuf, newstr, nblength, char, result;
buffer = message.split(" ");
blength = buffer.length;
result = "";
for(var i = 0; i < blength; i++) {
char = buffer[i].charAt(0);
@ian128K
ian128K / addfrom1tonum.js
Created Oct 2, 2014
Function for adding all numbers from 1 to a given number
View addfrom1tonum.js
function addFromOneToNum(num) {
var output;
output = num;
for(var i = 1; i < num; i++) {
output += i;
}
return output;
}
@ian128K
ian128K / lettershifter.js
Created Oct 2, 2014
Function for shifting all letters in a string one letter forward in the alphabet
View lettershifter.js
function letterShifter(message) {
var lc_alphabet, uc_alphabet, lc_key, uc_key, coded, i, ch, index;
lc_alphabet = "abcdefghijklmnopqrstuvwxyz";
uc_alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
lc_key = "bcdefghijklmnopqrstuvwxyza";
uc_key = "BCDEFGHIJKLMNOPQRSTUVWXYZA";
coded = "";
for(i = 0; i < message.length; i++) {
@ian128K
ian128K / reversestring.js
Created Oct 2, 2014
Function for reversing all the letters in a string
View reversestring.js
function reverseString(str) {
var output;
if((typeof str === "undefined") || (typeof str !== "string")) {
return "You have to pass a string as an argument."
}
output = str.split("").reverse().join("");
return output;
}
@ian128K
ian128K / factorial.js
Created Oct 2, 2014
Function for outputting the factorial of a number
View factorial.js
function factorial(num) {
// If the number is less than 0, reject it.
if (num < 0) {
return "You can't do a factorial on negative numbers.";
}
// If the number is 0, its factorial is 1.
else if (num == 0) {
return 1;
}
var output = num;
@ian128K
ian128K / longestword.js
Created Oct 2, 2014
Function takes an input string and returns the longest word in the string
View longestword.js
function LongestWord(sen) {
if(typeof sen = "undefined") {
return "You have to pass a sentence in as a string.";
} else {
var words = sen.split(" ");
if(words.length = 1) {
return words[0];
} else {
var largest = 0;
var output = "";
@ian128K
ian128K / 1-Original.html
Last active Aug 29, 2015
By viewing the source and just minifying the inline JavaScript in the Opportunity Dashboard view from the mock Salesforce project that comes with the trial of Tableau Online, I was able to cut the file size from 42 KB to 32 KB — a reduction of almost 24%!
View 1-Original.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta name="csrf-param" content="authenticity_token"/>
<meta name="csrf-token" content="xpGnHlrBwMt4Sski2rk7xIKRT50B4KgNYXmlk3FY6wA="/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0" />
<meta http-equiv="Expires" content="Thu, 01 Jan 1970 00:00:00 GMT"/>
View CSS Test-Button.md
@ian128K
ian128K / bash_colours
Last active Jun 17, 2019
Shell script colours
View bash_colours
## Colours and font styles
## Syntax: echo -e "${FOREGROUND_COLOUR}${BACKGROUND_COLOUR}${STYLE}Hello world!${RESET_ALL}"
# Escape sequence and resets
ESC_SEQ="\x1b["
RESET_ALL="${ESC_SEQ}0m"
RESET_BOLD="${ESC_SEQ}21m"
RESET_UL="${ESC_SEQ}24m"
# Foreground colours
You can’t perform that action at this time.