Skip to content

Instantly share code, notes, and snippets.

View AdamZWinter's full-sized avatar

Adam Winter AdamZWinter

  • Seattle, WA, USA
View GitHub Profile
function openWindowWithPostRequest() {
var winName='MyWindow';
var winURL='search.action';
var windowoption='resizable=yes,height=600,width=800,location=0,menubar=0,scrollbars=1';
var params = { 'param1' : '1','param2' :'2'};
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", winURL);
form.setAttribute("target",winName);
for (var i in params) {
@AdamZWinter
AdamZWinter / header.gist
Last active April 1, 2020 20:57
Secure site header
<?php
//header.php
if(!isset($_SESSION))
{
ini_set('session.cookie_lifetime', 0);
ini_set('session.use_cookies', 1);
ini_set('session.use_only_cookies', 1);
ini_set('session.use_strict_mode', 1);
ini_set('session.cookie_httponly', 1);
ini_set('session.cookie_secure', 1);
:root {
--myPurple: 8, 0, 24;
--purpleButton: 25, 0, 75;
--offWhite: 195, 210, 190, 1;
--backGrey: 40, 40, 40;
--linkBlue: 195, 210, 255, 1;
}
/* a is between zero and one. */
@AdamZWinter
AdamZWinter / PHP_POST.gist
Created March 8, 2020 03:41
POST with PHP file_get_contents to Google API
$grant_type = 'refresh_token';
$url = 'https://oauth2.googleapis.com/token';
$data = array('refresh_token' => $refresh_token, 'client_id' => $client_id, 'client_secret' => $client_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => $grant_type, 'scope' => $scope );
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data)