Skip to content

Instantly share code, notes, and snippets.

View Oblongmana's full-sized avatar
🐕

James Hill Oblongmana

🐕
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / te"st.md
Last active December 14, 2015 02:19
#testing #breaks

ghjhg" s} {dfgdfg " "