Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am rootl on github.
  • I am rhela (https://keybase.io/rhela) on keybase.
  • I have a public key ASAlvhdFOlcta0-M-GhygWNf_avSCqZ3h9_J655OYBppHwo

To claim this, I am signing this object:

@rootl
rootl / Pressbooks_Export_Example2pdf.css
Last active April 20, 2017 14:54
Pressbooks PDF Export Custom CSS Example 2 (book site reference: "milnepublishing.geneseo.edu/concise-introduction-to-logic")
/*
Theme Name: Luther PDF
Theme URI: http://pressbooks.com/
Description: Named after Martin Luther, this is a traditional book theme, good for novels, and text-heavy non-fiction. An earlier version of this theme was commissioned by Fortress Press / Augsburg Fortress.
Author: Pressbooks (Book Oven Inc.)
Author URI: http://pressbooks.com
Copyright 2011-2015 Book Oven Inc. (Pressbooks.com) code@pressbooks.com
Version: 1.4
*/
/*
@rootl
rootl / Pressbooks_Export_Example1pdf.css
Created April 20, 2017 14:47
Pressbooks PDF Export Custom CSS Example 1 (book site reference: "the-evolution-of-our-tribe-hominini")
/*
Theme Name: Luther PDF
Theme URI: http://pressbooks.com/
Description: Named after Martin Luther, this is a traditional book theme, good for novels, and text-heavy non-fiction. An earlier version of this theme was commissioned by Fortress Press / Augsburg Fortress.
Author: Pressbooks (Book Oven Inc.)
Author URI: http://pressbooks.com
Copyright 2011-2015 Book Oven Inc. (Pressbooks.com) code@pressbooks.com
Version: 1.4
*/
/*
@rootl
rootl / WP-Query-Download-Type-SUM-AVG-Day-Month
Last active March 30, 2016 14:19
MySQL WordPress sanitized Query for SUM, AVG of Downloads by Download Type. NOTES: Additional Types (ie HTML or Source Code) can be added. Query qepends on Download Monitor and Posts2Posts plugin for other WP users' ease of adding files and assigning them to posts. Grouping won't work here so I use CASE. Future plans: 1) Remove excess JOINS on t…
global $wpdb;
$result = $wpdb->get_results("
SELECT p.post_title AS 'Title',
SUM(CASE WHEN t.name = 'PDF' THEN m.meta_value ELSE NULL END) as 'PDF',
SUM(CASE WHEN t.name = 'EPUB' THEN m.meta_value ELSE NULL END) as 'EPUB',
SUM(m.meta_value) AS 'Totals',
round(AVG((m.meta_value)/180)) as 'DailyAvg',
round(AVG((m.meta_value)/30)) as 'MonthlyAvg',
r.p2p_from AS 'From'
FROM
@rootl
rootl / AVG-MED-MIN-MAX-MONTH-YEAR
Last active March 30, 2016 14:13
Query for SQL 2012 : Percentile_DISC function for median; sum, min, max, avg queries grouped by month and year. I will also post a version for sql versions lower than 2012 that cannot use percentile. Notes: 1) "DailyDiff" is a computed column using "PMCounts-AMCounts/2" to obtain the GateCount Daily Difference. 2) DB isn't partitioned so I had t…
SELECT
Year([Date]) GC_Year,
Month([Date]) GC_Month,
DATENAME(month,[Date]) Month_Name,
SUM(DailyDiff) AS GateCounts_MonthlyTotal,
MIN(DailyDiff) AS GateCounts_MIN,
MAX(DailyDiff) AS GateCounts_MAX,
AVG(DailyDiff) AS GateCounts_AVG,
GateCounts_MED=MAX(Median)
@rootl
rootl / LibraryHoursExceptionsAdmin.sql
Last active March 30, 2016 13:48
MySQL query to join date ranges with exceptions. Used for Library Hours Webservice with PHP based admin panel. The user will see a date range row listing library hours during that date range, along with any exceptions such as closings, holiday hours, extended hours.
CREATE TABLE IF NOT EXISTS `dayrangehours` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`StartDate` date NOT NULL,
`EndDate` date NOT NULL,
`MonStartT` time DEFAULT NULL,
`MonEndT` time DEFAULT NULL,
`TuesStartT` time DEFAULT NULL,
`TuesEndT` time DEFAULT NULL,
`WedStartT` time DEFAULT NULL,
`WedEndT` time DEFAULT NULL,
@rootl
rootl / HeadCountsMilneFraser.sql
Last active March 30, 2016 13:49
SQL 2012 Milne and Fraser Daily and Hourly Totals. Milne 3 Floors totals caclulated, totalled, joined and added to corresponding Fraser totals.
CREATE TABLE HeadCountsMilne
(
ID int identity(1,1) not null primary key,
Date datetime,
Hour varchar(50),
FirstFloor int,
MainFloor int,
ThirdFloor int,
TotalMilneThreeFloors int,
@rootl
rootl / 0_reuse_code.js
Last active September 16, 2015 12:45
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console