Skip to content

Instantly share code, notes, and snippets.

@PeeHaa
PeeHaa / ol.md
Created August 27, 2012 15:52
numbered lists
  1. test 1
  2. test 2
@PeeHaa
PeeHaa / SQL and PHP tutorial.md
Created April 11, 2012 20:48
SQL and PHP tutorial

-- WORK IN PROGRESS --

SQL and PHP tutorial

Introduction

Why this tutorial?

@PeeHaa
PeeHaa / oauth1-sign.php
Created August 1, 2012 13:42
Oauth 1a signature example
<?php
/**
* Implementation of the oAuth1 signature spec: http://oauth.net/core/1.0a/ *
*/
namespace Oauth1\Signature;
class TwitterSignature implements \Oauth\Signature
{
protected $signatureAlgorithm;
protected $httpMethod;
@PeeHaa
PeeHaa / arrays.md
Created August 31, 2012 13:34
If I see one more question about arrays in PHP...

Arrays can be seen as lists which can hold information. Arrays in PHP can holds all types of values like scalar values, objects or even other arrays.

Declaring an initializing arrays

First lets see how we can declare an empty array:

<?php
$theArray = array();
@PeeHaa
PeeHaa / v1.php
Created June 29, 2017 14:53
v1 vs v2
public function appendResponse(Response $response)
{
try {
$events = \json_try_decode($response->getBody(), true);
} catch (DecodeErrorException $e) {
$this->logger->emergency('Failed to decode response body as JSON', ['exception' => $e]);
throw new DecodingFailedException('Failed to decode response body as JSON', $e->getCode(), $e);
}
@PeeHaa
PeeHaa / GitAmptest.php
Created January 8, 2017 12:28
GitAmpTest with mocks
<?php declare(strict_types = 1);
namespace ekinhbayar\GitAmpTests\Client;
use Amp\Artax\Client;
use Amp\Artax\ClientException;
use Amp\Artax\Response;
use Amp\Promise;
use Amp\Success;
use ekinhbayar\GitAmp\Client\RequestFailedException;
E..
Time: 679 ms, Memory: 6.00MB
There was 1 error:
1) Amp\Dns\Test\IntegrationTest::testResolve
RuntimeException: Unknown error file getting key '\1'.
EXIT: 1
@PeeHaa
PeeHaa / so-golden
Created June 28, 2015 19:38
old army guy with 100 years of dev experience
I'm voting to close this question as off-topic because it has nothing to do with programming – PeeHaa 1 hour ago
Excuse me, but although I AM a programmer, for the past 35 YEARS, and a very experienced one at that, IT TAKES programming to figure this out. So, using apt-get update and apt-get INSTALL doesn't work to fix the problem. SO, excuse, me, but where else can I go to find a solution except the best place on the web for questions. NOT every question MUST deal with PROGRAMMING or perhaps, there "IS" a programming feature I NEED to do, through TERMINAL to "light up" the ethernet port. I AM 54 years old and need a solution. Instead of VOTING to destroy this question, how about we find a solution. – Peter 22 mins ago
BTW, we're ALL programmers here.... perhaps a bit of thinking together, vice VOTING my question OUT the window would be more of a prudent solution, don't you all think? We do that together in a real world work environment. How intelligent would it be if we simply told
@PeeHaa
PeeHaa / CustomEtsy.php
Created December 19, 2013 18:01
Etsy is being a dickhead with its non standard scope implementation. What a dick move
<?php
use OAuth\OAuth1\Service\Etsy;
use OAuth\OAuth1\Signature\SignatureInterface;
use OAuth\Common\Consumer\CredentialsInterface;
use OAuth\Common\Http\Uri\UriInterface;
use OAuth\Common\Storage\TokenStorageInterface;
use OAuth\Common\Http\Client\ClientInterface;
class CustomEtsy extends Etsy
@PeeHaa
PeeHaa / mail-regex-tester.php
Created August 8, 2013 10:12
Emailaddress regex pattern tester
<?php
if (isset($_POST['submit'])) {
$html = file_get_contents('http://fightingforalostcause.net/misc/2006/compare-email-regex.php');
$dom = new DOMDocument();
@$dom->loadHTML($html);
//$results = $dom->getElementById('results');