Skip to content

Instantly share code, notes, and snippets.

@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,");")
@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: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 / 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: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 / 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;
CREATE TABLE `movies` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`MovieName` varchar(45) DEFAULT NULL,
`Rating` double DEFAULT NULL,
`DateAdded` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
CREATE TABLE `Rating` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
@doofusdavid
doofusdavid / filecount.gs
Created February 13, 2017 22:59
Google Script to get file counts.
/**
* Google Apps Script - List all files & folders in a Google Drive folder, & write into a speadsheet.
* - Main function 1: List all folders
* - Main function 2: List all files & folders
*
* Hint: Set your folder ID first! You may copy the folder ID from the browser's address field.
* The folder ID is everything after the 'folders/' portion of the URL.
*
* @version 1.0
* @see https://github.com/mesgarpour
@doofusdavid
doofusdavid / speedtest.py
Created October 29, 2017 23:32
Take a speedtest and post the speed on Twitter
#!/usr/bin/python
import os
import sys
import csv
import datetime
import time
import twitter
def test():
cat ~/.ssh/id_rsa.pub | ssh user@hostname 'cat >> .ssh/authorized_keys'