Skip to content

Instantly share code, notes, and snippets.

View Oblongmana's full-sized avatar
🐕

James Hill Oblongmana

🐕
View GitHub Profile
@Oblongmana
Oblongmana / TextSelectField.cs
Last active April 8, 2022 02:04
Unity VisualElement (UnityEnginer.UIElements) combining a TextInput and ListView into something resembling the common web pattern of a TextField with dropdown, filtering as you type, and updating the text field if you pick an option. Details in class. https://unlicense.org
#if UNITY_EDITOR
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Unity.EditorCoroutines.Editor;
using UnityEngine;
using UnityEngine.UIElements;
/// <summary>
@Oblongmana
Oblongmana / git init-sf
Created October 24, 2013 22:05
This alias initialises a git repo with a Salesforce specific setup , with gitignore configured to exclude SublimeText project nature, OSX, and MavensMate nature files - which will be individual specific - not good in a distributed setup!.This alias should be added to your [alias] section in ~/.gitconfig, Once you've done that, you can invoke "gi…
[alias]
init-sf = "!workingdir=$(pwd); tempdir=$(mktemp -dt gitinitsftmp); (cd $tempdir && git init && curl -o .gitignore https://gist.github.com/Oblongmana/7130387/raw/69aa9b661b0bd7300eff8648c65362c7f711f725/.gitignore-sf && mkdir -p apex-scripts && mkdir -p src/classes && touch README.md && cp -R $tempdir/. $workingdir); rm -rf $tempdir;"
@Oblongmana
Oblongmana / .gitignore-sf
Last active August 4, 2023 08:24
Salesforce development gitignore file. Specific to a Sublime Text/MavensMate/OSX setup, used @TrineoLtd.Works well with this git alias for speeding up repo setup https://gist.github.com/Oblongmana/7145945. Curl with curl -o .gitignore https://gist.github.com/Oblongmana/7130387/raw/69aa9b661b0bd7300eff8648c65362c7f711f725/.gitignore-sf
#OSX-specific exclusions
.[dD][sS]_[sS]tore
#Sublime nature exclusions
*.sublime-workspace
*.sublime-project
#MavensMate nature exclusions
config/*
mm.log
@Oblongmana
Oblongmana / common-ModalPage.Page
Last active December 24, 2015 08:29
A reasonably quickly pluggable way of getting a #modal #dialog into a #visualforce page. You need to include jQuery (tested with 1.9.1) and jQueryUI (tested with 1.10.3) that has been customised with CSS SCope ".jqueryuidialog", as well as (of course?) the javascript file included in this gist. May blog about it a bit more in depth at some point…
<apex:page sidebar="false" title="My Modal Page">
<!-- NOTE RE JQUERYUI - MUST READ - PARTICULARLY IMPORTANT DUE TO UNFORTUNATELY BAD USER EXPERIENCE ON JQUERYUI WEBSITE :(
Go to http://jqueryui.com/download/
Pick any components you want to include (MUST include dialog however)
Scroll to bottom of page
Change the CSS scope box to ".jqueryuidialog" - being sure to include the period/fullstop
Now (and here comes the confusing user experience):
Click the "Design a custom theme" link, and you'll be taken away from the page
Customize the theme as you see fit (or don't, that's fine too) - I'd suggest checking out the options in the ThemeROller->Gallery tab
@Oblongmana
Oblongmana / common-saveEnforcer.js
Last active December 21, 2015 06:29
Small #javascript drop-in to help enforce #save when a user tries to #navigate #away from a page. Relatively naive implementation. See notes at top of file
/*------------------------------------------------------------------------------
common-enforcesave.js
Description:
this provides a fairly simple way to attempt to enforce saving of
important data on form pages. Adds "saveEnforcer" to globals. Add the
saveButton class to any buttons used for saving, and the inputToCapture
class to any inputs that should be saved. Call saveEnforcer.initialise()
on document ready.
@Oblongmana
Oblongmana / *ACN and ABN Validation.java
Last active December 20, 2015 11:09
ACN and ABN Validation fro both Salesforce Apex and T-SQL. See http://www.oblongmana.com/articles/ABN-ACN-Validation-For-Apex-and-TSQL/
public with sharing class ACNandABNValidation {
private enum ValidationType {ACN, ABN}
static final List<Long> ACN_WEIGHTS = new List<Long>{8,7,6,5,4,3,2,1};
static final List<Long> ABN_WEIGHTS = new List<Long>{10,1,3,5,7,9,11,13,15,17,19};
public static Boolean ValidateACN(String acnString) {
acnString = getNonBlankNumericStringWithoutWhitespace(acnString);
if(acnString == null) {
return false;
@Oblongmana
Oblongmana / *Custom_Page_Message_Framework.md
Last active March 12, 2020 01:42
#Custom #pageMessage #framework - mostly aimed for use in #portal contexts where it's important to be able to control the #style applied to messages. This framework uses #bootstrap classes for styling (so of course, you're probably going to want to use it with bootstrap!)

Custom Page Message Framework

This framework gives you a way to exert control over style when providing confirm/info/error/warn messages to your users in Visualforce pages, because let's face it: the default styles are not that pretty/easy to bring into line with a Client's style, particularly when being used in a Portal (I haven't personally worked on any clients using Communities yet, so can't comment on the aesthetics there!).

This framework is pretty simple and self-contained, including 100% test coverage for each class. The only things you need to bring to the party are Bootstrap css and js, and some very minor alterations to your controller and page files, which can be easily done with a quick find/replace or two.

Dependencies

Bootstrap css file : Optional, but strongly recommended unless you need to roll your own style
Bootstrap js file : Optional, but required if you want your messages to be dismissable
@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,
@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 / 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"