Skip to content

Instantly share code, notes, and snippets.

View icetee's full-sized avatar
:atom:
Development

Tamás András Horváth icetee

:atom:
Development
View GitHub Profile
@icetee
icetee / serial_number_generator.js
Created October 14, 2021 14:33
Get random serial numbers
let count = 10100;
let prefix = "KGY"
let keys = [];
let getRandomNumber = () => ("0000" + Math.round(Math.random() * 10000)).slice(-4)
do {
let randomKey = prefix + "-" + getRandomNumber() + "-" + getRandomNumber();
if (keys.indexOf(randomKey) === -1) {
@icetee
icetee / filtered_contact_type.patch
Last active June 26, 2021 20:34
Hotfix for CiviCRM contact_type Organization filter and disable "factory" contact
--- web/app/plugins/civicrm/civicrm/CRM/Profile/Selector/Listings.php
+++ Listings.php
@@ -451,6 +451,8 @@
$additionalWhereClause = 'contact_a.is_deleted = 0';
+ $extraWhereClause = 'contact_a.contact_type = "Organization" AND contact_a.id != 1';
+
if ($extraWhereClause) {
$additionalWhereClause .= " AND {$extraWhereClause}";
@icetee
icetee / mailtrain_scrapper.js
Created April 20, 2021 09:39
MailTrain export scrapper script
var rows = [];
$('tbody tr').each((i, elem) => {
var $elem = $(elem),
$td = $(elem).find('td');
var row = [];
row.push($td[0].innerText);
row.push($td[1].innerText);
row.push($td[2].innerText);
var shortcode = '[hello name="world"]';
var attributes = {};
shortcode.match(/[\w-]+=".+?"/g).forEach(function(attribute) {
attribute = attribute.match(/([\w-]+)="(.+?)"/);
attributes[attribute[1]] = attribute[2];
});
console.log(attributes);
@icetee
icetee / restart-touchbarserver.sh
Created October 26, 2020 18:46
Restart TouchBarServer
sudo pkill TouchBarServer; sudo killall ControlStrip
@icetee
icetee / realname.diff
Created March 23, 2020 14:59
Drupal realname diff
diff --git a/realname.api.php b/realname.api.php
index 09e813e..d5420bd 100644
--- a/realname.api.php
+++ b/realname.api.php
@@ -53,6 +53,17 @@ function hook_realname_update($realname, $account) {
}
+/**
+ * Respond to updates to accounts
@icetee
icetee / acf-pagination.php
Created August 24, 2019 11:07 — forked from kisabelle/acf-pagination.php
ACF Repeater Field Pagination
<?php
/*
* Paginate Advanced Custom Field repeater
*/
if( get_query_var('page') ) {
$page = get_query_var( 'page' );
} else {
$page = 1;
}
@icetee
icetee / bootstrap-grid-col-same-height.css
Created March 28, 2019 02:22
Bootstrap grid col same height
.row {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
flex-wrap: wrap;
}
.row > [class*='col-'] {
display: flex;
flex-direction: column;
@icetee
icetee / .my.cnf
Last active March 17, 2022 06:19
Backup for MySQL with mysqldump (all database)
[mysql]
user=backups
password=secret
[mysqldump]
user=backups
password=secret
@icetee
icetee / wp_relative_url.php
Created January 17, 2019 09:42
Use relative URL for WordPress
function callback_relative_url($buffer) {
// Replace normal URLs
$home_url = esc_url(home_url('/'));
$home_url_relative = wp_make_link_relative($home_url);
// Replace URLs in inline scripts
$home_url_escaped = str_replace('/', '\/', $home_url);
$home_url_escaped_relative = str_replace('/', '\/', $home_url_relative);
$buffer = str_replace($home_url, $home_url_relative, $buffer);