Skip to content

Instantly share code, notes, and snippets.

View CharlesKasasira's full-sized avatar

Charles Kasasira CharlesKasasira

View GitHub Profile

#Linux Cheat Sheet

##File Commands:

  • ls – directory listing
  • ls -al – formatted listing with hidden files
  • cd dir - change directory to dir
  • cd – change to home
  • pwd – show current directory
  • mkdir dir – create a directory dir
  • rm file – delete file
// test = "Buckethead"
// original = "DeathCubeK"
console.log(test.toLowerCase().split('').sort().join('')=== original.toLowerCase().split('').sort().join('')) // true
console.log(test.split('').sort().join('').toLowerCase() === original.split('').sort().join('').toLowerCase()) // false
/**
The order of method chaining matters when the methods being called have side effects or return different results depending on their order.
*/
@CharlesKasasira
CharlesKasasira / middleElement.js
Created February 9, 2023 13:43
Find the middle element
// As a part of this Kata, you need to create a function that when provided with a triplet, returns the index of the numerical element that lies between the other two elements.
// The input to the function will be an array of three distinct numbers (Haskell: a tuple).
// For example:
// gimme([2, 3, 1]) => 0
// 2 is the number that fits between 1 and 3 and the index of 2 in the input array is 0.
// Another example (just to make sure it is clear):
// gimme([5, 10, 14]) => 1
// 10 is the number that fits between 5 and 14 and the index of 10 in the input array is 1.
function gimme (triplet) {
@CharlesKasasira
CharlesKasasira / SEO.md
Created December 25, 2022 13:39 — forked from denzildoyle/SEO.md
I short list of SEO tips and tricks I have learned over time

SEO

In this list, I will be typically be talking SEO as it relates to Google because Google will likely account for the vast majority of your inbound search traffic. Additionally, if you rank highly on Google, you will probably do well on other search engines anyway. Just like in football if you could play in the Major league you would most likely kill it in the minor league I would begin by explaining why SEO is important talk a little bit about what SEO is about and talk about how those concepts relate to the world wide web. Then talk about some of the things you could do to optimize your site from top to bottom of a typical webpage.

Why it's important

  • When you want to hide something on google put it on the second page. #SEO @searchdecoder
  • Winner takes almost everything
  • More than 80 percent of shoppers research big purchases online first
  • Opertunity for business
  • 88% Of Consumers Trust Online Reviews As Much As Personal Recommendations
  • 72% Of Consumers Say That Positive Reviews Make Them T
@CharlesKasasira
CharlesKasasira / countriesInTheWorld.js
Created November 2, 2022 08:54
An array containing all the country names in the world
const countries = ["Afghanistan","Albania","Algeria","Andorra","Angola","Anguilla","Antigua & Barbuda","Argentina","Armenia","Aruba","Australia","Austria","Azerbaijan","Bahamas","Bahrain","Bangladesh","Barbados","Belarus","Belgium","Belize","Benin","Bermuda","Bhutan","Bolivia","Bosnia & Herzegovina","Botswana","Brazil","British Virgin Islands","Brunei","Bulgaria","Burkina Faso","Burundi","Cambodia","Cameroon","Canada","Cape Verde","Cayman Islands","Central Arfrican Republic","Chad","Chile","China","Colombia","Congo","Cook Islands","Costa Rica","Cote D Ivoire","Croatia","Cuba","Curacao","Cyprus","Czech Republic","Denmark","Djibouti","Dominica","Dominican Republic","Ecuador","Egypt","El Salvador","Equatorial Guinea","Eritrea","Estonia","Ethiopia","Falkland Islands","Faroe Islands","Fiji","Finland","France","French Polynesia","French West Indies","Gabon","Gambia","Georgia","Germany","Ghana","Gibraltar","Greece","Greenland","Grenada","Guam","Guatemala","Guernsey","Guinea","Guinea Bissau","Guyana","Haiti","Hondur
{
"quotes": [
{
"quote":"Life isn’t about getting and having, it’s about giving and being.","author":"Kevin Kruse"},
{
"quote":"Whatever the mind of man can conceive and believe, it can achieve.","author":"Napoleon Hill"},
{
"quote":"Strive not to be a success, but rather to be of value.","author":"Albert Einstein"},
{
@CharlesKasasira
CharlesKasasira / divisors.py
Created March 3, 2022 06:58
Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell and Result<Vec<u32>, String> in Rust).
def divisors(integer):
a = []
for i in range(2, integer):
if integer % i == 0:
a.append(i)
return a if a else str(integer) + " is prime"
// getting a fib at a certain position
function fib(n){
if(n <= 2) {
return 1// base case
}else{
return fib(n-1) + fib(n-2)
}// recuring case
}
// listing a given number of fibonacci numbers
@CharlesKasasira
CharlesKasasira / script.js
Created January 6, 2022 13:34
Detect whether a user is online or offline
// Simply requesting a certain file at an interval with fetch, in this case after 30 seconds
const checkOnlineStatus = async () => {
try{
const online = await fetch("https://w3schools.com")
return online.status >= 200 && online.status < 300
} catch (err) {
return false // Offline
}
}
@CharlesKasasira
CharlesKasasira / index.html
Last active January 6, 2022 13:32
Login Form with floating placeholder and light button
<div class="login-box">
<h2>Login</h2>
<form>
<div class="user-box">
<input type="text" name="" required="">
<label>Username</label>
</div>
<div class="user-box">
<input type="password" name="" required="">
<label>Password</label>