Categories
Resources Software Development

Ansible resources links videos and information

Ansible is used to provision/setup servers for your app.
Why is Ansible better than shell scripting?

Categories
Resources Software Development

Mysql resources links and information

This page contains links and videos to information about MySQL database.

More on MySQL option files in the documentation here.

Categories
Random Resources Software Development

How to push an existing project to a Github repository

While trying to figure out how to do this I found lots of bad info, info that lead to nothing but issues and bugs. I have stay so busy and do so many things I can never remember how to do anything. That is basically why this ENTIRE blog exists, my shit memory.

I found this article on DigitalOcean that works properly.

Step 1 create a repository on Github, even if the code you want to put in a repo exists, as long as it is not currently in any repo at all.

Step 2 navigate to the folder that contains the code that you want to push to the new Git/Github repo and run git init

Step 3 add the files with git add -A or git add .

Step 4 commit the files

Step 5 add the remote git origin server

Step 6 push to the remote git origin server

Or just use this script.

 

Categories
Resources Software Development

Linux commands resources and links

Difference between Ubuntu apt-get autoclean, clean, autoremove commands – it is important to know the difference.

Cleaning up with apt-get – how to clean up with apt clean command

How To Upgrade Ubuntu Using Command Line?

Linux << heredoc syntax info – great link has lots of good linux information

Here is an excellent link to a shell command cheatsheet. This lists the most commonly used shell programs.

An A-Z Index of the Linux command line: bash + utilities. – about the same as the list of shell commands above.20 Shell Scripting Questions for Practice

Writing text to files from shell or shell scripts

Awesome linux software – a list/article about awesome useful linux programs
Understanding Shell Initialization Files and User Profiles in Linux

20 Shell Scripting Questions for Practiceuses opensshLinux visudo command

Linux /etc/profile file information

Understanding a little more about /etc/profile and /etc/bashrc20 Shell Scripting Questions for Practice

Why and How to Edit Your Sudoers File in Linux

LINUX DIRECTORY STRUCTURE:/ETC EXPLAINED

Tutorialspoint Linux tutorials and really good information.20 Shell Scripting Questions for Practice

How to Use Sudo and the Sudoers File – very good article

Ubuntu Environmental variables – Ubuntu Documentation link

How to prompt for input from user in a linux shell script – article 20 Shell Scripting Questions for Practicecovers two ways to prompt users for input in shell scripts.

How to prompt and read user input in a Bash shell script – A good example of a script that prompts users for input and uses it.

Bash read builtin command – this command is built into bash meaning available without installing etc.

Linux while loop explained with examples of alternate syntaxes

How to create a self signed SSL certificate 

20 Shell Scripting Questions for Practice – article showing how to prompt users for input and how to answer prompts.


Categories
Resources Web Development

How to list and install php modules on ubuntu linux

I always, always forget how to do this and it takes an hour of googling to figure this out again. Basically I often need to see not just what php modules are installed on my system, but also what can be installed.

For example you can see what is already installed and available to you on your current system you simply type php -m in your command line. This command will list all of what is installed currently on your system.

But that is not what I want and probably not what you want if you are reading this. What I want is to know what is available for installing, or better what are the exact names of the packages. For this information you need a different command.

sudo apt-cache search php7*

This command searches the apt cache for packages that contain php7* the * is a wildcard meaning anything that looks like php7 such as php7.4-mysql. Try the command above and you will get a list of all of the php modules specifically for version 7.4. Not all modules will be listed. You can use another command to see all of the available php modules even if they don’t contain 7.4 in the name you can install them.

To see all php modules available use this command.

sudo apt-cache search php*

Minus the 7 and it will return every last module that contains the word php.

Then to install anything you need you use a command like the following

sudo apt install php7.4-mysql php7.4-curl php7.4-json php7.4-cgi php7.4-xsl

And that is how you list and install php modules/extensions.

Here is an interesting article about how apt-cache works on linux
Here is a link to some more resources about this topic.

Categories
Resources Web Development

How to get TinyMCE to not destroy image upload URL’s

Came across a weird not so feature of TinyMCE where it munges the URL your upload script returns when it uploads an image. For example if your upload script returns a url of http://example.com/folder/image.jpg. TinyMCE takes it upon itself to rewrite that URL breaking it to ../../folder/image.jpg  I am not sure why but I think it is trying to help you in some way.

The best clue I could find in the docs as to why this happens is at the bottom of the page in the CORS section here. It appears TinyMCE is removing the domain you add to the url then it cuts from the current page. The problem I encountered was if my page was blog it would remove the http://example.com part and replace it with ../../blog/folder/image.jpg which is not what I wanted.

I was about to replace TinyMCE but I decided to try something else. I did some googling and found this in the docs.  

I included this in my tinymce configs.

relative_urls : false,
remove_script_host : false,
document_base_url :  "{{ prependURL }}"

Those 3 lines of code fixed it all. Totally didn’t expect TinyMCE to munge the URL’s I returned. This ate up an entire day as I kept thinking the reason the image didn’t display was because my code wasn’t creating the URL’s correctly. Then I thought it was my Nginx configs. Then before giving up on TinyMCE  I did this last thing.

prependURL is a variable that contains the url of website hosting the image such as https://example.com TinyMCE prepends that to the url you return to it, even if https://example.com is already part of it. Otherwise it removes https://example.com and replaces it with a relative URL such as ../../folder/image.jpg

I hope this saves someone else time.

Categories
Resources Software Development Web Security

AWS autoscaling links and resources

AWS autoscaling lets you set up groups of EC2 instances which are controlled by a load balancer. The load balancer in turn makes sure your app has the correct number of EC2 instances running at all times. If your traffic is high it adds the maximum that you set. If traffic goes down it adjust to have the minimum EC2 instances that you set.

This system is great for startups who have no idea if their app will go viral or just flop. Often they just flop. But if you are lucky and it takes off you want to be able to handle the traffic so you don’t lose users.

Documentation link to AWS autoscaling

Running EC2 instances at Scale with autoscaling groups – small Ebook that walks through the whole process including using CodeDeploy.

Categories
Resources Software Development

AWS resources and links

AWS Parameter Store vs. AWS Secrets Manager – great short article that covers use cases and information about each and when to use.

Categories
Resources Software Development

Linux how to copy files from one directory to another without copying the directory name

This is for later when I forget how to do this. Basically I wanted to know how to move files from one directory into another recursively without the cp command also copying the directory name.

Basically if you use cp -r /directory then the contents of the directory and all within are copied, but this also copies the name of the current directory.

expect the unexpected
With linux expect the unexpected

The cp command is not logical, it doesn’t do what a user would expect.  Instead of just copying the files from /var/www/example to say /var/www/new-directory like one would logically expect, this command copies the files into new-directory but also puts them inside example so you end up with /var/www/new-directory/example/fileshere which is probably not what anyone expects.

So what kind of sorcery is required to get the outcome we would expect?
You add a tiny little dot to the first directory like so
cp -r /var/www/example/. /var/www/new-directory

Yes it is very important you structure the command EXACTLY like the above or else you won’t get what you want. Including the final slash with a dot after example/. tells the cp command to not copy the directory name, but to put all the files from that directory into the other.
Know you know…

now you know

 

 

Categories
Resources Software Development

GIT how to check user settings

With git you can configure global or per repository settings. Global means any repository on your computer that you want to use will use these settings unless you specify specific settings per repository.

The settings I am speaking of are your username, email and remote origin etc.  This article at this link covers the basics of setting your email and username.

But how do you see what the current values of a repository are? Navigate to the repository, to the level where your .git directory is and type the following:
git config –list

You should see something like the following:

git configs example
example git configs output

You can also view individual settings such as user.name or user.email with the following
git config user.name

git config user.email

Those commands will output the current values that are set. Basically you are telling git to echo/print the current values.
Here is a list of all of the values you can set in the git configuration.

Here is a link to the documentation that explains how to get and set git configuration values.

The documentation links show mostly how to set global settings for git, many times you will want per repository settings such as the origin. This article covers nicely how to set per repository settings.

Bitbucket has created this really nice git tutorial and documentation.

Here is another page of links and resources about GIT