Skip to content

Instantly share code, notes, and snippets.

View robynitp's full-sized avatar

Robyn Overstreet robynitp

  • NYU ITP
  • New York, NY
View GitHub Profile
@robynitp
robynitp / php_with_html.php
Last active November 17, 2022 03:17
Intro to PHP with HTML
<html>
<head>
<title>The Top Bar Title</title>
</head>
<body>
<p>Some information</p>
<!-- We're about to start PHP -->
<? php // We're in PHP now.
// assign some variables -- variables in PHP start with a dollar sign ($)
@robynitp
robynitp / geocode_xml.php
Created November 19, 2013 04:10
Example of accessing the Google Geocoding API and getting results in XML Info here: https://developers.google.com/maps/documentation/geocoding/
<?php
/*
Example of accessing the Google Geocoding API and getting results in XML
Info here: https://developers.google.com/maps/documentation/geocoding/
*/
$base_url = 'http://maps.googleapis.com/maps/api/geocode/';
$format = 'xml'; // 'xml' or 'json'
$address = 'address='.urlencode('350 5th Avenue New York, NY'); // makes the text URL friendly, ie, 350+5th+Avenue+New+York%2C+NY
$url = $base_url.$format.'?'.$address.'&sensor=false'; // Google requires 'sensor=false' parameter
@robynitp
robynitp / openweathermap.php
Created November 19, 2013 03:08
OpenWeatherMap API example See documentation for more info: http://openweathermap.org/API
<?php
/*
OpenWeatherMap API example
See documentation for more info: http://openweathermap.org/API
*/
/*
Get the 7-day forecast for London in imperial (Fahrenheit) units, with response in JSON format:
Parameters in query string:
q=London : search string
@robynitp
robynitp / pdo_connect.php
Last active December 28, 2015 03:19
Connect MySQL to PHP with PDO
<?php
//For more info, see: http://us1.php.net/manual/en/pdo.construct.php
/* Connect to an ODBC database using driver invocation */
$dsn = 'mysql:dbname=testdb;host=mysql.yourdomain.com';
$user = 'dbuser';
$password = 'dbpass';
try {
// create PDO object (stands for PHP Data Object, fyi)
@robynitp
robynitp / gist:7329393
Last active December 27, 2015 12:59
Basic OOP in PHP
<?php
// --- PHP --- //
// Declare and construct an object from the class HLine
// PHP doesn't care whether the parameters are ints or strings
$h1 = new HLine(20, 'meow');
// show the ypos property of h1
echo $h1->ypos;
class HLine{
/*
@robynitp
robynitp / gist:7329363
Last active December 27, 2015 12:58
Basic OOP in Processing
// --- Processing ---//
/*
Declare and construct an object from the class HLine
Processing requires that you state the type of a variable when you initialize it.
The type here is HLine
*/
HLine h1 = new HLine(20, 2.0);
// show the ypos property of h1
print(h1.ypos);