Skip to content

Instantly share code, notes, and snippets.

View chetanmadaan's full-sized avatar

Chetan Madaan chetanmadaan

View GitHub Profile
@marcus-at-localhost
marcus-at-localhost / Request Google Sheets JSON API v4 with PHP.md
Last active September 4, 2023 07:46
[Request Google Sheets JSON API v4 with PHP] #json #google-sheets

Request Google Sheets JSON API v4 with PHP #json #googlesheets

<?php

// Migrate to v4: https://developers.google.com/sheets/api/guides/migration#retrieve_row_data
// Form: https://forms.gle/P1hyew16yUSx7GgH8
// Table: https://docs.google.com/spreadsheets/d/1TlhxvW4GxayktKdjoWKt620qTzysEquC4UPGmOlGxb0/edit?usp=sharing
@chetanmadaan
chetanmadaan / .htaccess
Created February 27, 2020 21:43
.htaccess redirect thingy.
# Redirect HTTP with www to HTTPS with www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTP without www to HTTPS with www
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Redirect HTTPS without www to HTTPS with www
RewriteCond %{HTTPS} on
@dillansimmons
dillansimmons / recaptchaMarketo.js
Created October 21, 2016 05:51
Insert Google reCAPTCHA into Marketo form with validation
/* Load the Google reCAPTCHA API : Make sure it loads somewhere above the insert code-->
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
*/
/* Main code that inserts the reCAPTCHA into the marketo form */
// Wait for Marketo form to load
MktoForms2.whenReady(function (form) {
// Insert the recap div after the last form row
$( '<div id="recap"></div>' ).insertAfter( ".mktoFormRow:last-of-type" );
// render the recap : replace with your site key
<?php
function get_tls_version($sslversion = null)
{
$c = curl_init();
curl_setopt($c, CURLOPT_URL, "https://www.howsmyssl.com/a/check");
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
if ($sslversion !== null) {
curl_setopt($c, CURLOPT_SSLVERSION, $sslversion);
}
@jplitza
jplitza / webhook.php
Created January 7, 2015 14:36
A basic PHP webhook handler for Github, just verifying the signature and some variables before calling another command to do the actual work
<?php
// where to log errors and successful requests
define('LOGFILE', '/tmp/github-webhook.log');
// what command to execute upon retrieval of a valid push event
$cmd = 'update-jekyll.sh 2>&1';
// the shared secret, used to sign the POST data (using HMAC with SHA1)
$secret = '00000000000000000000000000000000';
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@magnetikonline
magnetikonline / dumprequest.php
Last active April 30, 2024 08:01
PHP script to dump full HTTP request to file (method, HTTP headers and body).
<?php
// https://gist.github.com/magnetikonline/650e30e485c0f91f2f40
class DumpHTTPRequestToFile {
public function execute($targetFile) {
$data = sprintf(
"%s %s %s\n\nHTTP headers:\n",
$_SERVER['REQUEST_METHOD'],
$_SERVER['REQUEST_URI'],
$_SERVER['SERVER_PROTOCOL']
@octocat
octocat / .gitignore
Created February 27, 2014 19:38
Some common .gitignore configurations
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@tschoffelen
tschoffelen / install.php
Last active February 12, 2024 09:20
A simple PHP script that automatically downloads and unzips the latest version of Wordpress in the current directory (./), so that I don't have to download it and upload it to my server through FTP manually.
<?php
echo '<pre>';
echo '<span style="color:blue">DOWNLOADING...</span>'.PHP_EOL;
// Download file
file_put_contents('wp.zip', file_get_contents('https://wordpress.org/latest.zip'));
$zip = new ZipArchive();
$res = $zip->open('wp.zip');
if ($res === TRUE) {
@maxrice
maxrice / us-state-names-abbrevs.php
Created May 23, 2012 18:32
US State Names & Abbreviations as PHP Arrays
<?php
/* From https://www.usps.com/send/official-abbreviations.htm */
$us_state_abbrevs_names = array(
'AL'=>'ALABAMA',
'AK'=>'ALASKA',
'AS'=>'AMERICAN SAMOA',
'AZ'=>'ARIZONA',
'AR'=>'ARKANSAS',