Skip to content

Instantly share code, notes, and snippets.

View dmulvi's full-sized avatar

Danny Mulvihill dmulvi

View GitHub Profile
@dmulvi
dmulvi / fullname.js
Last active February 9, 2017 22:20
SugarCRM 7 - add fields to Full Name headerpane display (middle name, nick name, preferred name etc)
/*
* I only wanted to apply this change to the Contacts modules so I put this file in:
* custom/modules/Contacts/clients/base/fields/fullname/
*/
({
extendsFrom: 'FullnameField',
formatMap: {
'f': 'first_name',
'l': 'last_name',
@dmulvi
dmulvi / view.js
Last active February 20, 2016 17:30
SugarCRM - easily create a custom handlebars helper
/* just throw this in the initialize method of your custom view */
window.Handlebars.registerHelper('trimString', function(module) {
var moduleShort = module.substring(0,2);
return new Handlebars.SafeString(moduleShort);
});
// force extra lines
@dmulvi
dmulvi / new.menu.php
Created April 29, 2016 00:43
Sugar 6 - Add Module Nav Item
<?php
// add this file to /custom/Extension/modules/Contacts/Ext/Menus/ and QRR
global $module_menu;
$module_menu[] = array('index.php?module=Contacts&action=Integrated_Search', 'Integrated Search', '');
<?php
// this allows adding a new custom field to the core module table
<?php
$dictionary['Account']['fields']['new_field'] = array(
'name' => 'new_field',
'vname' => 'LBL_NEW_FIELD',
'type' => 'varchar',
'len' => '255',
@dmulvi
dmulvi / SugarCRM.sublime-syntax
Last active March 27, 2017 14:37
SugarCRM Log Syntax Highlighter
%YAML 1.2
---
name: SugarCRM Log
scope: source.sugarcrmlog
contexts:
main:
- match: \w{3}\s?\w{3}\s?\d{2}\s?\d{2}:\d{2}:\d{2}\s?\d{4}
scope: text.sugar_log_date_string
@dmulvi
dmulvi / git-commands.sh
Last active May 23, 2017 17:28
Git Commands
# compare two branches (master and temp)
git log --graph --decorate --pretty=oneline --abbrev-commit master origin/master temp
# pull an old file and overwrite current
git checkout 'master@{7 days ago}' -- path/to/file.txt
# log changes before a date
git log --stat --before="2017-05-09"
@dmulvi
dmulvi / tricks.md
Last active April 27, 2017 16:58
sublime-tricks

Find Non-ASCII characters Just use regex search with string:

[^\x00-\x7F]
@dmulvi
dmulvi / PreventAccessHook.php
Created September 21, 2017 16:32
Prevent Access to module via Logic Hooks
<?php
class PreventAccessHook
{
public function preventAccess($bean, $event, $args) {
global $db, $current_user, $log;
// allow admins to view records
if ($current_user->is_admin && $event !== 'before_delete') {
return;
@dmulvi
dmulvi / createWallet.js
Created February 9, 2024 20:08
Create a Crossmint custodial wallet
const options = {
method: "POST",
headers: {
"X-API-KEY": "YOUR_API_KEY",
"Content-Type": "application/json",
},
body: JSON.stringify({
chain: "ethereum",
email: "[email protected]",
}),
@dmulvi
dmulvi / fetchNFTs.js
Created February 9, 2024 20:10
fetch NFTs from a wallet
const baseUrl = "https://staging.crossmint.com/api";
const chain = "polygon";
const wallet = "0x1234abcde...";
const options = {
method: "GET",
headers: { "X-API-KEY": "YOUR_API_KEY" },
};
fetch(