Skip to content

Instantly share code, notes, and snippets.

@stevesohcot
stevesohcot / controller-sign-up.php
Created November 27, 2023 01:37
Google recaptcha with PHP - sign up controller
<?php
if (array_key_exists('signUpAttempt', $_POST)) {
$captcha = isset($_POST['g-recaptcha-response']) ? $_POST['g-recaptcha-response'] : null;
// ultimately these could be constants in a "secrets" file
// aka stored as environment variables
#$captchaPublic = constant('CAPTCHA_PUBLIC');
#$captchaSecret = constant('CAPTCHA_SECRET');
@stevesohcot
stevesohcot / sign-up2.html
Created November 27, 2023 01:33
Google recaptcha with PHP - sign up form (v2)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Google reCAPTCHA Example</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
@stevesohcot
stevesohcot / sign-up1.html
Created November 27, 2023 01:31
Google recaptcha with PHP - sign up form
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Google reCAPTCHA Example</title>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css"
integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN"
@stevesohcot
stevesohcot / excel-run-stored-procedure-single-function.vba
Created August 7, 2023 15:09
Excel run stored procedure single function
Private Function getInfoFromStoredProcedure()
Dim sheet As String
sheet = "Data"
Worksheets(sheet).Select
Range("A1").Select
Set rPrint = Worksheets(sheet).Range("A2")
@stevesohcot
stevesohcot / excel-run-stored-procedure.vba
Created August 7, 2023 14:26
Excel VBA call function for Stored Procedure
Public Sub getDataFromRecordset()
Dim sheet As String
sheet = "Data"
Worksheets(sheet).Select
Range("A1").Select
Set rPrint = Worksheets(sheet).Range("A2")
@stevesohcot
stevesohcot / excel-run-stored-procedure.vba
Created August 7, 2023 14:25
Run Stored Procedure in SQL Server from Excel
Private Function getInfoFromStoredProcedure() As ADODB.Recordset
On Error GoTo Error:
Dim adoCon As ADODB.Connection
Dim adoCmd As ADODB.Command
Dim rst As New ADODB.Recordset
Set adoCon = New ADODB.Connection
Set adoCmd = New ADODB.Command
@stevesohcot
stevesohcot / import-sql-server-to-excel-vba.vba
Created August 7, 2023 14:05
Import SQL Server to Excel with VBA
Public Function getDataFromRecordset()
Dim sheet As String
sheet = "Output"
Worksheets(sheet).Select
Range("A1").Select
Dim strSQL As String
strSQL = "SELECT TOP 10 * FROM table"
@stevesohcot
stevesohcot / validate-column-headers.vba
Last active June 19, 2023 14:54
Excel VBA - validate column headers
Const COL_FIRST_NAME = "A"
Const ROW_HEADER = "2"
Dim validation As Boolean
validation = validateColHeaders()
If validation = False Then
End
End If
@stevesohcot
stevesohcot / excel-stored-procedure.vba
Created April 10, 2023 14:18
Run Stored Procedure and get contents in Excel VBA
Const strDbConn As String = "server=server-goes-here;Database=db-goes-here;Trusted_Connection=Yes;Driver={ODBC Driver 17 for SQL Server}"
Private Function getInfoFromStoredProcedure() As ADODB.Recordset
On Error GoTo Error:
Dim adoCon As ADODB.Connection
Dim adoCmd As ADODB.Command
Dim rst As New ADODB.Recordset
@stevesohcot
stevesohcot / show-all-month.sql
Created March 28, 2023 14:18
Show all months in a dataset
-- Show "all months" in results
-- even if there's data missing
-- Define start/end dates for the query
DECLARE @startDate AS DATE = '1/1/2023';
DECLARE @endDate AS DATE = '12/31/2023';
-- We'll use this to iterate in the loop