Skip to content

Instantly share code, notes, and snippets.

View trevordevore's full-sized avatar

Trevor DeVore trevordevore

View GitHub Profile
@trevordevore
trevordevore / gist:5584753
Created May 15, 2013 15:17
Convert XML to and from a LiveCode array
/**
* Handlers for converting XML to LiveCode arrays and vice versa.
*
* Provided by Trevor DeVore of Blue Mango Learning Systems.
*/
/**
* \brief Escapes the predefined XML entities in a string.
*
* \param pStr The string to escape the characters in.
@trevordevore
trevordevore / LiveCode
Created April 17, 2013 14:12
Getting user info from an Active Directory server using VBScript and LiveCode
# Put the VBScript into a variable and then execute as follows:
do theScript as "vbscript"
if the result begins with "error," then put item 2 to -1 of the result into theError
else
put the result into theADUserInfo ## last name, first name & cr & group & tab & group ...
end if
@trevordevore
trevordevore / utmtolatlong.livecodescript
Last active June 9, 2018 15:14
LiveCode function for converting a UTM location to latitude/longitude
script "UTM To LatLong Library"
/**
Summary: Converts UTM coordindates to lat/long
Parameters:
pZoneNumber: A number between 1 and 60.
pZoneLetter: A-Z, Zones A-M are soutern, N-Z are northern/
pEasting: Number
pNorthing: Number
@trevordevore
trevordevore / behaviorsdatagridbuttonbehavior.livecodescript
Last active November 7, 2017 16:15
Fixes issues where mobileScroller is not recreated when returning to card with DataGrid on it
local sDataArray -- Multi-dimensional array
local sIndexSequencing -- sDataArray indexes in order they should appear
local sInit -- Has control been opened once before?
local sControlIsOpen
constant kDefaultDimmedHiliteColor = "212,212,212"
constant kRowColor = "255,255,255"
constant kHeaderBkgrndStartColor = "219,219,219"
constant kHeaderBkgrndEndColor = "188,188,188"
@trevordevore
trevordevore / htmlTextToMarkdown.livecodescript
Created November 6, 2017 15:17
LiveCode htmlText to Markdown
function htmlTextToMarkdown pText, pEscape
put pEscape is not false into pEscape
replace "<b>" with "<strong>" in pText
replace "</b>" with "</strong>" in pText
## http://daringfireball.net/projects/markdown/syntax
## Doesn't support targets as far as I can tell
_RemoveATagTarget pText
@trevordevore
trevordevore / signOSXApplication.livecodescript
Last active June 16, 2017 14:33
LiveCode script-only stack that will code sign LIveCode applications on OS X
script "SignApplicationForOSX"
on preOpenCard
set the visible of this stack to true
put the rect of this stack into tRect
put item 1 of tRect + 400 into item 3 of tRect
put item 2 of tRect + 400 into item 4 of tRect
set the rect of this stack to tRect
constant kMultiLineModeNone = 0
constant kMultiLineModeLiteral = 1
constant kMultiLineModeFolded = 2
command YAMLToArray pYaml
local tInDocument = true
local tPath
local tArray
local tPathLists
local tReferences
result = ""
theDomain = "[[Domain]]" 'domain with no trailing /
theQuery = "[[Query]]" 'query such as ou=Users,dc=...
theUser = "[[Username]]"
thePassword = "[[Password]]"
On Error resume next
Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
LDAPString = "LDAP://"
@trevordevore
trevordevore / gist:3498531
Created August 28, 2012 14:33
Security Scoped Bookmark URLs
/*
To use:
1) Get path to file/folder using file selection dialog.
2) Pass path to secscopGetBookmarkFromURL in order to get bookmark data for it.
3) Store this bookmark data somehow.
4) Tell the OS you want access to the file using secscopInitializeURLFromBookmarkData(). Store security-scoped url returned for later.
5) When you are done using the file call secscopStopUsingURL.
You will need to do steps 4 and 5 every time you want to open a file across sessions. For example, if you have a recent files menu or a folder that a user selects once and you write data to across sessions.
*/
@trevordevore
trevordevore / gist:5246242
Created March 26, 2013 15:23
Zips/Unzips folders using LiveCode. There are a lot of supporting handlers included.
/**
* \brief Creates a zip file from a directory. The ZIP archive should already have been opened with revZipOpenArchive.
*
* \param pZipArchivePath The path to save the zip archive to. This should already have been opened with revZipOpenArchive.
* \param pRootFolderPath The folder to save in the zip archive.
* \param pIncludeRootFolderInArchiveItemNames Pass in true to include the name of pRootFolderPath in the zip archive.
* \param pFilesToExclude Files that should not be included in the archive.
* \param pExtensionsThatArentCompressed File extensions that should be added without any compression.
* \param pFolderPath Used when calling itself recursively. Pass in empty.
*