This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
#This is the same as (\,*? N\. ?E.) | |
#All spaces need to be escaped in verbose mode. | |
ne_pattern = re.compile(r """ | |
( #start group | |
\,*? #look for comma (escaped); *? = 0 or more commas with fewest results | |
\ N\.? #look for (escaped) space + N that might have an (escaped) period after it | |
\ ?E #look for an E that may or may not have an space in front of it | |
. #the E might be followed by another character. | |
) #close group |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Attempting to get a d3 non-contiguous cartogram to work when data for some states does not exist. | |
// Ratio of state delegations in the 43rd Congress | |
var data = [ | |
,0.025,0,0.003,0.018,0.018,0.003,0.018,0.008,0.003,0.01,0.03,0,0.003,0.056,0.038,0.028, | |
0.018,0.03,0.02,0.018,0.02,0.04,0.03,0.013,0.023,0.038,0.003,0.008,0.008,0.013,0.023, | |
0.003,0.096,0.025,0.003,0.058,0,0.01,0.076,0.01,0.02,0,0.03,0.02,0.003,0.013,0.03,0.003, | |
0.013,0.025,0.003,0 | |
]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*My old nemisis, NULL, but this time I think it's a problem with my understanding of key value pairs. Both $_GET array and $Drop array return the following in a variable dump. I WANT $Drop to return NULL for empty values: | |
array(8) { ["street"]=> string(14) "106 3rd St. NW" ["new_street"]=> string(0) "" ["city"]=> string(10) "Washington" ["new_city"]=> string(0) "" ["state"]=> string(2) "DC" ["new_state"]=> string(0) "" ["new_modern_address"]=> string(0) "" ["new_hotel"]=> string(0) "" } | |
*/ | |
include 'connect.php'; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Based on code in the API sandbox: http://mapstraction.appspot.com/#image_overlay. JS documentation here: http://www.mapscripting.com/mxndocs | |
/index.html | |
THIS CODE ONLY RENDERS BASE MAP | |
http://rungiraffe.com/clio3/mapexample/mapstraction/openlayers.html | |
--> | |
<html> | |
<head> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Functions to calculate congress start and end years | |
function congressStart($congress) { | |
$start_calc = $congress * 2 + 1787; | |
return $start_calc; | |
} | |
function congressEnd($congress) { | |
$end_calc = $congress * 2 + 1789; | |
return $end_calc; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Connect to mysql | |
$connect = mysql_connect("","",""); | |
if (!$connect) { | |
die('Could Not Connect to MySQL'); | |
} | |
//else echo "You are in mysql.<br />"; | |
//Connect to database dc_address | |
mysql_select_db('dc_address_test') or die('You are not in dc_address_test.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The joiner table won't update when address_id is NULL. Table is structured so that address_id_fk will take a NULL value. Any ideas? */ | |
$join_congq = "INSERT INTO join_cong (congress_num, bio_id_fk, address_id_fk, party_id_fk) | |
VALUES ('$congress','$bio_id','$address_id', '$party_id')"; | |
//Update join_cong joiner table and check for failure | |
if (mysql_query($join_congq)){ | |
echo ("<strong>The join_cong joiner table has been updated</strong>".$break); | |
echo ("Query: ".$join_congq.$break); | |
echo ("Data: ".$congress.$comma.$bio_id.$comma.$address_id.$comma.$party_id.$break); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
include 'connect.php'; | |
//UNIVERSAL VARIABLES | |
$comma = ", "; | |
$break = "<br />"; | |
//CONGRESS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Having trouble dealing with NULL values. | |
In some cases $street has a value and $hotel = NULL; | |
Sometimes $hotel has a value and $street = NULL; | |
Sometimes they both are NULL. | |
This code seems to require BOTH a street AND a hotel. I want to test for either or. | |
(for context see below) */ | |
//Create variable containing MySQL Query for finding existing street. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Create variables for the bio entries | |
$street = mysql_real_escape_string($_POST['street']); | |
$city = mysql_real_escape_string($_POST['city']); | |
$state = $_POST['state']; | |
$hotel = mysql_real_escape_string($_POST['hotel']); | |
$modern_address = mysql_real_escape_string($_POST['modern_address']); | |
//Check for blank entries; make them NULL | |
if (empty($street)) { | |
$street = NULL; |
NewerOlder