Skip to content

Instantly share code, notes, and snippets.

View Benjaminhu's full-sized avatar
🚀
To infinity and beyond.

Simon Benjámin Benjaminhu

🚀
To infinity and beyond.
View GitHub Profile
@Benjaminhu
Benjaminhu / sentry_google_chat_webhook.php
Last active November 14, 2022 14:25
This script can act as a middleman between Sentry's webhook system and Google Chat Incoming Webhooks
<?php
$googleChatWebhookURL = '<YOUR-GOOGLE-CHAT-WEBHOOK-URL>';
$integrationClientSecret = '<YOUR-Sentry-Settings-integration-Edit Integration-CREDENTIALS-Client Secret>';
/**
* https://developers.google.com/chat/how-tos/webhooks#step_2_write_the_webhook_script
* https://developers.google.com/chat/api/guides/message-formats/basic
*/
@Benjaminhu
Benjaminhu / bookmarklet-get-unique-sorted-pattern-list-from-current-HTML-page.js
Created August 22, 2022 20:45
JavaScript Bookmarklet: get unique sorted pattern list from current HTML page
// steps:
// 1. copy code (CTRL + A, CTRL + C)
// 2. go to: http://subsimple.com/bookmarklets/jsbuilder.htm
// 3. paste code after: "javascript:"
// 4. [optional] customize "pattern"
// 5. add name
// 6. push "(function...)" button
// 7. push "comress" button
// 8. drag & drop your bookmarklet name to your bookmark tab
@Benjaminhu
Benjaminhu / mysq.alter.if.not.exists.alternative.sql
Created April 11, 2022 19:15
MySQL ALTER TABLE IF NOT EXISTS - I think so best alternative
-- <TABLE NAME> replace to table name
-- <COLUMN> replace to column name
SELECT COUNT(*) INTO @exist FROM information_schema.columns
WHERE table_schema = DATABASE() AND table_name = '<TABLE NAME>' AND column_name = '<COLUMN>' LIMIT 1;
SET @query = IF (@exist <= 0,
"ALTER TABLE <TABLE NAME> ADD COLUMN <COLUMN> MEDIUMTEXT NULL",
"SELECT 'COLUMN EXISTS: <TABLE NAME>.<COLUMN>' AS column_exists_info"
);
@Benjaminhu
Benjaminhu / bookmarklet-make-branch-name-from-jira-ticket.js
Last active July 24, 2023 09:26
JavaScript Bookmarklet: make a branch name from a Jira ticket
javascript:
// steps:
// 1. copy code
// 2. go to: http://subsimple.com/bookmarklets/jsbuilder.htm
// 3. paste code after: "javascript:"
// 4. [optional] customize "removeRegexp"
// 5. add name
// 6. push "(function...)"
// 7. push "comress"
// 8. drag & drop your bookmarklet name to your bookmark tab
@Benjaminhu
Benjaminhu / aws-elasticache-bash-auto-discovery-node.sh
Last active October 18, 2020 09:38
AWS - ElastiCache for Memcached - bash query first node - Auto Discovery cluster node
#!/bin/bash
# https://docs.aws.amazon.com/AmazonElastiCache/latest/mem-ug/AutoDiscovery.html
#
# ConfigurationEndpoint example: mycluster.fnjyzo.cfg.use1.cache.amazonaws.com
#
# CacheNodes Endpoint 1: mycluster.fnjyzo.cfg.0001.use1.cache.amazonaws.com
# CacheNodes Endpoint 2: mycluster.fnjyzo.cfg.0002.use1.cache.amazonaws.com
#
# Queries and returns the SORTED FIRST item
@Benjaminhu
Benjaminhu / config.insert.sql
Created August 23, 2020 11:43
PostgreSQL self-check config insert template
INSERT INTO
config (id, host, section, name, value)
SELECT
nextval('seq_config'::text), new.host, new.section, new.name, new.value
FROM (
SELECT DISTINCT host, '<SECTION>' AS section, '<NAME>' AS name, '<VALUE>' AS value FROM config
) AS new
WHERE NOT EXISTS (
SELECT notexists.host
FROM config AS notexists
<?php
include_once ' <<< PATH_TO >>> /vendor/autoload.php';
use QuickBooksOnline\API\DataService\DataService;
$config = [
'auth_mode' => 'oauth2',
'scope' => 'com.intuit.quickbooks.accounting',
'baseUrl' => 'Development',