Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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
@keithweaver
keithweaver / s3-upload-via-form.php
Created July 18, 2017 11:33
Upload image using form submission to AWS S3 with PHP
<?php
// This file demonstrates file upload to an S3 bucket. This is for using file upload via a
// file compared to just having the link. If you are doing it via link, refer to this:
// https://gist.github.com/keithweaver/08c1ab13b0cc47d0b8528f4bc318b49a
//
// You must setup your bucket to have the proper permissions. To learn how to do this
// refer to:
// https://github.com/keithweaver/python-aws-s3
// https://www.youtube.com/watch?v=v33Kl-Kx30o
@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 / run-custom-cascade.py
Last active January 14, 2019 07:26
Object detection using custom Haar Cascade on an image with OpenCV
# Running:
# $ python run-custom-cascade.py
# Import OpenCV
import cv2
# Image file
IMAGE_FILE = './example.png' # Change this to be your image
# Cascade file
<?php
// Install using composer and run: $ composer require kweaver00/lumberjack_php dev-master
require_once "/vendor/autoload.php";
$lumberjack = new \Kweaver\Lumberjack\Lumberjack();
$lumberjack->setAppKey("YOUR_APP_KEY");
$lumberjack->setAPIKey("YOUR_API_CODE");
$lumberjack->log("TAG","Content goes here.", "Verbose");
// Title, Content, Level of importance
@keithweaver
keithweaver / folder-of-images-upload.py
Last active May 17, 2017 15:02
Upload a whole folder of images to the Haar Cascade Market via API
# This file will find keywords in the file name to assign tags for the
# Cascade Market. Add keywords to the image file name in the following
# format "..._keyword_keyword2.jpg". This is explained more below.
#
#
# Tips:
# - Keep it consistent. I made the mistake of labeling a mix of longboard and
# longboarder to represent the same thing. As a result, when I train I have
# to make sure the other is not in the negative set or it will affect my
# cascade.
@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 / 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';