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) { |
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
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 | |
require('simpleCache.php'); | |
$cache = new SimpleCache(); | |
$minx = $_GET['minx']; | |
$maxx = $_GET['maxx']; | |
$miny = $_GET['miny']; |
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 | |
add_action('activated_plugin','save_error'); | |
function save_error(){ | |
file_put_contents(ABSPATH. 'wp-content/plugins/PLUGIN_FOLDER/error.html', ob_get_contents()); | |
} | |
?> |
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 | |
add_action('admin_menu', 'plugin_admin_add_page'); | |
function plugin_admin_add_page() { | |
add_options_page('Custom Plugin Page', 'Custom Plugin Options Page', 'manage_options', 'page_slug', 'plugin_options_page'); //settings menu page | |
} | |
function plugin_options_page() { | |
//HTML and PHP for Plugin Admin Page | |
echo "<h2>The Custom Plugin Options Page</h2>"; | |
} |
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 | |
//http://codex.wordpress.org/Class_Reference/wpdb | |
global $wpdb; | |
echo "<h2>Plugin Admin Page</h2>"; | |
$arr = $wpdb->get_results("SELECT * FROM $wpdb->users"); | |
echo '<div id="dt_example"><div id="container"><form><div id="demo">'; | |
echo '<table cellpadding="0" cellspacing="0" border="0" class="display" id="example"><thead><tr>'; |
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 | |
/** | |
* @package Quick Contact | |
* @version 0.1 | |
*/ | |
/* | |
Plugin Name: Quick Contact | |
Plugin URI: http://techslides.com/ | |
Description: Quick Contact WordPress Plugin to make an Ajax form submission, store it in the database, and show it in a Admin backend page. | |
Version: 0.1 |
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 f(y) { | |
var z = 1; | |
return function g(y) { | |
alert(y + z); | |
} | |
} | |
var z=10; | |
f(); //returns the function: function g(y) {alert(y + z);} | |
f()(2); //grabs function g, assings 2 to y, knows z is 1 through closure scope and makes an alert(3) |
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
d3.select("#save").on("click", function(){ | |
var html = d3.select("svg") | |
.attr("version", 1.1) | |
.attr("xmlns", "http://www.w3.org/2000/svg") | |
.node().parentNode.innerHTML; | |
//console.log(html); | |
var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html); | |
var img = '<img src="'+imgsrc+'">'; | |
d3.select("#svgdataurl").html(img); |