Skip to content

Instantly share code, notes, and snippets.

@lornajane
lornajane / patch.php
Created May 2, 2013 13:57
update the gist we made via the GitHub API, using PHP and streams
<?php
include "github-creds.php"; // sets $access_token
ini_set('user_agent', "PHP"); // github requires this
$api = 'https://api.github.com';
$url = $api . '/gists/5501496'; // URL of the specific gist
// prepare the body data
$data = json_encode(array(
@lornajane
lornajane / post.php
Created May 2, 2013 13:55
create a gist using PHP and streams
<?php
include "github-creds.php"; // sets $access_token
ini_set('user_agent', "PHP"); // github requires this
$api = 'https://api.github.com';
$url = $api . '/gists'; // no user info because we're sending auth
// prepare the body data
$data = json_encode(array(
@lornajane
lornajane / get.php
Created May 2, 2013 13:53
Get a list of my gists with PHP streams
<?php
ini_set('user_agent', "PHP"); // github requires this
$api = 'https://api.github.com';
$url = $api . '/users/lornajane/gists';
// make the request
$response = file_get_contents($url);
// check we got something back before decoding
@lornajane
lornajane / poem.txt
Created May 2, 2013 11:00
Rather Lame Poetry
If I had the time, I'd make a rhyme
@lornajane
lornajane / text.txt
Created December 20, 2012 15:37
Gist created by API
Some riveting text
@lornajane
lornajane / gist:4131314
Created November 22, 2012 14:01
localhost index
<?php
// phpinfo();
echo "verb: " . $_SERVER['REQUEST_METHOD'] . "\n";
echo "headers:";
var_dump(apache_request_headers());
echo "\n";
@lornajane
lornajane / file1.txt
Created September 25, 2012 12:00
an API-created gist
Some lovely code, how nice!
@lornajane
lornajane / gist:3756788
Created September 20, 2012 16:03
My First Form
<form method="post">
Name: <input type="text" name="name" />
<br />
<input type="submit" />
</form>
<?
if($_POST) {
echo "Hello, " . filter_input(INPUT_POST, "name", FILTER_SANITIZE_STRING);
sudo http_proxy="http://wwwcache.lmu.ac.uk:3128" aptitude install curl
# add to .bashrc:
export http_proxy="http://wwwcache.lmu.ac.uk:3128"
<?php
Interface WeatherInterface {
public function getWeather();
}
class WeatherBot implements WeatherInterface {
public function getWeather() {
// imagine something more complicated
return 'Sunny';