Skip to content

Instantly share code, notes, and snippets.

Avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / scroll-position-hide-fb.js
Created Oct 23, 2018
Hide / show element depending on scroll position
View scroll-position-hide-fb.js
(function(target, threshold, elem) {
listener = () => {
if (target.scrollY > threshold) {
elem.style.opacity = 1;
} else {
elem.style.opacity = 0;
}
};
target.addEventListener(
'scroll',
@Lewiscowles1986
Lewiscowles1986 / count-lines
Created Oct 7, 2018
Count lines in files
View count-lines
#!/bin/python
"""
This utility allows you to count the number of lines in files
by default just .py files, but accepts command-line arguments.
This utility does miss files and folders beginning with '.'
so don't use them!
usage: {script} {path} [extensions] [exclude]
@Lewiscowles1986
Lewiscowles1986 / index.php
Last active Sep 23, 2018
WordPress media Taxonomies
View index.php
<?php
/*
Plugin Name: CODESIGN2 Media Taxonomy Modifications
Plugin URI: http://www.codesign2.co.uk
Description: We think it's a real shame that media can be a little unweildy, and not make much sense; on larger sites it's debilitating, so we made this plugin. Enjoy
Author: CODESIGN2
Version: 1.3.6
Author URI: http://www.codesign2.co.uk/
*/
@Lewiscowles1986
Lewiscowles1986 / grub.cfg
Last active May 14, 2020
multiboot USB Linux goodness
View grub.cfg
# This grub.cfg file was created by Lance http://www.pendrivelinux.com
# Suggested Entries and the suggestor, if available, will also be noted.
set timeout=10
set default=0
set gfxpayload=keep
submenu "Ubuntu" {
menuentry "Ubuntu Desktop ISO" {
set isofile=/ubuntu.iso
@Lewiscowles1986
Lewiscowles1986 / closestNumberArray.js
Created Aug 26, 2018 — forked from vipickering/closestNumberArray.js
Javascript: Find The Closest Number In Array To A Specific Value
View closestNumberArray.js
var array = [];
function closest(array,num){
var i=0;
var minDiff=1000;
var ans;
for(i in array){
var m=Math.abs(num-array[i]);
if(m<minDiff){
minDiff=m;
View destroy-sticky-header.js
/*
* Find sticky header elements annoying? Well delete them with this
*
* inspired by https://www.ghacks.net/2018/08/16/remove-anything-that-is-sticky-on-websites/
* improved (IE9, all recent chrome, mozilla, mobile browsers) using information from:
*
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf
* - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
* - https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
@Lewiscowles1986
Lewiscowles1986 / nextcloud.sh
Created Aug 11, 2018
Testing Nextcloud using Docker
View nextcloud.sh
#!/bin/bash
mkdir -p ~/nextcloud
docker run -t -d --restart=always --name=nextcloud --publish 7000:80 --volume $PWD/nextcloud:/var/www/html:z nextcloud
@Lewiscowles1986
Lewiscowles1986 / onlyoffice.sh
Created Aug 11, 2018
Testing Onlyoffice with nextcloud
View onlyoffice.sh
#!/bin/bash
mkdir -p ~/onlyoffice
docker run -i -t -d --name=onlyoffice -p 7050:80 \
--volume ~/onlyoffice/logs:/var/log/onlyoffice:z \
--volume ~/onlyoffice/data:/var/www/onlyoffice/Data:z \
--volume ~/onlyoffice/lib:/var/lib/onlyoffice:z \
--volume ~/onlyoffice/db:/var/lib/postgresql:z onlyoffice/documentserver
@Lewiscowles1986
Lewiscowles1986 / README.md
Last active Apr 17, 2019
Playstation 2 EU USB "The Buzz" controller
View README.md

"The Buzz" Playstation 2 EU USB controller

Using tool "Simple HID Write"

  • W: Write
  • R: Read
W 00 {FF} 00 00 00 // controller 1 red light activate
W 00 {00} 00 00 00 // controller 1 red light deactivate
@Lewiscowles1986
Lewiscowles1986 / script.js
Created May 20, 2018
Anonymous Upload images to Imgur V3 JS
View script.js
var ImgurAPIKey = 'YEAH-IM-NOT-GIVING-THAT';
window.addEventListener('paste', function(e) {
function eventPreventDefault(e) {
e.preventDefault();
}
function getClipboardData(e) {
return window.clipboardData || e.clipboardData;
}
You can’t perform that action at this time.