Skip to content

Instantly share code, notes, and snippets.

Avatar

Matt Kaye mattkaye

  • The Durst Organization
  • New York, NY
View GitHub Profile
@mattkaye
mattkaye / simple-curl.php
Last active August 29, 2015 14:22
Simple cURL
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 November 19, 2013 03:10
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 October 7, 2013 15:46
Remove directory and contents recursively. Suppress notices
View new_gist_file.ps1
rmdir "FOLDERNAME" /S /Q
@mattkaye
mattkaye / new_gist_file
Created June 28, 2013 18:46
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 June 21, 2013 19:30
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, " "));
}