Here are some Javascript hints/tips that i have come across when learning to program Javascript and i thought to share them with you.
Small little javascript snippets that will enhance your big Javascript applications as a Javascript programmer.
Javascript Code example 1)...
const isUpperCase = str => str === str.toUpperCase();
console.log(isUppercase("string")); //false
console.log(isUppercase("STRING")); //true
console.log(isUppercase("5TR1NG")); //true
Javascript Code example 2)...
const differenceInArrays = (array1, array2) => {
const set = new Set(array2);
return array1.filter(x => !set.has(x));
};
differenceInArrays(["apple", "orange", "grape"], ["apple", "orange", "pear"]);
// ["grape"]
differenceInArrays([8, 13, 7],[ 25, 8, 9]);
// [13, 7]
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Javascript Code example 3)...
const scrollToTopOfPage = ( ) => {
const c = document.documentElement.scrollTop | | document.body.scrollTop;
if (c > 0 {
window.requestAnimationFrame(scrollToTop);
window.scrollTop(0, c - c / 8);
}
};
scrollToTopOfPage();
Here are some Linux hints/tips that i have come across when learning to use Linux and i thought to share them with you.
These small little Linux command snippets that will enhance your use of the Linux command set.
If you are unsure of the Linux Command you want to use or the options it offers, typing man then the command displays a manual for that command within Linux itself
root@fmssltd:~/home/user$ man ls
User Commands
NAME
ls - list directory contents
SYNOPSIS
ls [OPTION]... [FILE]...
DESCRIPTION
List information about the FILEs (the current directory by default). Sort entries alphabetically if none of -cftuvSUX nor --sort is specified.
Don't know where you are in the Linux directory structure typing pwd
displays the current working directory for you.root@fmssltd:~/home/user$ pwd
/home/user/desktop/pictures
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Want to know what files or directories are in the directory you are in, typing ls, displays a list of files & directories for you.
root@fmssltd:~/home/user$ ls
Holidays Kids adam.jpg ben.jpg
Holidays & Kids = directories. adam.jpg & ben.jpg = jpeg images.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
You want to work in another directory, just typing cd with a directory after it, moves you to that directory. If the directory does not exist first check for a misspelling or use the ls command.
root@fmssltd:~/home/user$ cd Holidays
root@fmssltd:~/home/user/Holidays$
Here are some Python hints/tips that i have come across when learning to program Python and i thought to share them with you.
These small little Python code snippets that will enhance your bigger Python applications as you grow as a Python programmer.
Python Code example 1)...
stringtolist.py
print("Enter a string of data?")
my_list = list(map(int, input().split()))
print(my_list)
Python 3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 18:49:57)
Type "help", "copyright", "credits" or "license()" for more information.
>>>
Enter a string of data?
10 20 30 40 50
[10, 20, 30, 40, 50]
>>>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python Code example 2)...
The following example summarises the ‘f’ string formatting option in Python 3.
Since Python 3.0, the format() function was introduced to provide advance formatting options.
Python f-strings are available since Python 3.6. The string has the f prefix and uses { } to evaluate variables.
format_string.py
name = ‘Andrew’
age = 51
print (f'{name} is {age} years old')
Python 3.7.5 (v3.7.5:5c02a39a0b, Oct 14 2019, 18:49:57)
Type "help", "copyright", "credits" or "license()" for more information.
>>>$ python format_string.py
Andrew is 51 years old
>>>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python Code example 3)...
Here are some Python hints/tips that i have come across when learning to program Python and i thought to share them with you.
These small little Python code snippets that will enhance your bigger Python applications as you grow as a Python programmer.
Python Code example 1)...
listcombine.py
# zip() function takes two equal length lists and mergers them together in pairs
list1 = [1,3,5,7]
list2 = [2,4,5,6]
for a, b in zip(list1,list2):
print (a, b)
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
Type "help", "copyright", "credits" or "license()" for more information.
>>>$ python listcombine.py
1 2
3 4
5 5
7 6
>>>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python Code example 2)...
listgroups.py
mylist = [‘Moon’, ‘Trees’, ‘Monkeys’, ‘Humans’, ‘Black’, ‘White’]
groups = list(zip(*[iter(mylist)]*2))
print (groups)
Python 3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)
Type "help", "copyright", "credits" or "license()" for more information.
>>>$ python listgroups.py
[('Moon', 'Trees'), ('Monkeys', 'Humans'), ('Black', 'White')]
>>>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Python Code example 3)...
These hints and tips are the accumulation of many years experience of dealing with the general public and business IT equipment user's.
They have been written to be easy to understand and break down the jargon that is indoctrinated in IT equipment article's, book's and publication's.
I hope you enjoy these hints and tips and find them useful.
Provides Help to common computer/tablet and web problems.