Skip to content

Instantly share code, notes, and snippets.

@huyby
huyby / github-unsubscribe-all.js
Last active June 5, 2024 12:32
Github subscription clean up
function unsubscribeAll() {
fetch('https://github.com/notifications/subscriptions?reason=review_requested', {
method: 'POST',
body:new FormData(document.querySelector('#threads-unsubscribe-form')),
})
.then((response) => response.text())
.then((text) => {
document.querySelector('html').innerHTML=text
const subscriptionIds = document.querySelectorAll('input[name^=subscription_ids]');

Keybase proof

I hereby claim:

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

To claim this, I am signing this object:

@huyby
huyby / skip_includes_fieldresolver.patch
Created November 8, 2017 16:15
Temp 'fix' to allow related resource endpoints keep using nested include resources (e.g. field_image,field_image.uid)
diff --git a/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php b/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
index e74b26a..1e4bb69 100644
--- a/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
+++ b/src/Normalizer/JsonApiDocumentTopLevelNormalizer.php
@@ -247,6 +247,8 @@ class JsonApiDocumentTopLevelNormalizer extends NormalizerBase implements Denorm
protected function expandContext(Request $request, ResourceType $resource_type) {
// Translate ALL the includes from the public field names to the internal.
$includes = array_filter(explode(',', $request->query->get('include')));
+ $public_includes = $includes;
+ /*
--- ./src/Controller/FieldablePathController.php 2017-05-18 11:51:40.000000000 +0200
+++ ./src/Controller/FieldablePathController.php 2017-05-18 11:59:01.000000000 +0200
@@ -43,7 +43,7 @@
->load($params[$entity_type]);
// Make sure the current entity exists and contains path field.
- if (empty($entity) || !$entity->hasField('path')) {
+ if (empty($entity) || !(method_exists($entity, 'hasField') && $entity->hasField('path'))) {
return;
}
@huyby
huyby / ssh_port_forwarding
Created March 6, 2017 13:46
SSH port forwarding commands; useful for forwarding a remote database connection over SSH in combination with other configurations like a jump host (bastion)
# Overview on SSH port forwarding: http://blog.trackets.com/2014/05/17/ssh-tunnel-local-and-remote-port-forwarding-explained-with-examples.html
# Example of MySQL database connection tunnel using a jump host
ssh -F ./ssh.cfg -nNT -L 33060:localhost:3306 remotehost
# ./.ssh.cfg contents
Host bastion
Hostname 8.8.8.8
User bastion-user
@huyby
huyby / laravel.sh
Last active December 15, 2015 14:54
Bash script for a quick(er) Laravel applicaton setup
#!/usr/bin/env bash
# Prompt for Yes/No answer
# $1 - question
# $2 - default answer (Y|N)
ask() {
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
@huyby
huyby / createmysqldb.sh
Last active August 29, 2015 14:23
Create a MySQL database, dito user and random generated password.
#!/bin/sh
# Tiny script to create a mysql user and database with same
# name. A random password is generated (yay!)
usage() {
cat << __EOT
Usage: createmysqldb.sh <dbname>
where <dbname> is the one-word name you'd like to use as database name and
username if -u parameter is not set.
Options:
@huyby
huyby / php_cli_xdebug.md
Created November 26, 2013 08:49
PHP cli debugging with Netbeans

PHP cli config

Check cli config if xdebug is configured.

Xdebug ide key

Export 'XDEBUG_CONFIG' with 'idekey=netbeans-xdebug'

$ export XDEBUG_CONFIG="idekey=netbeans-xdebug"

@huyby
huyby / ffmpeg-web-video.md
Last active August 30, 2016 14:24
Use ffmpeg/ffmpeg2theora to convert video to formats suitable for web usage, convertors like Miro Video Converter don't always have good results. Also check ffmpegx GUI.
@huyby
huyby / replace-ssh-key.md
Last active November 28, 2016 16:29
Replace or delete ssh key in authorized_key files

Test for replacement

sed -n 's#ssh-rsa.*OLD_KEY_ID#NEW_KEY# p' .ssh/authorized_keys

Test for deleting

sed -n '#ssh-rsa.*KEY_ID# p' .ssh/authorized_keys

Do replacement in multiple authorized_key files (change maxdepth to your needs)