Skip to content

Instantly share code, notes, and snippets.

View matthewpoer's full-sized avatar

Matthew Poer matthewpoer

View GitHub Profile
@matthewpoer
matthewpoer / field_xml_builder.php
Created October 22, 2018 14:47
Salesforce [Text] Field Builder from Array List `php -f field_xml_builder.php > fields_xml.xml`
<?php
// php -f field_xml_builder.php > fields_xml.xml
$fields = array(
'Action',
'ActionDate',
'Address1',
'Address2',
'Address3',
@matthewpoer
matthewpoer / .gitignore
Created October 5, 2018 01:43
example SugarCRM/SuiteCRM .gitignore file for tracking the CRM as a whole application (vs. developing code as a Sugar plugin)
# assumes a top-level dir. structure like to:
# /.
# /.git/ (git is up here so all of the below are tracked)
# /.gitignore (this file)
# /crm/ (holds the Sugar/Suite application files)
# /db/ (holds database backups, or at least fields_meta_data and config and similar)
# /scripts/ (holds helper scripts for automated backups of database, quick repair, etc.)
# Ignore cache, but make sure it exists
crm/cache/*
@matthewpoer
matthewpoer / Vagrantfile
Created September 26, 2018 03:56
LAMP with PHP 5.6 (via devbox project) and MailHog
$mailhog_setup = <<-SCRIPT
rm ~/.profile
apt-get update
apt-get install -y golang-go
echo "export GOPATH=$HOME/gocode" >> ~/.profile
source ~/.profile
go get github.com/mailhog/MailHog
go get github.com/mailhog/mhsendmail
cp ~/gocode/bin/MailHog /usr/local/bin/mailhog
@matthewpoer
matthewpoer / user input
Created July 18, 2018 13:39
Using `fgets` to solicit and obtain user input in PHP CLI
<?php
echo "What do you want?" . PHP_EOL;
$handle = fopen("php://stdin","r");
$input = fgets($handle);
echo "You want " . $input . PHP_EOL;
@matthewpoer
matthewpoer / binary-search-tree-1.sql
Created June 29, 2018 13:12
Answer to HackerRank's "Binary Tree Nodes" SQL practice problem
-- https://www.hackerrank.com/challenges/binary-search-tree-1/problem
select
parents.n,
case
-- if there is no parent to this node, then it is the root of the tree
when parents.p is null then 'Root'
-- if there are no children to this node, then it is a leaf
when children.nodes is null then 'Leaf'
-- otherwise it much be a branch
else 'Inner'
@matthewpoer
matthewpoer / composer.json
Created June 8, 2018 15:28
a composer config. example with various requirements, including public and private GitHub hosted repos. not on packagist
{
"repositories": [
{
"type": "package",
"package": {
"name": "matthewpoer/unit-tests",
"version": "dev-7_6_1",
"dist": {
"url": "https://github.com/matthewpoer/unit-tests/archive/7_6_1.zip",
"type": "zip",
@matthewpoer
matthewpoer / SelectAll.js
Created October 23, 2017 19:09
SFDC Set History Tracking for all fields. Natively the UI only allows you to de-select all fields. This JS will invert the native function and select all of the fields on the screen. Note that SFDC only allows 20 fields to be tracked, so you may have to manually remove some before saving.
// copy the text out of the native function
var selectAll = selectNone.toString();
// replace "checked=false" with "checked=true"
selectAll = selectAll.replace(/checked=false/g, 'checked=true');
// rename the function
selectAll = selectAll.replace(/function selectNone/g, 'function selectAll');
// the text var selectAll now contains a new function, so calling eval make it accessible
@matthewpoer
matthewpoer / SugarCRM_LAMP_Setup.sh
Last active August 1, 2017 04:55
LAMP setup for SugarCRM 6.5 on Ubuntu 16.04
#!/bin/bash
# Set up LAMP stack tailored on Ubuntu 16.04 LTS to latest version of SugarCRM 6.5
# (as of 2017-07-23 that's 6.5.26; 6.5 is EoL as of 2017-07-15)
# sources
# https://developer.sugarcrm.com/2016/01/04/using-packer-to-create-consistent-sugar-hosting-environments/#more-12929
# https://launchpad.net/~ondrej/+archive/ubuntu/php/
# http://support.sugarcrm.com/Resources/Supported_Versions/
# Stack Setup
@matthewpoer
matthewpoer / config_si.php
Created May 9, 2017 18:28 — forked from chicks/config_si.php
SugarCRM Silent Installer
<?php
$sugar_config_si = array(
'setup_db_host_name' => 'localhost',
'setup_db_sugarsales_user' => 'sugarcrm',
'setup_db_sugarsales_password' => 'DB_USER_PASSWORD',
'setup_db_database_name' => 'sugarcrm',
'setup_db_type' => 'mysql',
'setup_db_pop_demo_data' => false,
@matthewpoer
matthewpoer / account_parent_export.sql
Created May 2, 2017 13:11
Select the Account ID, Name and Parent ID and Name for all Sugar Accounts with Parents
select
accounts.id as account_guid,
accounts.name as account_name,
accounts.parent_id as parent_account_guid,
parents.name as parent_account_name
from accounts
join accounts parents
on parents.deleted = 0
and accounts.parent_id = parents.id
where accounts.deleted = 0