Skip to content

Instantly share code, notes, and snippets.

@fractastical
fractastical / @umityalcinalp URLRewriter.txt
Created May 24, 2011 21:38
@umityalcinalp URLRewriter
http://blog.sforce.com/sforce/2010/05/url-rewriting-for-your-customizing-your-site-urls.html
global class ApexClassName implements Site.UrlRewriter {
global PageReference mapRequestUrl(PageReference externalUrl) {//}
global List<PageReference> generateUrlFor(List<PageReference> myForcedotcomUrls) {//...}
}
@fractastical
fractastical / Apex-Lang List Functions (Merge, etc.) .txt
Created May 24, 2011 21:38
Apex-Lang List Functions (Merge, etc.)
/* ============================================================
* This code is part of the "apex-lang" open source project avaiable at:
*
* http://code.google.com/p/apex-lang/
*
* This code is licensed under the Apache License, Version 2.0. You may obtain a
* copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
* ============================================================
@fractastical
fractastical / boyd_r URL Navigation for Custom Objects.txt
Created May 24, 2011 21:38
boyd_r URL Navigation for Custom Objects
http://bit.ly/cj450K
//Get a reference to the Custom Object and gets its Key
Schema.DescribeSObjectResult result = customObject__c.sObjectType.getDescribe();
//navigate to the View Page
PageReference pageRef = New PageReference('/' + result.getKeyPrefix() + '/o');
pageRef.setRedirect(true);
return pageRef;
@fractastical
fractastical / Chuck Tomanek convert 15 character ID Strings to 18 chars.txt
Created May 24, 2011 21:39
Chuck Tomanek convert 15 character ID Strings to 18 chars
// http://www.sundog.net/sunblog/posts/a-handy-method-for-converting-15-character-id-strings-in-salesforce-to-18-c/
public string generate18CharId(string id){
// This method will take a 15 character ID and return its 18 character ID:
if (id == null){
return null;
}
if (id.length() != 15) {
public class JSONObject {
/*
Copyright (c) 2002 JSON.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the 'Software'), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@fractastical
fractastical / runger Remove duplicate items from List.txt
Created May 24, 2011 21:39
runger Remove duplicate items from List
Set<sobject> myset = new Set<sobject>();
List<sobject> result = new List<sobject>();
myset.addAll(originalList);
result.addAll(myset);
@fractastical
fractastical / sinatra_jquery_test.rb
Created October 22, 2011 20:13 — forked from mr-rock/sinatra_jquery_test.rb
An example of Sinatra working with Ajaxified JQuery based on some pieces of code published by Rafael George on the Sinatra Google Group.
require 'sinatra'
require 'dm-core'
require 'haml'
DataMapper.setup(:default, 'sqlite3::memory:')
class Message
include DataMapper::Resource
property :id, Serial
@fractastical
fractastical / barrel_bookmarklet.js
Created November 3, 2011 22:31 — forked from bengl/barrel_bookmarklet.js
A bookmarklet to replicate Google's "do a barrel roll" on any arbitrary page.
javascript:(function(a,k,t,n,u,i,m,o,w){document.head.innerHTML+=['<style>@-',m,k,m,t,'@-',o,k,o,t,'@-',w,k,w,t,'body{-',m,a,n,m,a,u,m,a,i,'-',o,a,n,o,a,u,o,a,i,'-',w,a,n,w,a,u,w,a,i,'}</style>'].join('');})("-animation","-keyframes roll { 100% { -","-transform:rotate(360deg); } }","-name:roll;-","-duration:4s;-","-iteration-count:1;","moz",'o','webkit');
@fractastical
fractastical / spark.rb
Created November 16, 2011 07:51 — forked from jcromartie/spark.rb
Sparklines in Ruby
#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
# prints a sparkline in the terminal using the supplied list of numbers
# examples:
# spark.rb 10 20 30 100 90 80
# spark.rb 1 2 0.4 0.1 1.3 0.7
@ticks = %w[▁ ▂ ▃ ▄ ▅ ▆ ▇]
values = ARGV.map { |x| x.to_f }
@fractastical
fractastical / jquery.oauth.js
Created March 16, 2012 15:33 — forked from andyedinborough/jquery.oauth.js
Introduces $.oauth() to make using OAuth from jQuery as easy as using $.ajax()
(function (window, document, $, undefined) {
if (!$.Deferred) throw 'jQuery 1.5 is required to use the jQuery.oauth script!';
function require(name, url) {
if (window[name] === undefined)
return $.ajax({ type: 'GET', cache: true, dataType: 'script', url: url });
}
$.oauth = function (options) {
var d = $.Deferred();