Skip to content

Instantly share code, notes, and snippets.

View kgust's full-sized avatar

Kevin Gustavson kgust

  • Vanderbilt University Medical Center
  • Nashville, Tennessee USA
View GitHub Profile
@kgust
kgust / symfony-form-event-listener.php
Created March 31, 2024 02:20
This is an example Symfony form event listener.
<?php
$builder->addEventListener(FormEvents::POST_SUBMIT, function ($event) {
$form = $event->getForm();
$oldPassword = $form->get('old_password')->getData();
$newPassword = $form->get('password')->get('first')->getData();
$user = $this->security->getUser();
if (!$this->passwordEncoder->isPasswordValid($user, $oldPassword)) {
$form->get('old_password')->addError(new FormError('The old password is incorrect.'));
@kgust
kgust / fetch.js
Created March 31, 2024 02:16
Use JavaScript's native fetch
let promise = fetch(url, {
method: "GET", // POST, PUT, DELETE, etc.
headers: {
// the content type header value is usually auto-set
// depending on the request body
"Content-Type": "text/plain;charset=UTF-8"
},
body: undefined, // string, FormData, Blob, BufferSource, or URLSearchParams
referrer: "about:client", // or "" to send no Referer header,
// or an url from the current origin
@kgust
kgust / Roku Secret Menus.md
Last active January 20, 2024 15:35
Roku Secret Menus

Here is a list of currently-working secret menus, though new ones are discovered often:

  • Home x 5 + FF x 3 + RW x 2: Secret screen one (factory reset, USB test, cycle channel store, update server/software, enable debug)
  • Home x 5 + U + R + D + L + U: Secret screen two (cycle screenshot, cycle ad-banner, remote auto-pair, log theme info)
  • Home x 5 + U + D + U + D + U: Wi-Fi secret screen
  • Home x 5 + FF + PP + RW + PP + FF: Platform secret screen
  • Home x 5 + FF + D + RW + D + FF: Antenna secret screen
  • Home x 5 + RW x 3 + FF x 2: Bitrate override
  • Home x 3 + U x 2 + R + L + R + L + R: Developer settings
  • Home x 3 + U x 2 + L + R + L + R + L: Channel info
@kgust
kgust / parse-composer-lock.sh
Last active October 12, 2023 18:19
Using jq to parse composer.lock
<composer.lock jq '.packages[] | [.name, .version]' | less
@kgust
kgust / ldap.php
Created March 4, 2023 18:36
Testing LDAP Bind
<?php
// using ldap bind
$ldaprdn = $RDN; // ldap rdn or dn
$ldappass = $PASS; // associated password
// connect to ldap server
$ldapconn = ldap_connect($ldapUrl)
or die("Could not connect to LDAP server.");
@kgust
kgust / cs_fixer.php
Last active June 17, 2020 12:56
Configurations for php-cs-fixer (we are using phpcs and phpcbf instead)
<?php
require('./vendor/autoload.php');
$finder = PhpCsFixer\Finder::create()
->notPath('vendor')
->in(__DIR__)
->name('*.php')
->ignoreDotFiles(true)
->ignoreVcs(true)
<?php
// input misspelled word
$input = 'carrrot';
// array of words to check against
$words = array('apple','pineapple','banana','orange',
'radish','carrot','pea','bean','potato');
// no shortest distance found, yet
$shortest = -1;
@kgust
kgust / README.md
Last active May 29, 2019 13:02 — forked from ralphschindler/README.md
Docker For Mac - De-facto Host Address Alias (10.254.254.254) - "The 10254 Trick".

Docker (Mac) De-facto Standard Host Address Alias

This launchd script will ensure that your Docker environment on your Mac will have 10.254.254.254 as an alias on your loopback device (127.0.0.1). The command being run is ifconfig lo0 alias 10.254.254.254

Installation

Copy/Paste the following in terminal with sudo (must be root as the target directory is owned by root)...

sudo curl -o /Library/LaunchDaemons/info.kevingustavson.docker_10254_alias.plist https://gist.github.com/kgust/3fe1ae7420e2b35ed3b40eb3feef4efe/raw/info.kevingustavson.docker_10254_alias.plist
@kgust
kgust / dark.md
Created December 4, 2018 18:01 — forked from a7madgamal/dark.md
Dark mode for Slack on MacOS
  1. Close slack
  2. Open this file /Applications/Slack.app/Contents/Resources/app.asar.unpacked/src/static/ssb-interop.js
  3. Append this to it
document.addEventListener('DOMContentLoaded', function() {
 $.ajax({
   url: 'https://cdn.rawgit.com/laCour/slack-night-mode/master/css/raw/black.css',
   success: function(css) {
 $("").appendTo('head').html(css);
@kgust
kgust / php-phpdbg-proxy.sh
Created November 29, 2018 13:39 — forked from VeryStrongFingers/php-phpdbg-proxy.sh
PHPStorm - PHP-PHPDBG Interpreter proxy
#!/bin/bash
#### Dirty/Fake PHP Interpreter to trick PHPStorm into using PHPDBG for running tests with/without code coverage
## For Mac/Linux only, Window's ubuntu subsystem theoretically would work too
##
##
## Related JetBrain's issues/feature requests
## https://youtrack.jetbrains.com/issue/WI-21414
## https://youtrack.jetbrains.com/issue/WI-29112
##