Skip to content

Instantly share code, notes, and snippets.

View harrietty's full-sized avatar

Harriet harrietty

View GitHub Profile
@harrietty
harrietty / hashRouterVsBrowserRouter.md
Last active September 16, 2021 07:56
Why do we need to use HashRouter instead of BrowserRouter when hosting on S3?

Why do we need to use HashRouter instead of BrowserRouter when hosting on S3?

Remember, React is a SPA - Single Page Application

As we know, the main idea of React Applications is that they are single page. There is just ONE HTML file, and ONE JavaScript file (although we cound split it up - more on that another day). This means that we do not have different physical files for different pages in our Application. E.g. we do not have index.html for the homepage, about.html for the About page, blog.html for the blog page. This was one of the key differences we discovered when we started using React, as opposed to when we were just using HTML. With React, all the content and logic is written in JavaScript and injected into a single HTML page.

At the end of the day, when we bundle our development code, these are the files we get:

  • index.html
  • bundle.js
@harrietty
harrietty / Golang_Regex_Cheatsheet.md
Last active April 2, 2024 10:49
Golang Regex Cheatsheet

Golang Regex Cheatsheet

Using the regexp package

Include in the imports:

import "regexp"
#!/bin/bash
set -ex
GROUP_NAME=$1
NAMESPACE=$2
# Critical
aws logs put-metric-filter \
--log-group-name ${GROUP_NAME} \
#!/bin/bash
set -ex
NAMESPACE=$1
ALARM_NAME_PREFIX=$2
# Error
aws cloudwatch put-metric-alarm \
--alarm-name "$ALARM_NAME_PREFIX Error Count" \
class FooSpec
def self.describe(message, &block)
puts message
FooSpec.class_eval &block
end
def self.context(message, &block)
puts message
FooSpec.class_eval &block
end
#!/bin/bash
# A script that outputs each number from start to end
# -s 1 to start at one
# -e 20 to end at 20
# -b to count backwards
# final argument is prefix to all the numbers
# e.g. count -s 1 -e 20 -b NUM_
reverse=0

Update all extensions of a particular type of file

#!/bin/bash

# changes the extension of all files matching a given extension

extension_to_replace="$1"
new_extension="$2"

Here are some posible solutions with explanations for Bash Practice Exercises. They are not necessarily the only or the best solutions - there is a preference for using a series of simple commands piped to one another.

1. A program that tells you whether the argument is a file, directory or doesn't exist

#!/bin/bash

# Using an error exit code to make sure the program does not continue.
# Exiting with anything other than 0 signifies an error.

Excersises for learning bash shell scripting

Part 1: Creating scripts and simple logic

1. Create a program that tells you whether the argument you give it is a file, a directory or does not exist.

Use: $ ./test.sh foo

Output:

@harrietty
harrietty / commands.md
Last active November 2, 2018 16:42
Useful Bash commands

Useful Bash Commands

Network

netstat | grep ssh (mac)

netstat -vanp --tcp | grep 8080 (CentOS)

kill -9 <PID>