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
| //IMAGE PRELOADER | |
| var nextimage = "/images/some-image.jpg"; | |
| $(document).ready(function(){ | |
| window.setTimeout(function(){ | |
| var img = $("<img>").attr("src", nextimage).load(function(){ | |
| //all done | |
| }); | |
| }, 100); |
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
| //DYNAMICALLY ADD FORM ELEMENTS | |
| //change event on password1 field to prompt new input | |
| $('#password1').change(function() { | |
| //dynamically create new input and insert after password1 | |
| $("#password1").append("<input type='text' name='password2' id='password2' />"); | |
| }); | |
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
| //AUTOPOPULATE SELECT BOX USING AJAX AND JQURY | |
| $(function(){ | |
| $("select#ctlJob").change(function(){ | |
| $.getJSON("/select.php",{id: $(this).val(), ajax: 'true'}, function(j){ | |
| var options = ''; | |
| for (var i = 0; i < j.length; i++) { | |
| options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'; | |
| } | |
| $("select#ctlPerson").html(options); |
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
| //CALCULATES DISTANCE BETWEEN 2 POINTS | |
| function getDistanceBetweenPointsNew($latitude1, $longitude1, $latitude2, $longitude2) { | |
| $theta = $longitude1 - $longitude2; | |
| $miles = (sin(deg2rad($latitude1)) * sin(deg2rad($latitude2))) + (cos(deg2rad($latitude1)) * cos(deg2rad($latitude2)) * cos(deg2rad($theta))); | |
| $miles = acos($miles); | |
| $miles = rad2deg($miles); | |
| $miles = $miles * 60 * 1.1515; | |
| $feet = $miles * 5280; | |
| $yards = $feet / 3; | |
| $kilometers = $miles * 1.609344; |
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
| //CALCULATE AGE | |
| function birthday ($birthday){ | |
| list($year,$month,$day) = explode("-",$birthday); | |
| $year_diff = date("Y") - $year; | |
| $month_diff = date("m") - $month; | |
| $day_diff = date("d") - $day; | |
| if ($day_diff < 0 || $month_diff < 0) | |
| $year_diff--; | |
| return $year_diff; |
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
| //CONVERT CANVAS TO AN IMAGE | |
| // Converts canvas to an image | |
| function convertCanvasToImage(canvas) { | |
| var image = new Image(); | |
| image.src = canvas.toDataURL("image/png"); | |
| return image; | |
| } |
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
| //CONVERTS AN IMAGE TO CANVAS | |
| // Converts image to canvas; returns new canvas element | |
| function convertImageToCanvas(image) { | |
| var canvas = document.createElement("canvas"); | |
| canvas.width = image.width; | |
| canvas.height = image.height; | |
| canvas.getContext("2d").drawImage(image, 0, 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 | |
| try { | |
| $count = 6; | |
| $tweet=json_decode(file_get_contents("http://api.twitter.com/1/statuses/user_timeline/atrueresistance.json?count=".$count."" )); | |
| for ($i=1; $i < $count; $i++){ | |
| //Assign feed to $feed | |
| $feed = $tweet[($i-1)]->text; | |
| //Find location of @ in feed | |
| $feed = str_pad($feed, 3, ' ', STR_PAD_LEFT); //pad feed |
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
| function url_exists($url) { | |
| $hdrs = @get_headers($url); | |
| return is_array($hdrs) ? preg_match('/^HTTP\/\d+\.\d+\s+2\d\d\s+.*$/',$hdrs[0]) : false; | |
| } | |
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
| function detect_city($ip) { | |
| $default = 'UNKNOWN'; | |
| if (!is_string($ip) || strlen($ip) < 1 || $ip == '127.0.0.1' || $ip == 'localhost') | |
| $ip = '8.8.8.8'; | |
| $curlopt_useragent = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)'; | |
| $url = 'http://ipinfodb.com/ip_locator.php?ip=' . urlencode($ip); |