Skip to content

Instantly share code, notes, and snippets.

@keithweaver
keithweaver / setting-up-lamp-ec2.md
Created March 20, 2017 22:48
Setting up a LAMP stack on Amazon Web Services (AWS) EC2

Setting Up EC2

  1. Sign into AWS
  2. Open EC2
  3. Click Instances on Left Side
  4. Click "Launch Instance"
  5. Select "Amazon Linux AMI 2016.09.1 (HVM), SSD Volume Type"
  6. Select Free Tier
  7. Click review and launch
  8. Press Launch
@keithweaver
keithweaver / domain-to-aws-ec2-instance.md
Created March 20, 2017 23:49
Point Domain to Amazon Web Services (AWS) EC2 Instance

Point Domain to Amazon Web Services (AWS) EC2 Instance

  1. Open the Amazon Route 53 console at https://console.aws.amazon.com/route53/.
  2. If you are new to Amazon Route 53, you see a welcome page; choose Get Started Now for DNS Management. Otherwise, choose Hosted Zones in the navigation pane.
  3. Choose Create Hosted Zone.
  4. For Domain Name, type your domain name.
  5. Choose Create.
  6. Click the Hosted Zone, edit record set.
  7. In the value, add ec2-54-152-134-146.compute-1.amazonaws.com.
  8. Change your DNS file to point to the IPv4 address (This would be in something like GoDaddy).
@keithweaver
keithweaver / write-to-file.py
Created March 25, 2017 19:28
Write to File with Python
# Writing to a file in Python
# This was tested on Python 2.7.
# path - is a string to desired path location. The file does
# not have to exist.
# content - is a string with the file content.
def writeToFile(path, content):
file = open(path, "w")
file.write(content)
file.close()
@keithweaver
keithweaver / objects-classes-in-python.py
Last active March 25, 2017 20:05
Example Objects within single file in Python
# This is an example of using Object/Classes in Python.
# The code has been tested with Python 2.7.
# My Car Object
class ExampleCarObject:
# This is the constructor so when creating the object, these are
# the required parameters. "self" is needed as the first parameter
# for all functions in the object but when call it, you do NOT
# pass anything in. At the bottom there is an example.
def __init__(self, carOwner):
@keithweaver
keithweaver / unity-handle-touch-or-click.cs
Created March 27, 2017 14:00
Handle touch input or mouse click with Unity
// Example of handling click or touch down in Unity
using System.Collections;
using System.Collections.Generic;
using Unity;
public class CharacterMovement : MonoBehaviour {
void start() {
Debug.Log("Start");
}
void update() {
@keithweaver
keithweaver / change-gravity-object-unity.cs
Created March 27, 2017 14:10
Changing Gravity direction on Object in Unity
// This is for changing gravity direction on the Y axis for
// a particular object.
// This is for Unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterMovement : MonoBehaviour {
float FORCE_OF_GRAVITY = 9.8F;
@keithweaver
keithweaver / move-left-right-unity.cs
Created March 27, 2017 14:18
Move object forward from left to right in Unity
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CharacterMovement : MonoBehaviour {
public float movementSpeed = 5.0f;
void Start() {
Debug.Log("Start");
}
@keithweaver
keithweaver / example-of-l293d-two-motors.py
Created March 27, 2017 19:33
Example of using L293D Python Library
# Run the following commands in the terminal/command line:
# pip install l293d
# or (I had to run as root):
# sudo pip install l293d
#
# I also needed to install Yaml
# So:
# pip install pyyaml
# or I had to run with sudo:
# sudo pip install pyyaml
@keithweaver
keithweaver / get-file.py
Last active October 8, 2021 11:56
Get File Content with Python
# Example of getting file content
def getFileContent(pathAndFileName):
with open(pathAndFileName, 'r') as theFile:
# Return a list of lines (strings)
# data = theFile.read().split('\n')
# Return as string without line breaks
# data = theFile.read().replace('\n', '')
@keithweaver
keithweaver / motor.py
Created April 4, 2017 04:41
Running Motor with Raspberry Pi
import RPi.GPIO as GPIO
from time import sleep
GPIO.setmode(GPIO.BOARD)
Motor1A = 16
Motor1B = 18
Motor1E = 22
GPIO.setup(Motor1A,GPIO.OUT)