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 / 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);
@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 / 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 / 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 / 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 / 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 / file_put.php
Last active August 29, 2015 13:56
Writing to a file with PHP
<?php
/*
Add a new line to a file that contains records of names and phone numbers
For example, the file might be called clients.txt and look like this:
Chan,Roger,345-9876
Garcia,Victoria,456-1234
Stevens,Julie,678-9872
*/
@robynitp
robynitp / foursquare_output.json
Created February 27, 2014 20:17
JSON output from Foursquare
{
"meta": {
"code": 200
},
"response": {
"neighborhoods": [],
"venues": [{
"id": "4b8aa3e1f964a520e77632e3",
"name": "NYU Stern School of
Business",
@robynitp
robynitp / weathercolors.php
Created March 5, 2014 00:31
Example PHP logic using a simple weather app
<!DOCTYPE HTML>
<html>
<head>
<title>The colors of weather</title>
<?php
$temp = 45;
$conditions = 'rain';
/*
@robynitp
robynitp / html5_basic.html
Created March 10, 2014 20:05
A base HTML5 to use for a single page site. Javascript, jQuery, and CSS need to be added.
<!doctype html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html">
<!-- css and js references are just placeholders here. add your own -->
<link rel="stylesheet" type="text/css" media="all" href="css/style.css">
<script type="text/javascript" src="js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="js/myscript.js"></script>
<title>HTML5</title>