Skip to content

Instantly share code, notes, and snippets.

Avatar

Evan Donovan evandonovan

View GitHub Profile
@evandonovan
evandonovan / user-profile.tpl.php
Created May 19, 2010 22:42
user-profile.tpl.php with embedded view
View user-profile.tpl.php
<?php
// $Id: user-profile.tpl.php,v 1.2.2.1 2008/10/15 13:52:04 dries Exp $
/**
* @file user-profile.tpl.php
* Default theme implementation to present all user profile data.
*
* This template is used when viewing a registered member's profile page,
* e.g., example.com/user/123. 123 being the users ID.
*
View wget-entire-website.sh
#!/bin/sh
# get entire website via wget
# from https://www.linuxjournal.com/content/downloading-entire-web-site-wget
# replace EXAMPLE.COM with your site
wget \
--recursive \
--no-clobber \
--page-requisites \
--html-extension \
--convert-links \
@evandonovan
evandonovan / menu-include.js
Created May 21, 2019 01:47
Javascript to dynamically include content on an Unbounce page
View menu-include.js
/* Example code - by Evan Donovan, public domain
Adjust the paths and selectors below as needed.
*/
/**
* Get HTML from another URL -
* Uses the vanilla JS XMLHttpRequest
* https://gomakethings.com/ditching-jquery/#get-html-from-another-page
* The first parameter is a URL to fetch, the second is the JS function that is called to handle the data that is received.
* @param {String} url The URL
@evandonovan
evandonovan / themename_addressfield_formatter__components.php
Created January 10, 2019 03:54
Cleaner formatting for addressfield (plus RDFa microdata)
View themename_addressfield_formatter__components.php
// Override addressfield_tokens themeing function
// Requires addressfield_tokens module as well as addressfield
// Add to template.php and change THEMENAME to name of your theme, then clear cache
function THEMENAME_addressfield_formatter__components($vars) {
$loc = $vars['address'];
$out = '';
// Note added RDFa microdata - https://schema.org/PostalAddress
// Organization name if present (nothing in first or last name fields)
@evandonovan
evandonovan / gist:6135344
Created August 1, 2013 21:08
Web crawler
View gist:6135344
## Task class
require 'mysql'
module OrgSocGraph
FIELDS = {
"orgs.csv" => [
Class.new(Object) do
def name
:description
end
View moodle_rysnc.sh
#!/usr/bin/expect -f
# exp_internal 1 ;# uncomment to turn on expect debugging
set timeout -1
USER="user"
HOST="127.0.0.1"
SRC="/src/dir/here"
DST="/dst/dir/here"
# creates an rsync process that will rsync with excluded directories
View db_backup.sh
#! /bin/bash
# set user
USER="usr"
# set port
PORT="22"
# set remote IP (put yours here)
HOST="127.0.0.1"
@evandonovan
evandonovan / gist:6135556
Created August 1, 2013 21:33
DMOZ scraper
View gist:6135556
module DMOZ
FIELDS = {
"dmoz.csv" => [
Class.new(Object) do
def name
:title
end
end.new,
Class.new(Object) do
def name
@evandonovan
evandonovan / gist:6135383
Created August 1, 2013 21:12
JobExecutor code
View gist:6135383
class JobExecutor
attr_reader :data_store, :fields
def initialize(fields)
@jobs = []
@threads_working = 0
@lock = Mutex.new
@data_store = DataStore.new(fields)
@fields = fields
@evandonovan
evandonovan / gist:1562280
Created January 4, 2012 21:37
Leads code for Round Robin Record Assignment
View gist:1562280
// leadsRoundRobin.trigger:
trigger leadRoundRobin on Lead (before insert, before update) {
//
//Check if assignment owner has changed
//
Map<Integer,Id> queueIds = new Map<Integer,Id>(); //Trigger index --> Queue ID
Integer idx = 0;
for (Lead l : Trigger.new)