Skip to content

Instantly share code, notes, and snippets.

@keithweaver
keithweaver / split-video-by-frame.py
Created May 10, 2017 19:30
Using OpenCV takes a mp4 video and produces a number of images.
'''
Using OpenCV takes a mp4 video and produces a number of images.
Requirements
----
You require OpenCV 3.2 to be installed.
Run
----
Open the main.py and edit the path to the video. Then run:
@keithweaver
keithweaver / create-folder.py
Created March 10, 2017 03:42
Create a folder with Python
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
@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 / add-prefab-game-object-to-scene.cs
Last active December 28, 2023 03:36
Create a new game object/prefab in a scene using C# code for Unity.
using UnityEngine;
using System.Collections;
// I attached this script to my main camera
public class GenerateMap : MonoBehaviour {
void Start () {
int x = 0;
int y = 0;
// Adding a Prefab/GameObject to Scene using C#. Make sure you create a prefab with the file name
@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 / s3-file-upload.js
Last active August 21, 2023 19:30
S3 File Upload to AWS S3
const AWS = require('aws-sdk');
const Busboy = require('busboy');
const BUCKET_NAME = '';
const IAM_USER_KEY = '';
const IAM_USER_SECRET = '';
function uploadToS3(file) {
let s3bucket = new AWS.S3({
accessKeyId: IAM_USER_KEY,
@keithweaver
keithweaver / swagger.yml
Last active June 19, 2023 18:17
Woo Commerce API as Swagger
openapi: 3.0.0
info:
title: WooCommerce REST API
version: 1.0.0
servers:
- url: http://{{baseurl}}
components:
securitySchemes:
basicAuth:
type: http
@keithweaver
keithweaver / save-file.py
Last active June 14, 2023 05:13
Save JSON file with Python
import json
def writeToJSONFile(path, fileName, data):
filePathNameWExt = './' + path + '/' + fileName + '.json'
with open(filePathNameWExt, 'w') as fp:
json.dump(data, fp)
# Example
data = {}
@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
{
"swagger": "2.0",
"info": {
"title": "API",
"contact": {}
},
"host": "http://localhost:9000",
"paths": {
"/basics/cars/downstream": {
"get": {