Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Kaye mattkaye

View GitHub Profile
View simple-curl.php
$endpoint = 'http://yahoo.com';
$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields));
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if($response === false){
echo 'Curl error: ' . curl_error($ch);
@mattkaye
mattkaye / new_gist_file.php
Created Nov 19, 2013
Turn on error reporting
View new_gist_file.php
ini_set('error_reporting',E_ALL);
ini_set('display_errors',-1);
@mattkaye
mattkaye / new_gist_file.ps1
Created Oct 7, 2013
Remove directory and contents recursively. Suppress notices
View new_gist_file.ps1
rmdir "FOLDERNAME" /S /Q
@mattkaye
mattkaye / new_gist_file
Created Jun 28, 2013
Write script tag to head
View new_gist_file
function appendScriptTag(path){
var head= document.getElementsByTagName('head')[0];
var script= document.createElement('script');
script.type= 'text/javascript';
script.src= path;
head.appendChild(script);
}
@mattkaye
mattkaye / new_gist_file
Created Jun 21, 2013
Get URL Parameter By Name
View new_gist_file
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
You can’t perform that action at this time.