Skip to content

Instantly share code, notes, and snippets.

View ckoppelman's full-sized avatar

Charles Koppelman-Milstein ckoppelman

View GitHub Profile
#!/bin/bash
# Stages modified hunks matching passed in regex
SEARCH=$1
PATHS_DIVIDER=$2
PATHS=$3
if [ -z "$PATHS" ]
then
git diff -U1 | grepdiff "$SEARCH" --output-matching=hunk | git apply --cached
public class SchemaUtils {
static final Set<String> UNCHANGEABLE_FIELDS = new Set<String>{
'CreatedById', 'CreatedDate',
'LastModifiedById', 'LastModifiedDate',
'SystemModstamp', 'IsDeleted'
};
static final String TOOLING_API_QUERY_FORMAT = (
' SELECT Id, Metadata ' +
' FROM FieldDefinition ' +
var lastIdList = [];
var getAllCallData = function (idList, knownData, callback) {
var deferreds = idList.map(function (id) {
var matchedEl = null;
if (knownData) {
matchedEl = knownData.find(function (el) { return el.id === id; });
if (matchedEl) {
return matchedEl;
import nltk
from nltk.tokenize.treebank import TreebankWordTokenizer
class TreebankSpanTokenizer(TreebankWordTokenizer):
def __init__(self):
self._word_tokenizer = TreebankWordTokenizer()
def span_tokenize(self, text):
@ckoppelman
ckoppelman / TriggerUtilities.cls
Created March 13, 2017 17:25
TriggerUtilities
public class TriggerUtilities {
private TriggerUtilities() {
}
public static Boolean hasAnyFieldChanged(SObject newObj, Map<Id, SObject> oldMap, List<Schema.SObjectField> flds) {
for (Schema.SObjectField fld : flds) {
if (hasFieldChanged(newObj, oldMap, fld)) {
return true;
}
}
@ckoppelman
ckoppelman / salesforce_version.rb
Last active July 5, 2016 17:30
Find the "API version" for an arbitrary Salesforce release name and vice versa.
to_version_string=->v{%w{spring summer winter}[v.to_i%3] + ' ' + (2005+(v.to_i-2)/3).to_s}
from_version_string=->s{
no_apostrophe = s.sub(?', '20')
season, year = no_apostrophe.split(' ')
(2+(year.to_i-2005)*3 + %w{wi sp su}.index(season.downcase[0,2])).to_s + '.0'
}
@ckoppelman
ckoppelman / A.markdown
Last active March 24, 2016 19:55 — forked from larrybotha/A.markdown
Fix SVGs not scaling in IE9, IE10, and IE11

Fix SVG in <img> tags not scaling in IE9, IE10, IE11

IE9, IE10, and IE11 don't properly scale SVG files added with img tags when viewBox, width and height attributes are specified. View this codepen on the different browsers.

Image heights will not scale when the images are inside containers narrower than image widths. This can be resolved in 2 ways.

Use sed in bash to remove width and height attributes in SVG files

As per this answer on Stackoverflow, the issue can be resolved by removing just the width and height attributes.

@ckoppelman
ckoppelman / sandbox-pill.css
Last active November 16, 2015 14:59
Creates a floating pill of the Sandbox name or else the environment. To be used with Stylish
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("salesforce.com") {
/*
* this is where SFDC keeps the "Sandbox: xxx" message.
* the .messages element is empty if it's not a sandbox
*/
#phHeader .messages .pageMsg.textOnly.normalImportance,
#phHeader .messages:empty::after {
@ckoppelman
ckoppelman / .gitconfig
Created August 11, 2015 16:56
A filter for .gitconfig to ignore logos in the application files (Salesforce)
# it's quite annoying to change from sandbox to production
# in the same directory unless you have this filter installed
# To make use of it, add the following line to your .gitattributes file:
#
# *.app filter=ignore_logo
[filter "ignore_logo"]
clean = sed '/<logo>/'d
smudge = cat
@ckoppelman
ckoppelman / commit-msg
Last active December 18, 2015 03:08
Githook for requiring a JIRA issue in the commit message like [REALM-1234]. Place this in .git/hooks/
#!/bin/sh
message=`cat $1`
prevLang=`echo $LANG` # this will get reset once we're done here
rc=0
# The Portable-Git that comes with Github for Windows has a bash version of 3.1.0,
# so it doesn't understand regex matching. Use pattern matching instead.
# regex="(\[[A-Z]{2,5}-[0-9]{1,6}\]|\[NO-ISSUE\])"