Skip to content

Instantly share code, notes, and snippets.

@iwek
iwek / pinterest-2.js
Last active December 14, 2015 13:19
Organize or Sort Pinterest Images by Repins
//cleanup and sort elemets that have repins
//grab all pins
var mylist = $('.Pin');
//find all pins that have repins
var listitems = mylist.find('.socialItem');
var list = listitems.filter(function(f,i){
var test = Number( $(i).text().trim().replace("repins", "").replace("repin", "") );
if(test>0){
@iwek
iwek / pinterest-3.js
Last active December 14, 2015 13:19
Show the sorted images on Pinterest
//empty main section
$(".Grid").before('<div id="organized"/>').remove();
//append sorted items
$.each(list, function(idx, itm) {
$("#organized").append($(itm).parents('.Pin'));
});
//style it up
$('.Pin').css({'clear': 'both', 'position': 'static'});
@iwek
iwek / pinterest-4.js
Last active December 14, 2015 13:19
Sort and Organize Pinterest Images by Likes
//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) {
@iwek
iwek / lastfm-api.php
Last active January 30, 2023 21:00
Last FM API script in PHP to pull album and artist artwork.
<?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) {
@iwek
iwek / php-curl.php
Created March 8, 2013 15:11
PHP Curl Example with Error Checking
<?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);
@iwek
iwek / traceroute.php
Last active April 1, 2020 15:03
PHP Curl call to get a Traceroute with Pingdom API
<?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"));
@iwek
iwek / traceroute.php
Last active December 3, 2022 14:03
PHP Script for Traceroute Pingdom API
<?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;
@iwek
iwek / mysql-import-csv
Created March 8, 2013 17:16
Importing MaxMind GeoIP Lite CSV file into MySQL
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`)
@iwek
iwek / maxmind.php
Created March 11, 2013 20:30
Retrieve Location from MaxMind Database in MySQL with PHP
<?php
//check the POST
$ips = $_POST["ips"];
if (empty($ips)) {
echo 'Please provide ips.';
} else {
//connect to mysql and select the maxmind database
@iwek
iwek / geo-convert.js
Created March 18, 2013 18:43
JavaScript Geographic Coordinate Conversion
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;
}