Skip to content

Instantly share code, notes, and snippets.

@doofusdavid
doofusdavid / gist:1f7ef20be09f599b19a9
Created October 2, 2015 00:25
stored procedure to create a bunch of ratings
DELIMITER $$
CREATE DEFINER=`root`@`%` PROCEDURE `new_procedure`()
BEGIN
DECLARE counter int;
set counter = 0;
while counter < 1000000 do
insert into Rating (Rating, MovieID) VALUES (truncate(rand()*10, 0), 1);
set counter=counter+1;
end while;
@doofusdavid
doofusdavid / gist:cd2dfb6cae53100b9631
Created September 9, 2015 23:33
PHP Array of the Raven
$raven = array(
"Once upon a midnight dreary, while I pondered, weak and weary,",
"Over many a quaint and curious volume of forgotten lore-",
" While I nodded, nearly napping, suddenly there came a tapping,",
"As of some one gently rapping, rapping at my chamber door.",
"\"'Tis some visitor,\" I muttered, \"tapping at my chamber door-",
" Only this and nothing more.\"",
"",
" Ah, distinctly I remember it was in the bleak December;",
@doofusdavid
doofusdavid / slugify
Created July 29, 2013 16:30
mysql function to create wordpress slug from text. Taken from here: http://stackoverflow.com/questions/5409831/mysql-stored-function-to-create-a-slug
DROP FUNCTION IF EXISTS `slugify`;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost`
FUNCTION `slugify`(dirty_string varchar(200))
RETURNS varchar(200) CHARSET latin1
DETERMINISTIC
BEGIN
DECLARE x, y , z Int;
Declare temp_string, new_string VarChar(200);
Declare is_allowed Bool;
@doofusdavid
doofusdavid / gist:6074454
Created July 24, 2013 20:53
VBScript version of WordPress' santitize_title_with_dashes
Function sanitize_title_with_dashes(title As String) As String
Dim oDoc As HTMLDocument
Set oDoc = New HTMLDocument
oDoc.body.innerHTML = title
title = oDoc.body.innerText
title = LCase(title)
@doofusdavid
doofusdavid / gist:6072257
Created July 24, 2013 16:42
quick and dirty wordpress slug generator in excel for data import from an existing database.
=LOWER(CLEAN(SUBSTITUTE(TRIM(C2)," ","-")))
@doofusdavid
doofusdavid / gist:6072250
Created July 24, 2013 16:41
Syntax for creating multi-table insert statements to import information into wordpress. This is an excel function.
=CONCATENATE("INSERT INTO wp_3_terms (name, slug) values ('",C2,"', '",E2,"');","
SET @LASTID = LAST_INSERT_ID();","
INSERT INTO wp_3_term_taxonomy (term_id, taxonomy,parent,count) VALUES(@LASTID, 'media_source', 0,0);",
"INSERT INTO wp_3_pods_media_source (@LASTID, ",A2,");")