Skip to content

Instantly share code, notes, and snippets.

View mtetlow's full-sized avatar

Mike "Mikename" Tetlow mtetlow

  • AscendX
  • Denver CO
View GitHub Profile
@mtetlow
mtetlow / gist:2775527
Created May 23, 2012 14:31 — forked from stackdump/gist:1479007
List local memcached keys using Ruby
#!/usr/bin/env ruby
require 'net/telnet'
cache_dump_limit = 100
localhost = Net::Telnet::new("Host" => "localhost", "Port" => 11211, "Timeout" => 3)
slab_ids = []
localhost.cmd("String" => "stats items", "Match" => /^END/) do |c|
matches = c.scan(/STAT items:(\d+):/)
slab_ids += matches
end
@mtetlow
mtetlow / ApexRESTExample.cls
Created April 10, 2013 14:41
The goal of this gist is to describe how to query an object within a SFDC Managed Package, with a user who is not licensed for access to the managed project. There are two components, an apex class containing a custom REST endpoint, and a VisualForce Page where we hit the SF AJAX Proxy enroute to the SF REST API.
@RestResource(urlMapping='/RestTest/*')
global with sharing class ApexRESTExample {
@HttpGet
global static List<NAMESPACE__ManagedPackageObject__c> getTasks() {
List<NAMESPACE__ManagedPackageObject__c> test = [SELECT Id, Name from NAMESPACE__ManagedPackageObject__c];
return test;
}
}
@mtetlow
mtetlow / customTriggerTests.cls
Created April 19, 2013 18:58
TaskRay add Project Name as a Task Tag
@isTest
private class customTriggerTests{
@isTest
static void tagAdditionOnTaskAdd_test(){
//Insert a project
TASKRAY__Project__c project = new TASKRAY__Project__c(Name='Test Project', TASKRAY__Status__c = false);
insert project;
//get the id of the newly inserted project
Id projectId = project.Id;
//Add a task to the new project
@mtetlow
mtetlow / exampleJS.js
Created June 3, 2013 15:54
This is a first pass at creating a Salesforce.com APEX Remote Action wrapper for jQuery deferred objects. This will allow you to utilize the jQuery.deferred methods (http://api.jquery.com/category/deferred-object/), and avoid lengthy strings of callback methods.
function remoteActionDeferredWrap(remoteActionMethod, paramArr, escape){
//Create the deferred object
var deferredObj=$j.Deferred();
//Create the callback method, this will manipulate the deferred object to show when complete
var callback = function(result,status){
if(status.status==true){
deferredObj.resolve(result);
}
else{
deferredObj.reject('Error: '+status.message);
function getLocaleDateString(){
var formats ={"ar-SA":"dd/mm/yy","bg-BG":"dd.m.yyyy","ca-ES":"dd/mm/yyyy","zh-TW":"yyyy/m/d","cs-CZ":"d.m.yyyy",
"da-DK":"dd-mm-yyyy","de-DE":"dd.mm.yyyy","el-GR":"d/m/yyyy","en-US":"m/d/yyyy","fi-FI":"d.m.yyyy","fr-FR":"dd/mm/yyyy",
"he-IL":"dd/mm/yyyy","hu-HU":"yyyy. mm. dd.","is-IS":"d.m.yyyy","it-IT":"dd/mm/yyyy","ja-JP":"yyyy/mm/dd",
"ko-KR":"yyyy-mm-dd","nl-NL":"d-m-yyyy","nb-NO":"dd.mm.yyyy","pl-PL":"yyyy-mm-dd","pt-BR":"d/m/yyyy",
"ro-RO":"dd.mm.yyyy","ru-RU":"dd.mm.yyyy","hr-HR":"d.m.yyyy","sk-SK":"d. m. yyyy","sq-AL":"yyyy-mm-dd",
"sv-SE":"yyyy-mm-dd","th-TH":"d/m/yyyy","tr-TR":"dd.mm.yyyy","ur-PK":"dd/mm/yyyy","id-ID":"dd/mm/yyyy",
"uk-UA":"dd.mm.yyyy","be-BY":"dd.mm.yyyy","sl-SI":"d.m.yyyy","et-EE":"d.mm.yyyy","lv-LV":"yyyy.mm.dd.",
"lt-LT":"yyyy.mm.dd","fa-IR":"mm/dd/yyyy","vi-VN":"dd/mm/yyyy","hy-Am":"dd.mm.yyyy","az-Latn-AZ":"dd.mm.yyyy",
"eu-ES":"yyyy/mm/dd","mk-mK":"dd.mm.yyyy","af-ZA":"yyyy/mm/dd","ka-GE":"dd.mm.yyyy","fo-FO":"dd-mm-yyyy",
Pattern tagSafe = Pattern.compile('[a-zA-Z\\s\\d\\-_]');
Matcher tagSafeMatcher = tagSafe.matcher('Pyramid Construction Inc1234_-.');
String[] strArr = new String[]{};
while(tagSafeMatcher.find()){
system.debug(tagSafeMatcher.group(0));
strArr.add(tagSafeMatcher.group(0));
}
system.debug(String.join(strArr,''));
Pattern tagSafe = Pattern.compile('[a-zA-Z\\s\\d\\-_]');
Matcher tagSafeMatcher = tagSafe.matcher('Pyramid Construction Inc1234_-.');
String[] strArr = new String[]{};
while(tagSafeMatcher.find()){
system.debug(tagSafeMatcher.group(0));
strArr.add(tagSafeMatcher.group(0));
}
system.debug(String.join(strArr,''));
//Kick off with
Database.executeBatch(new batchUpdate(),50);
//Class like this
global class batchUpdate implements Database.Batchable<sObject> {
// This method returns a SOQL query locator containing the records
// to be iterated
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator([SELECT Id,Something__c FROM CustomObj__c]);
//Setup -> Customize -> Chatter -> Feed tracking
//Enable feed tracking on TaskRay History, TaskRay Project Notification, TaskRay Task Notification, and TaskRay View Project objects
List<TASKRAY__trHistory__Feed> historyFeed = [SELECT Id FROM TASKRAY__trHistory__Feed];
delete historyFeed;
List<TASKRAY__trTaskNotification__Feed> taskNotificationFeed = [SELECT Id FROM TASKRAY__trTaskNotification__Feed];
delete taskNotificationFeed;
List<TASKRAY__trProjectNotification__Feed> projectNotificationFeed = [SELECT Id FROM TASKRAY__trProjectNotification__Feed];
@font-face {
font-family: 'icomoon';
src: url('fonts/icomoon.eot');
}
@font-face {
font-family: 'icomoon';
src: url(data:application/x-font-ttf;charset=utf-8;base64,AAEAAAALAIAAAwAwT1MvMg6v8ywAAAC8AAAAYGNtYXDgfOaMAAABHAAAAERnYXNwAAAAEAAAAWAAAAAIZ2x5ZlRMFxoAAAFoAAA6WGhlYWQASAk3AAA7wAAAADZoaGVhB8ID+wAAO/gAAAAkaG10eOIADMUAADwcAAAA6GxvY2GdD5AIAAA9BAAAAHZtYXhwAEMBLQAAPXwAAAAgbmFtZUQXtNYAAD2cAAABOXBvc3QAAwAAAAA+2AAAACAAAwQAAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAACDmAgPA/8D/wAPAAEAAAAAAAAAAAAAAAAAAAAAgAAAAAAACAAAAAwAAABQAAwABAAAAFAAEADAAAAAIAAgAAgAAACDgNOYC//8AAAAg4ADmAP///+EgAho3AAEAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQBRABEDrgNuAFMAAAEuASIGBwEOARQWFx4BMjY3AT4BNCYnLgEiBg8BDgEUFhceATI2PwE+ATIWFx4BFAYHAQ4BIiYnLgE0NjcBPgEyFhceARQGDwEeAxc3PgE0JicDrihmamYp/isoKCgoKWZqZigBIBkZGRkZP0I/GbQKCgoKCRcYFwm1BhAQEAYGBgYG/uAWNzk3FhYWFhYB1RY3OTcWFhYWFgQLEQwHAS4pKSkpA24pKSkp/isoZmpmKSgoKCgBIBk/Qj8ZGRkZGbUJFxgXCQoKCgq0BgYGBgYQEBAG/uEWFhYWFjc5NxYB1RYWFhYWNzk3FgQPICIjEi4pZmpmKAA