Skip to content

Instantly share code, notes, and snippets.

View matthewpoer's full-sized avatar

Matthew Poer matthewpoer

View GitHub Profile
@matthewpoer
matthewpoer / READMD.md
Last active May 1, 2017 17:53
Flat-File SugarCRM Activity Data Exports

Execute SQL scripts and generate TSV files

  • mysql -h HOSTNAME -u USERNAME -pPASSWORD DATABSE < calls_all_invited_people.sql > calls_all_invited_people.tsv
  • mysql -h HOSTNAME -u USERNAME -pPASSWORD DATABSE < calls_all_invited_people_condensed_guids.sql > calls_all_invited_people_condensed_guids.tsv
  • mysql -h HOSTNAME -u USERNAME -pPASSWORD DATABSE < meetings_all_invited_people_condensed_guids.sql > meetings_all_invited_people_condensed_guids.tsv
  • mysql -h HOSTNAME -u USERNAME -pPASSWORD DATABSE < tasks_all.sql > tasks_all.tsv

Clean TSV files to map \r\n to just \n (removing the \r reference)

  • sed -e 's/\r//g' -i calls_all_invited_people.tsv
  • sed -e 's/\r//g' -i calls_all_invited_people_condensed_guids.tsv
  • sed -e 's/\r//g' -i meetings_all_invited_people_condensed_guids.tsv
@matthewpoer
matthewpoer / clickShowButtons.js
Last active March 1, 2017 14:41
Click all of the "View trimmed content" buttons in a single Gmail thread. Alternatively, just open the Print view for the thread.
// note that the on-screen JS has a $ but it is not true jQuery
function findButton(){
button = $('[data-tooltip="Show trimmed content"]');
if(typeof button != 'undefined' && button.id){
return button;
} else {
return FALSE;
}
}
@matthewpoer
matthewpoer / QuoteLineItems.sql
Created September 1, 2016 18:17
Use this SQL to find all valid + deleted groupings and line items for a given Quote. If you use this in Sequel Pro then you can easily use it's UI to un-delete records
select
quotes.name,products.name,products.quantity,products.cost_price,
products.discount_price,
quotes.id as quotes_id,
quotes.deleted as quotes_deleted,
product_bundle_quote.id as product_bundle_quote_id,
product_bundle_quote.deleted as product_bundle_quote_deleted,
product_bundles.id as product_bundles_id,
product_bundles.deleted as product_bundles_deleted,
product_bundle_product.id as product_bundle_product_id,
@matthewpoer
matthewpoer / BadSyntaxReport.sh
Last active June 27, 2016 05:40
PHP Syntax Check. Checks the syntax using `php -l` for all PHP files in a directory. Only reports the errors and file names (i.e. doesn't show "No syntax errors detected in..."
find ./ -type f -name \*.php -exec php -l {} \; | grep -v 'No syntax errors'
@matthewpoer
matthewpoer / ApiClient.php
Last active August 29, 2015 14:24
Attempt to demonstrate a potential PHP Bug wherein a string of data that includes an equals sign (=), when json_encode()'d twice and delivered to a web server, will be interpreted as a split in a data array.
<?php
echo "<h1>JSON Array to Double Array PHP Bug(?)</h1>";
echo "<p>Attempt to demonstrate a potential PHP Bug wherein a string of data that includes an equals sign (=), when json_encode()'d twice and delivered to a web server, will be interpreted as a split in a data array.</p>\n";
$array = array(
'one' => 'one is one',
'two' => 'two = two',
);
@matthewpoer
matthewpoer / 76_rli_fix.php
Last active August 29, 2015 14:20
if you upgrade a 7.5 to a 7.6 Sugar system you may need this to enable the Opportunities config screen and allow the use of RLIs again. Place the file in your root Sugar directory and run it from CLI like you would cron, e.g. "php -f 76_rli_fix.php"
<?php
if (!defined('sugarEntry')) define('sugarEntry', true);
chdir(dirname(__FILE__));
define('ENTRY_POINT_TYPE', 'api');
require_once('include/entryPoint.php');
$sapi_type = php_sapi_name();
if (substr($sapi_type, 0, 3) != 'cli') {
sugar_die("cron.php is CLI only.");
@matthewpoer
matthewpoer / Fields Meta Data.md
Last active August 29, 2015 14:20
Convert the HTML table from a fields_meta_data table dump into a SQL statement to create the table on your work station

Turn HTML fields_meta_data dumps into SQL statements

(1) Manually remove

and open/end tags

(2) remove all strings matching class="tabDetailViewD\w"

(3) replace  

@matthewpoer
matthewpoer / NumberTwo.sh
Created April 22, 2015 12:29
Shell Script to dump and re-load a database as a background process so you don't have to sit and wait for it.
#/bin/sh
#
# NumberTwo.sh
# (because it's gonna take a dump)
#
# Dump and re-load some large database into a new sandbox. Helpful to have
# this in a script that we can run in the background when the database is
# large.
#
# Use it like this:
@matthewpoer
matthewpoer / CustomMetadataApi.php
Created April 13, 2015 20:11
Sugar 7 Mobile UI - allow use of modules as subpanels without adding to the navigation menu. First add the module(s) through the typical Mobile Configuration tool, then create a hard-coded list in the CustomMetadataAPI class like below.
<?php
require_once('clients/base/api/MetadataApi.php');
/**
* custom/clients/base/api/CustomMetadataApi.php
*/
class CustomMetadataApi extends MetadataApi
{
/**
@matthewpoer
matthewpoer / requeue-failed-jobs.sql
Created March 20, 2015 15:06
Re-queue some number of failed job_queue entries based on the fact that they failed and are of a certain name
update job_queue set
date_modified = date_entered,
execute_time = date_entered,
status = 'queued',
resolution = 'queued',
message = NULL,
failure_count = NULL,
client = ''
where name = 'tcx_job_account_set_teams' and resolution = 'failure';