This file contains 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
//simple XHR request in pure JavaScript | |
function load(url, callback) { | |
var xhr; | |
if(typeof XMLHttpRequest !== 'undefined') xhr = new XMLHttpRequest(); | |
else { | |
var versions = ["MSXML2.XmlHttp.5.0", | |
"MSXML2.XmlHttp.4.0", | |
"MSXML2.XmlHttp.3.0", | |
"MSXML2.XmlHttp.2.0", |
This file contains 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
<!--HTML file--> | |
<!DOCTYPE html> | |
<script> | |
//define a worker | |
var worker = new Worker('worker.js'); | |
worker.addEventListener('message', function(e) { | |
console.log('Worker said: ', e.data); | |
}, false); |
This file contains 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 convert(geo){ | |
var latlonrg = /(\d+(?:\.\d+)?)[\xb0\s]?\s*(?:(\d+(?:\.\d+)?)['\u2019\u2032\s])?\s*(?:(\d+(?:\.\d+)?)["\u201d\u2033\s])?\s*([SNEW])?/i; | |
var m = String(geo).split(latlonrg), | |
lat = m && +m[1] + (m[2] || 0) / 60 + (m[3] || 0) / 3600; | |
if (m[4].toUpperCase() == "S") { | |
lat = -lat; | |
} | |
This file contains 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 | |
//check the POST | |
$ips = $_POST["ips"]; | |
if (empty($ips)) { | |
echo 'Please provide ips.'; | |
} else { | |
//connect to mysql and select the maxmind database |
This file contains 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
mysql -u root -p root; | |
USE maxmind; | |
DROP TABLE IF EXISTS `blocks`; | |
CREATE TABLE `blocks` ( | |
`startIPNum` int(10) unsigned NOT NULL, | |
`endIPNum` int(10) unsigned NOT NULL, | |
`locID` int(10) unsigned NOT NULL, | |
PRIMARY KEY (`startIPNum`,`endIPNum`) |
This file contains 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 | |
$host = $_GET["host"]; | |
if (empty($host)) { | |
echo 'Please provide host'; | |
} else { | |
//create the url for API call | |
$url = "https://api.pingdom.com/api/2.0/traceroute?host=".$host; |
This file contains 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 | |
//initialize | |
$ch = curl_init(); | |
// 2. set the options, including the url | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_URL, "https://api.pingdom.com/api/2.0/traceroute?host=techslides.com"); | |
curl_setopt($ch, CURLOPT_USERPWD, "EMAIL:PASSWORD"); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("App-Key: YOUR-KEY-HERE")); |
This file contains 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 | |
//initialize | |
$ch = curl_init(); | |
// 2. set the options, including the url | |
curl_setopt($ch, CURLOPT_URL, "https://api.pingdom.com/api/2.0/traceroute?host=techslides.com"); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("App-Key: YOUR-KEY-HERE")); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_HEADER, 0); |
This file contains 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 | |
//get artist photo | |
function getArtistPhoto($artist, $size) { | |
$artist = urlencode($artist); | |
$xml = "http://ws.audioscrobbler.com/2.0/?method=artist.getinfo&artist={$artist}&api_key=YOUR_KEY"; | |
$xml = @file_get_contents($xml); | |
if(!$xml) { |
This file contains 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
//cleanup for likes | |
$(".likes").each(function() { | |
var num = Number($(this).text().trim().replace("likes", "").replace("like", "")); | |
$(this).html(num); | |
}); | |
//sort | |
var mylist = $('.Pin'); | |
var listitems = mylist.find('.likes:not(:contains(0))'); //do not match on elements that have 0 likes | |
listitems.sort(function(a, b) { |