Skip to content

Instantly share code, notes, and snippets.

View magicdude4eva's full-sized avatar

Gerd Naschenweng magicdude4eva

View GitHub Profile
@magicdude4eva
magicdude4eva / zsh-syntax-highlighting paste performance improvement
Last active April 25, 2025 19:23
zsh-syntax-highlighting paste performance improvement
Add the following in .zshrc:
...
plugins=(osx git zsh-autosuggestions zsh-syntax-highlighting zsh-nvm docker kubectl)
...
### Fix slowness of pastes with zsh-syntax-highlighting.zsh
pasteinit() {
OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]}
zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`?
@magicdude4eva
magicdude4eva / smtp-test.php
Created February 1, 2019 09:59
SMTP Test via PHPMailer
<?php
/*
To test: Run on any version of PHP, then install "PHPMailer" via composer:
composer require phpmailer/phpmailer
Test login via: https://outlook.office365.com/ecp/
*/
$fromAddress = 'XXX@domain.com';
$recipientAddress = 'YYY@recipientdomain.com';
import java.util.*;
public class MemEat {
public static void main(String[] args) {
List l = new ArrayList<>();
System.out.println("Max Java Memory (MB): " + Runtime.getRuntime().maxMemory() / (1_024 * 1_024));
System.out.println("Total Memory (MB): " + Runtime.getRuntime().totalMemory() / (1_024 * 1_024));
System.out.println("Max Java CPU Cores: " + Runtime.getRuntime().availableProcessors());
while (true) {
@magicdude4eva
magicdude4eva / Huawei.php
Created April 14, 2019 10:54
Huawei B618s-22d - reboot script and retrieval of other info
<?php
// Config
$routerAddress = '192.168.8.1';
$username="admin";
$password="password";
// Code
$router = new HuaweiB618($routerAddress);
@magicdude4eva
magicdude4eva / logstash.conf
Created March 13, 2017 12:48
Port25 / PowertMTA Logstash / Graylog configuration
################################################################################
## Port25 Logstash configuration
##
## Logging configuration:
##
## <acct-file /var/log/pmta/acct.csv>
## delete-after 60d
## move-interval 5m
## max-size 500M
## records d,b,r,t,tq,f,rb,rs
@magicdude4eva
magicdude4eva / better-touch-bar-crypto.json
Last active March 6, 2024 19:27
Better-Touch-Bar Config for Crypto currencies - BTC / Ether / Ripple
{
"BTTPresetName" : "CryptoCurrency",
"BTTPresetUUID" : "3A49CBCE-DE02-4F8F-A70E-6BA367ACD683",
"BTTPresetContent" : [
{
"BTTAppBundleIdentifier" : "BT.G",
"BTTAppName" : "Global",
"BTTAppSpecificSettings" : {
},
@magicdude4eva
magicdude4eva / dnstest.sh
Last active March 12, 2023 12:01
Dnstest
#!/usr/bin/env bash
command -v bc > /dev/null || { echo "bc was not found. Please install bc."; exit 1; }
{ command -v drill > /dev/null && dig=drill; } || { command -v dig > /dev/null && dig=dig; } || { echo "dig was not found. Please install dnsutils."; exit 1; }
NAMESERVERS=`cat /etc/resolv.conf | grep ^nameserver | cut -d " " -f 2 | sed 's/\(.*\)/&#&/'`
PROVIDERS="
1.1.1.1#cloudflare
4.2.2.1#level3
@magicdude4eva
magicdude4eva / bidorbuy-test.md
Last active November 27, 2021 11:45
Bidorbuy Java test

Programming example - Write an app:

  • For Java tests create a Tomcat/Webapp project using Eclipse and then write a simple search/display results app using JSPs.
  • For Android / iOS native apps use the respective development IDEs (Android Studio or XCode)
  • Email back the completed project (it should be importable into the IDE and just run)
  • There is no limit to creativity/what you use. The code should however follow a MVC pattern and have abstraction/separation of concerns (i.e. network logic should not be part of presentation logic)

The service to call for this exercise is the Paginated Trade Search service. It is a RESTful GET service you will call with HTTP parameters to retrieve the results you want. For authentication to the service you will add HTTP headers to your request.

First things first, each call you make to our demo service requires the following HTTP headers:

@magicdude4eva
magicdude4eva / FileDownload.java
Created June 8, 2017 19:05
How to bypass SSLProtocolException: handshake alert: unrecognized_name
/** Downloads a file from the specified URL to the specified local file path.
* It returns the number of bytes in the downloaded file,
* or throws an exception if there is an error.
*
* @param aURL
* @param aLocalFilePath
* @param aMilliSecondTimeout
* @param aSkipSNI
* @return
*/
@magicdude4eva
magicdude4eva / dyn_dns_acme.sh
Created July 5, 2017 15:55
dyn_dns_acme.sh
#!/usr/bin/bash
#DynDNS.com Domain API
CUSTOMERNAME='PLEASE-SET'
USERNAME='PLEASE-SET'
PASSWORD='PLEASE-SET'
DYNAPIURL="https://api.dynect.net/"
ZONE="PLEASE-SET"