Skip to content

Instantly share code, notes, and snippets.

View devuri's full-sized avatar

uri devuri

  • Mexico
View GitHub Profile
@devuri
devuri / functions.php
Created August 30, 2018 18:03 — forked from danieliser/functions.php
Plugins API Active Install Count Shortcode for WordPress
<?php
function plugin_install_count_shortcode( $atts ) {
$a = shortcode_atts( array(
'plugin' => NULL,
), $atts );
if( ! $a['plugin'] ) {
return;
}
@devuri
devuri / class-search.php
Created August 26, 2018 01:54 — forked from arsonus/class-search.php
A PHP script to search a MySQL database
<?php
/**
* Performs a search
*
* This class is used to perform search functions in a MySQL database
*
* @version 1.0
* @author John Morris <[email protected]>
*/
class search {
@devuri
devuri / LiveSearch.php
Created August 26, 2018 01:52 — forked from hirshagarwal/LiveSearch.php
Live Search mySQL Database (PHP)
<?php
/* Created by Hirsh Agarwal of H2 Micro (www.h2micro.com) */
//Call the function every time the search query is updated
function search ($searchQuery){
//Fields
$searchResult = array();
//Define Server Variables
@devuri
devuri / github-gist-api.js
Created August 24, 2018 14:23 — forked from techslides/github-gist-api.js
GitHub API to make Gists with Ajax
/*
Assuming jQuery Ajax instead of vanilla XHR
*/
//Get Github Authorization Token with proper scope, print to console
$.ajax({
url: 'https://api.github.com/authorizations',
type: 'POST',
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa("USERNAME:PASSWORD"));
#Get the size of each table, ordered by largest to smallest
SELECT table_name AS "Tables",
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"
FROM information_schema.TABLES
WHERE table_schema = "YOU+TABLE+NAME+HERE"
ORDER BY (data_length + index_length) DESC;
#Get the size of the entire DB
SELECT table_schema "DB Name",
Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB"
@devuri
devuri / gist:0e45c7324ee3d48ccc400d4f7676ce05
Created August 19, 2018 19:48 — forked from webaware/gist:3110728
basic example of populating a form from a database using AJAX and JSON
<?php
/*
-- the SQL database table
create table form_ajax (
ID varchar(5) not null,
Name varchar(100),
Address varchar(100),
Phone varchar(20),
Email varchar(255),
CREATE TABLE IF NOT EXISTS `country` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`iso` char(2) NOT NULL,
`name` varchar(80) NOT NULL,
`nicename` varchar(80) NOT NULL,
`iso3` char(3) DEFAULT NULL,
`numcode` smallint(6) DEFAULT NULL,
`phonecode` int(5) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@devuri
devuri / README.md
Created August 19, 2018 16:56 — forked from hofmannsven/README.md
My simply MySQL Command Line Cheatsheet
@devuri
devuri / wordpress-firebase.php
Created August 13, 2018 02:59 — forked from derekconjar/wordpress-firebase.php
An example of using Firebase and WordPress together. The idea is to use WP's custom post types and metaboxes to make content management easy, and sync with Firebase so that your websites have access to a real-time JSON feed of your custom data.
<?php
/**
* All custom functions should be defined in this class
* and tied to WP hooks/filters w/in the constructor method
*/
class Custom_Functions {
// Custom metaboxes and fields configuration
@devuri
devuri / DomXpath.php
Created July 14, 2018 05:01 — forked from jmoz/DomXpath.php
DomXpath example
<?php
/**
* @author James Morris <[email protected]>
*/
$html = <<<'EOF'
<html>
<body>
<h1>Foo</h1>
<div id="content">