Skip to content

Instantly share code, notes, and snippets.

View jbuncle's full-sized avatar

James Buncle jbuncle

View GitHub Profile
@jbuncle
jbuncle / build-patched-kernel.sh
Last active September 23, 2021 12:20
Compile and install Linux Kernel with patch for Lenovo Legion 5 15ARH05 Touchpad
#! /bin/bash
#
# Lenovo Legion 5 Patch Utility
#
# This script aims to simplify the application of various patches required for Lenovo Legion 5 15ARH05.
# For convenience you can run this script with `bash <(curl https://gist.githubusercontent.com/jbuncle/7dacde983b3c33b3b816b10e2fd2308a/raw/build-patched-kernel.sh)`
#
# References:
# - Original bug and related patch: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1887190
# - Touchpad patch file: https://www.spinics.net/lists/linux-input/msg69458.html
@jbuncle
jbuncle / install-docker.sh
Created June 24, 2020 15:19
Script for installing docker on ubuntu
#!/bin/sh
set -e
set -o xtrace
# bash <(curl -s https://gist.githubusercontent.com/jbuncle/409c26f4915c499cc4f48b2fbe9d9c35/raw)
# Docker
sudo apt-get update
sudo apt-get install \
@jbuncle
jbuncle / README.md
Last active October 23, 2020 09:14
PHP Script to upload/push a composer project to a Nexus Repository Manager (that supports composer).

Composer Nexus Upload/Push

Quick Usage

php <(curl -s https://gist.githubusercontent.com/jbuncle/8e479343cfeb785046e3c6fe1a73dcce/raw/nexus-upload.php) \
         --repository=https://example.nexus.repo.com/repository/composer-repo/ \
         --username=publisher-user \
         --password=$NEXUS_PASS \
         --version=$CI_COMMIT_TAG
@jbuncle
jbuncle / install-netbeans.sh
Last active May 8, 2020 16:13
Script for installing Netbeans 11 on Linux
#! /bin/bash -e
# bash <(curl -s https://gist.githubusercontent.com/jbuncle/02ff866cd799acd5c17ac6ff66ac3afe/raw)
set -o xtrace
STARTDIR=$(pwd)
VERSION=11.3
@jbuncle
jbuncle / jquery.dragAndDrop.js
Created July 8, 2016 23:49
jQuery Drag and Drop
$.fn.dragAndDrop = function ($to, callback) {
// 'this' is the element to be dragged.
var $from = $(this);
// Make draggable
$from.attr('draggable', 'true');
// Enable dragging over '$to'
$to.on('dragover', function (event) {
if ($from.has(event.currentTarget)) {
// Allow drag onto '$to' elements
@jbuncle
jbuncle / jQuery onEnterKeypress
Created July 1, 2016 08:49
Basic jQuery function for handling enter key being hit.
/**
* Basic jQuery function for handling enter key being hit.
*
* @returns jQuery
*/
$.fn.onEnterKeypress = function (callback) {
return $(this).keypress(function (evt) {
// Check for enter key
if (evt.which === 13) {
// Invoke callback
@jbuncle
jbuncle / jquery.scroll-highlight.js
Created May 19, 2016 12:54
Adds class to bookmark/local links when the linked element is in view.
/*!
* Adds class to bookmark/local links when the linked element is in view.
*
* Requires https://gist.github.com/jbuncle/6f6185e88be875b2585e736a422c3f15 for detecting when element is in view.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
@jbuncle
jbuncle / jquery.scroller.js
Last active May 19, 2016 12:29
Simple jQuery Plugin for using an animated scroll to on page anchors/links
/*!
* Simple jQuery Plugin for using an animated scroll to on page anchors/links.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.sibling-fader.js
Created May 19, 2016 12:23
Simple jQuery Plugin which fades out an elements siblings on hover.
/*!
* Simple jQuery Plugin which fades out an elements siblings on hover.
*
* Copyright 2016 James Buncle
*
* Released under the MIT license.
* http://jquery.org/license
*
*/
(function ($) {
@jbuncle
jbuncle / jquery.has-attr.js
Created May 19, 2016 12:20
jQuery plugin example of checking if an element has a given attribute
(function ($) {
$.fn.hasAttr = function (name) {
var currentAttr = $(this).attr(name);
return currentAttr !== undefined && currentAttr !== false;
};
})(jQuery);