Skip to content

Instantly share code, notes, and snippets.

View doublejosh's full-sized avatar
🎰
front-ending

Josh Lind doublejosh

🎰
front-ending
View GitHub Profile
@doublejosh
doublejosh / css_page_curl_shadow
Created May 21, 2011 18:42
Cross Browser CSS Page Curl Shadow
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Cross Browser CSS Page Curl Shadow</title>
<style type="text/css">
body{font-family: "American Typewriter","Bookman Old Style","Palatino Linotype","Palatino",Georgia,typewriter,monos;}
#page-wrap{width:960px;margin:5% auto;}
.shadow-wrap{}
@doublejosh
doublejosh / cutedate
Created June 2, 2011 02:34
takes an integer time/date and returns a user-friendly text string representation of now until then.
<?php
// -------------------- RETURN USER FRIENDLY DATE/TIME STRING -------------
function cuteDate($compared) {
if(!is_numeric($compared) || strlen(time())!=10) return 'date unknown'; // proper format check
$today= time(); // get it
$diff= $today-$compared; // subtract it
// return the cute string
switch(true) {
@doublejosh
doublejosh / block_remap
Last active October 3, 2015 02:28
Move core block settings across to a new theme
# Reset blocks to remove standard placements.
UPDATE block SET status = 0, region = -1 WHERE theme = 'OLD-THEME';
# Pull data across.
UPDATE block AS export_blocks
INNER JOIN block AS import_blocks
ON import_blocks.module = export_blocks.module
AND import_blocks.delta = export_blocks.delta
/**
* Turn decimals into fractions.
*/
function dec2frac($f) {
$base = floor($f);
if ($base) {
$out = $base . ' ';
$f = $f - $base;
}
if ($f != 0) {
@doublejosh
doublejosh / table_size
Last active May 18, 2016 19:40
Table Size on Pantheon
Query...
SELECT TABLE_NAME as name, TABLE_ROWS as rows, round(((data_length + index_length) / 1024 / 1024), 2) as size
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'tableau_pantheon_www'
AND TABLE_NAME LIKE "%revision%"
ORDER BY size desc;
LOCAL TEST:
mysql --user=root --password=root -e "SELECT UNIX_TIMESTAMP() AS timestamp, round(((data_length + index_length) / 1024 / 1024), 2) as table_size_mb, TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = 'tableau_pantheon_www' AND table_name = '***TABLE_NAME***'"
@doublejosh
doublejosh / form_cache_size_breakdown
Last active August 29, 2015 13:57
Form Cache Table Size Breakdown
LOCAL...
mysql -uroot -proot tableau_pantheon_www -e "select cid, LENGTH(data) as length_data, serialized, expire, created INTO OUTFILE '/Users/***USER***/Documents/Tableau/form_cache_size-local.csv' FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' from cache_form"
LOCAL WITH OUT OUTFILE...
mysql -uroot -proot tableau_pantheon_www -e "select cid, LENGTH(data) as length_data, serialized, expire, created from cache_form" > /Users/jlind/Documents/Tableau/form_cache_size-local.txt
REMOTE...
mysql -upantheon -p***PASS*** -h dbserver.live.***HASH***.drush.in -P ***PORT*** pantheon -e "select cid, LENGTH(data) as length_data, serialized, expire, created from cache_form" > /Users/***USER***/Documents/Tableau/form_cache_size-live.txt
@doublejosh
doublejosh / gist:9898601
Last active August 29, 2015 13:57
HTML Emails Suck
Main things to keep in mind, since they're hard to believe...
1. Only use inline style.
2. Just give in and nest tables. It's terrible, but reliable everywhere.
3. Margin and padding is not completely supported (depending on DOM element).
Mostly just not Outlook > 2003, which is insane.
4. Apply style to divs and not many other tags.
@doublejosh
doublejosh / omghosts
Last active August 29, 2015 13:59 — forked from angrytoast/omghosts
Never accidentally leave your /etc/hosts file edited again!!! Let your computer remind you.
#! /usr/bin/env bash
GOLDEN_DOMAIN="example.com"
PROBLEM="$(cat /etc/hosts | grep $GOLDEN_DOMAIN | grep -v '^#' | wc -w)"
if [ "$PROBLEM" -gt 0 ]; then
say omg fix yer hosts
fi
@doublejosh
doublejosh / get_any_object.php
Last active August 29, 2015 14:01
Agnostic current entity loader function
<?php
/**
* Utility function to agnosticly get the current menu object.
* Structured like menu_get_object(), but the passed type will be set for you.
*
* @param string (reference) $return_type
*
* return object
* Entity object of current menu callback page.
*/
@doublejosh
doublejosh / CollectionClass.js
Last active August 29, 2015 14:02
Ultra-light-weight basic object convenience methods class.
Collection = function (obj) {
// Private vars.
var keyList = null,
length = null;
// Public functions.
return {
/**