Skip to content

Instantly share code, notes, and snippets.

@mrbarletta
mrbarletta / interceptor.py
Last active September 10, 2025 23:09
Bluetooth keyboard adding a letter
#!/usr/bin/env python3
import evdev
import time
import sys
import signal
import os
import select
try:
from rich.console import Console
@mrbarletta
mrbarletta / parsePostfixLog.js
Created June 20, 2024 21:58
An easy way to get From/To list from the postfix.log mainlog. I wanted a quick way to find in the log if postfix received an email.
import fs from "fs";
import util from "util";
util.inspect.defaultOptions={depth :null, maxArrayLength: null};
function parseLogSection(section) {
const lines = section
.split("\n")
.map((line) => line.trim())
.filter((line) => line);
const result = {
@mrbarletta
mrbarletta / firebaseGetAuthToken.js
Last active September 20, 2022 18:40
Firebase - CF Worker
import { getTokenFromGCPServiceAccount } from "@sagi.io/workers-jwt";
export async function getAccessToken(){
const serviceAccountJSON = {
type: "service_account",
project_id: GOOGLE_PROJECT_ID, //ENVIRONMENT VARIABLES
private_key_id: GOOGLE_PRIVATE_KEY_ID,
private_key: GOOGLE_PRIVATE_KEY,
client_email: GOOGLE_CLIENT_EMAIL,
client_id: GOOGLE_CLIENT_ID,
@mrbarletta
mrbarletta / exportDbeaverPasswords.sh
Created March 18, 2022 02:12
DBeaver password export command
openssl aes-128-cbc -d -K babb4a9f774ab853c96c2d653dfe544a -iv 00000000000000000000000000000000 -in ~/.local/share/.DBeaverData/workspace6/General/.dbeaver/credentials-config.json
@mrbarletta
mrbarletta / bulkSetRoles.js
Created March 16, 2020 04:22
Mass update SuiteCRM roles using JS - adjust the value, paste on console and Save
let a= $("[id^=ACLEditView_Access] [id$=delete]").each(function(i, item){
let el = $(item).find('select')
if(el.length>0){
$("#"+$(el).attr('id')+" option[value='80']").prop('selected',true) // 80 means GROUP
}
})
let a= $("[id^=ACLEditView_Access] [id$=edit]").each(function(i, item){
let el = $(item).find('select')
if(el.length>0){
$("#"+$(el).attr('id')+" option[value='80']").prop('selected',true) // 80 means GROUP
@mrbarletta
mrbarletta / MailgunWebhooks.php
Last active December 24, 2018 15:26
MailgunWebhooks Entrypoint - sets SuiteCRM email opted out + Note with details for reference
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
function unsubscribeNote($recipient, $note, $description)
{
global $db;
$queryOptout = "UPDATE email_addresses SET opt_out=1 WHERE email_address='?'";
$queryBeans = "SELECT emr.bean_id, emr.bean_module FROM email_addresses ema
INNER JOIN email_addr_bean_rel emr ON ema.id=emr.email_address_id

Keybase proof

I hereby claim:

  • I am mrbarletta on github.
  • I am mrbarletta (https://keybase.io/mrbarletta) on keybase.
  • I have a public key ASB_Ze20rYEo5tWgo1qezqDNKaYam330rVGRMwyM_bEnWAo

To claim this, I am signing this object:

<?php
namespace App\Jobs;
use App\Models\ZohoInvoice;
use function \FluidXml\fluidxml;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
@mrbarletta
mrbarletta / genesis_public_key
Created February 21, 2018 15:48
genesis_public_key
041de9f893bf0f429e4263cd29abc3979021dfe931a1a10574af3478b537e0d9a85b83215e7417dceed147e6e9f91140e4f067e1bc60748361d0e4a7c49dd100c3​
@mrbarletta
mrbarletta / gravity_forms_webhook_example_suitecrm.php
Last active March 21, 2021 04:08
Gravity Forms Webhook example - Posting data to SuiteCRM/SugarCRM/LionixCRM - working example
<?php
// Add the following code to your theme functions.php (not recommended as might get lost on updates) or create a plugin
//LX - CRM
add_action( 'gform_after_submission', 'post_to_crm', 10, 2 );
function post_to_crm( $entry, $form ) {
$post_url = 'https://youInstance.lionix.com/index.php?entryPoint=WebToPersonCapture';
$post=false;
//Gravity forms has IDs for each of the fields . Some fields, like 1.3, means FIELD 1, subfield 3. Which usually means first_name