Skip to content

Instantly share code, notes, and snippets.

View evandonovan's full-sized avatar

Evan Donovan evandonovan

View GitHub Profile
<?php
// convenience theming function for taxonomy lists -- ead 6.10.10
function taxonomy_node_list_terms_by_vocabulary($nid, $voc_id, $link = FALSE, $ul = FALSE) {
/* loads a "dummy" node in order to use taxonomy_node_get_terms_by_vocabulary()
to get an array of taxonomy terms */
$node = new stdClass();
$node->vid = db_result(db_query("SELECT MAX(vid) FROM {node_revisions} WHERE nid = %d", $nid));
$terms = taxonomy_node_get_terms_by_vocabulary($node, $voc_id);
if(!isset($terms) || !is_array($terms) || empty($terms)) { return ''; }
@evandonovan
evandonovan / location.inc.php
Created June 30, 2010 20:04
Feeds mapping for location_cck.module
<?php
// $Id$
/**
* @file
* On behalf implementation of Feeds mapping API for location_cck.module (Location CCK).
*/
/**
* Implementation of hook_feeds_node_processor_targets_alter().
@evandonovan
evandonovan / TestCityvisionScheduledTasks.cls
Created December 15, 2011 22:46
Test for my scheduled Apex
@isTest
private class TestCityvisionScheduledTasks {
// just tests whether the scheduled classes run.
static testMethod void testRunsScheduled() {
CityvisionScheduledLeadScorer cvSLS = new CityvisionScheduledLeadScorer();
String sch = '0 0 23 * * ?';
Test.startTest();
Id jobId = System.schedule('City Vision Lead Scoring', sch, cvSLS);
@evandonovan
evandonovan / gist:1515657
Created December 23, 2011 23:26
Assignment of Contacts Class
/* Class */
public with sharing class CityvisionContactAssigner {
static final Id OWNER_NYOUNG;
static final Id OWNER_AWEBB;
static {
List<User> users = [SELECT Id, Alias FROM User WHERE Alias = 'nyoung' OR Alias = 'awebb' OR Alias = 'MOmori' OR Alias = 'ASears'];
for(User u : users) {
// Switch which user to use based on whether we are in production environment, since partner users don't carry across to sandboxes.
if((CityvisionConstants.onProduction == true && u.Alias == 'nyoung')
@evandonovan
evandonovan / gist:1562280
Created January 4, 2012 21:37
Leads code for Round Robin Record Assignment
// 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)
@evandonovan
evandonovan / gist:6135344
Created August 1, 2013 21:08
Web crawler
## Task class
require 'mysql'
module OrgSocGraph
FIELDS = {
"orgs.csv" => [
Class.new(Object) do
def name
:description
end
@evandonovan
evandonovan / gist:6135383
Created August 1, 2013 21:12
JobExecutor code
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:6135556
Created August 1, 2013 21:33
DMOZ scraper
module DMOZ
FIELDS = {
"dmoz.csv" => [
Class.new(Object) do
def name
:title
end
end.new,
Class.new(Object) do
def name
#! /bin/bash
# set user
USER="usr"
# set port
PORT="22"
# set remote IP (put yours here)
HOST="127.0.0.1"
#!/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