Skip to content

Instantly share code, notes, and snippets.

@krschmidt
krschmidt / WeeksElapsed.html
Last active August 29, 2015 14:02
Weeks Elapsed + % Elapsed
<html>
<head>
<title>Weeks Elapsed</title>
</head>
<body>
<div id="container" style="width:100%; height:50px; border:1px solid black;">
<div id="progress-bar" style="width:50%;
background-color:black;
height:50px;">
</div>
@krschmidt
krschmidt / gist:ec145651299ea34b4aba
Last active August 29, 2015 14:09
Mirroring a section of a Drupal website
wget --mirror --page-requisites --adjust-extension --convert-links -e robots=off --accept-regex '.*(section|/sites/default/files).*' --directory-prefix=section http://www.example.com/section
@krschmidt
krschmidt / delete_term_and_nodes.php
Last active August 29, 2015 14:10
Drush script to delete a taxonomy term and its children, as well as all nodes with that term
<?php
//Enter the taxonomy term ID you want to delete
$termid = -1;
$allterms = taxonomy_get_children($termid);
$allterms[] = $termid;
echo "Deleting $termid and its children\n";
echo "Deleting " . count($allterms) . " terms\n";
@krschmidt
krschmidt / brace.css
Last active January 17, 2016 05:40
Horizontal Curly Brace - works in Chrome 41
.item {
width: 200px;
}
.top {
margin-bottom: -8px;
text-align: center;
}
.borders {
border-bottom: black solid 1px;
border-left: black solid 1px;
@krschmidt
krschmidt / convertusers.sql
Created October 10, 2015 18:08
LDAP to CAS Converstion
INSERT INTO cas_user (uid, cas_name)
SELECT u.uid AS uid, u.name as cas_name
FROM users u
WHERE uid <> 0 AND
NOT EXISTS (SELECT cas_name FROM cas_user c WHERE c.cas_name = u.name) AND
u.name NOT LIKE "L0%";
@krschmidt
krschmidt / convert.sql
Created October 10, 2015 18:21
Single user local to CAS
update users set name='username' where uid=user-id;
insert into cas_user (uid, cas_name) values (user-id, 'username');
@krschmidt
krschmidt / recent-edits.sql
Last active November 7, 2015 23:38
Recent Logins and Edits to Drupal
# users without any recent edits
select u.name, u.mail, n1.uid, n1.vid, n1.nid, from_unixtime(n1.timestamp) changed
from node_revision n1, users u
where n1.uid = u.uid
and timestamp=
(select max(timestamp)
from node_revision n2
where n2.uid=n1.uid) # this selects the most recent revision for each person
and from_unixtime(n1.timestamp) < date_sub(now(), interval 30 day)
and u.status = 1 # ignore people who are blocked
@krschmidt
krschmidt / recent.py
Created November 7, 2015 23:33
Login Nag
#!/usr/bin/python
import MySQLdb
import smtplib
import re
import os
# list of users to exclude by usernames
exclusions = []
# DB stuff
@krschmidt
krschmidt / text-search.php
Created November 19, 2015 05:10
Drupal Text Search
<?php
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']);
$base_url = 'http://'.$_SERVER['HTTP_HOST'];
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION);
global $user;
if (!in_array('administrator', array_values($user->roles)) && !in_array('Admin Lite', array_values($user->roles))) {
echo "You do not have sufficient permissions to view this page. <a href='/user'>Log in</a>, or verify that you have an administrative role";
die();
@krschmidt
krschmidt / head.html
Last active July 12, 2024 10:40
Set Canonical URL via Javascript
<script type='text/javascript'>
var link = !!document.querySelector("link[rel='canonical']") ? document.querySelector("link[rel='canonical']") : document.createElement('link');
link.setAttribute('rel', 'canonical');
link.setAttribute('href', location.protocol + '//' + location.host + location.pathname);
document.head.appendChild(link);
</script>