Skip to content

Instantly share code, notes, and snippets.

@keithweaver
keithweaver / upstream_swagger.json
Created June 13, 2023 18:01
Upstream Basic V1
{
"swagger": "2.0",
"info": {
"title": "API",
"contact": {}
},
"host": "http://localhost:9000",
"paths": {
"/basics/cars/upstream": {
"get": {
@keithweaver
keithweaver / open-private-s3-file.php
Last active May 29, 2023 11:05
Open AWS S3 File Privately with PHP
<?php
$BUCKET_NAME = '';
$IAM_KEY = '';
$IAM_SECRET = '';
require '/vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
// Get the access code
@keithweaver
keithweaver / put-object-on-aws-s3.php
Last active May 18, 2023 19:20
Upload an image/object to an AWS S3 Bucket using PHP
<?php
// Installed the need packages with Composer by running:
// $ composer require aws/aws-sdk-php
$filePath = "https://example.com/test.png";
require 'vendor/autoload.php';
$bucketName = 'YOUR_BUCKET_NAME';
$filePath = './YOUR_FILE_NAME.png';
@keithweaver
keithweaver / s3-upload-via-link.php
Last active May 18, 2023 16:44
Upload image using link to AWS S3 with PHP
@keithweaver
keithweaver / check-if-file-exists.py
Created March 10, 2017 03:49
Check if file exists with Python
import os
def doesFileExists(filePathAndName):
return os.path.exists(filePathAndName)
# Example
if doesFileExists('./test.json'):
print ('Yaa it exists!')
else:
print ('Nope! Not around')
@keithweaver
keithweaver / bluetooth-raspberry-pi-communication.py
Last active April 7, 2023 13:49
Sending information with bluetooth on Raspberry Pi (Python)
# Uses Bluez for Linux
#
# sudo apt-get install bluez python-bluez
#
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/x232.html
# Taken from: https://people.csail.mit.edu/albert/bluez-intro/c212.html
import bluetooth
def receiveMessages():
@keithweaver
keithweaver / get-wifi.py
Last active March 20, 2023 18:01
Get Wifi information on Mac OSx using Python
# I tried to use the pip install wifi but it really didn't work.
# So created this
import subprocess
process = subprocess.Popen(['/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport','-I'], stdout=subprocess.PIPE)
out, err = process.communicate()
process.wait()
print(out)
'''
@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 / save-video-w-opencv.py
Created March 9, 2017 15:01
Stream and save video in Python with OpenCV
# For more info: http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_video_display/py_video_display.html
import cv2
import numpy as np
import os
FILE_OUTPUT = 'output.avi'
# Checks and deletes the output file
# You cant have a existing file or it will through an error
if os.path.isfile(FILE_OUTPUT):
@keithweaver
keithweaver / sendgrid.php
Last active January 28, 2023 15:22
Send an email with PHP using Sendgrid (Mail Server)
<?php
// You need to install the sendgrid client library so run: composer require sendgrid/sendgrid
require '/vendor/autoload.php';
// contains a variable called: $API_KEY that is the API Key.
// You need this API_KEY created on the Sendgrid website.
include_once('./credentials.php');
$FROM_EMAIL = 'YOUR_EMAIL';
// they dont like when it comes from @gmail, prefers business emails