Skip to content

Instantly share code, notes, and snippets.

View Oblongmana's full-sized avatar
🐕

James Hill Oblongmana

🐕
View GitHub Profile
@Oblongmana
Oblongmana / te"st.md
Last active December 14, 2015 02:19
#testing #breaks

ghjhg" s} {dfgdfg " "

@Oblongmana
Oblongmana / ISO3166_1_Alpha_2.java
Last active December 14, 2015 04:19
#Static #Apex #Maps for the #ISO #3166-1 #Alpha-2 #Country #Code #standard. One maps from Country to Code, and one from Code to Country. There are also copies of these with the Country name lengths truncated to 35 characters
public static Map<String, String> ISO3166_1_Alpha2_CountryToCode = new Map<String,String> {
'AFGHANISTAN'=>'AF',
'ÅLAND ISLANDS'=>'AX',
'ALBANIA'=>'AL',
'ALGERIA'=>'DZ',
'AMERICAN SAMOA'=>'AS',
'ANDORRA'=>'AD',
'ANGOLA'=>'AO',
'ANGUILLA'=>'AI',
'ANTARCTICA'=>'AQ',
@Oblongmana
Oblongmana / ListFieldsAndIfRequired.java
Last active December 14, 2015 18:39
Output a list of all fields on an object, and whether or not they are required. This isn't 100% accurate, but is useful for doing things faster! Adapted from http://boards.developerforce.com/t5/Apex-Code-Development/Detect-a-required-field-in-Apex/td-p/129693
//Adapted from http://boards.developerforce.com/t5/Apex-Code-Development/Detect-a-required-field-in-Apex/td-p/129693
Map<String, Schema.SObjectField> describeFields = Schema.SObjectType.Bank__c.fields.getMap();
//CREATE A MAP WITH FIELD NAME AS KEY AND A BOOLEAN (Required) AS VALUE
Map<String, Boolean> fieldIsRequired = new Map<String, Boolean>();
Map<String, Schema.DisplayType> fieldsTypes = new Map<String, Schema.DisplayType>();
for(String field : describeFields.keyset()){
Schema.DescribeFieldResult desribeResult = describeFields.get(field).getDescribe();
@Oblongmana
Oblongmana / rowCheckBox.js
Created March 24, 2013 21:33
Short #jQuery chunk which assigns an #onClick #function to each #pageBlockTable #row which finds the #checkbox in the row and simulates the onClick event on the checkbox. Ignores clicks on the checkbox itself, and ignores clicks on links
//dataRow is the class that Salesforce applies to all data rows, but you could equally use this in a non Salesforce context
$(".dataRow").click(function(event)
{
//Ignore link and checkbox clicks, otherwise find the row's checkbox and click it
if(event.target.type!=="checkbox" && !$(event.target).is('a')) {
$(this).find($("input:checkbox")).click();
}
});
@Oblongmana
Oblongmana / COM_ObjectExtensions.cs
Created April 28, 2013 23:03
This adds an #Extension method to #Object (necessary as there are loads of different types of COM object, but with no more specific superclass other than Object) which will properly release a #COM object. This is oriented towards #Excel so it includes code to close workbooks, and properly quit Excel Applications - could easily be extended with a…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
namespace AnalysisSuite.Extensions
{
public static class ObjectExtensions
{
@Oblongmana
Oblongmana / ExcelExtensions.cs
Last active December 16, 2015 18:39
This contains #Extension methods for #Excel objects. At present, just contains a method for simplifying getting the #Value2 for a particular column/row in a particular worksheet. This gives the value back, and takes care of the COM management stuff nicely, so you can just call worksheetInstance.GetCellValue2(colInt,rowInt) without thinking too h…
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Excel = Microsoft.Office.Interop.Excel;
using MyExtensions
namespace MyExtensions
{
public static class ExcelExtensions
@Oblongmana
Oblongmana / DateTimeExtensions.cs
Created April 28, 2013 23:12
This contains #Extension methods for #DateTime objects. The method WeekSpan gives you Tuple<DateTime,DateTime? representing a week from the start of the day a week ago to the end of the DateTime instance calling the method.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace MyExtensions
{
public static class DateTimeExtensions
{
@Oblongmana
Oblongmana / CustomPlayPause.scpt
Created April 29, 2013 01:59
#Applescript file to control #play / #pause #priority when run. Priority here is: If Quicktime has focus, play/pause in qt; if VLC has focus, play/pause in VLC; otherwise play/pause in Spotify
on run {input, parameters}
tell application "System Events"
set MyList to (name of every process)
end tell
set nameOfFocusedApp to name of (info for (path to frontmost application))
if (MyList contains "QuickTime Player" and nameOfFocusedApp is "QuickTime Player.app") is true then
tell application "QuickTime Player"
@Oblongmana
Oblongmana / rfonggrapheditor_chrome_console_cmds_Step1.js
Created June 20, 2013 03:33
rfong's graph editor fork doesn't currently work due to using a raw.github script. This works around that using the rawgithub.com workaround instead
//Import script using rawgithub workaround site (as opposed to raw.github which doesn't work and is currently used on the page)
var jq = document.createElement('script');
jq.src = "https://rawgithub.com/rfong/graph-editor.js/master/build/graph-editor.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
@Oblongmana
Oblongmana / Parsley.js
Last active December 19, 2015 05:49
Quick demo of how one can get the #parsley #JavaScript #form #validation framework (http://parsleyjs.org/) up and running very quickly in a #Salesforce + #bootstrap context, with verbose comments throughout on usage (and some comments what to do if not using one or both of Salesforce/Bootstrap).
//Static resource called parsley contains just the parsley.js file. Ditto jQuery. In a non-sf context,
// I'm sure you can work it out :)
<apex:includeScript value="{!$Resource.jQuery}"/>
<apex:includeScript value="{!$Resource.parsley}"/>
//An example of using the parsley.js (http://parsleyjs.org/) form validation framework in Salesforce,
// on a bootstrapified page (this should[?] work equally well on a non-bootstrap page - it just uses
// bootstrap class names where appropriate).
//Note that as salesforce doesn't allow "custom" attributes in <apex> elements (this uses HTML5
// data-* attributes), this uses the javascript method of initialising parsley. In a non-sf context,