Skip to content

Instantly share code, notes, and snippets.

View Lewiscowles1986's full-sized avatar
🤓

Lewis Cowles Lewiscowles1986

🤓
View GitHub Profile
@Lewiscowles1986
Lewiscowles1986 / closestNumberArray.js
Created August 26, 2018 05:28 — forked from vipickering/closestNumberArray.js
Javascript: Find The Closest Number In Array To A Specific Value
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;
@Lewiscowles1986
Lewiscowles1986 / destroy-sticky-header.js
Created August 18, 2018 07:35
Destroy sticky headers
/*
* 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 August 11, 2018 11:03
Testing Nextcloud using Docker
#!/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 August 11, 2018 11:02
Testing Onlyoffice with nextcloud
#!/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 November 18, 2023 19:08
Playstation 2 EU USB "The Buzz" controller

"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 10:11
Anonymous Upload images to Imgur V3 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;
}
@Lewiscowles1986
Lewiscowles1986 / script.js
Last active November 10, 2019 10:03
Prev Next JS injection
/*
* Used via https://chrome.google.com/webstore/detail/user-javascript-and-css/nbhcbdghjpllgmfilhnhkllmkecfmpld
* to embed JS in all web-pages that are compliant to enable keyboard-navigation of blog posts
*/
(function() {
window.addEventListener('keydown', function(e) {
switch(e.key) {
case 'Left': // IE11 BS
case 'ArrowLeft':
var link = document.querySelector('a[rel="prev"], .prev, #previtem');
[Desktop Entry]
Type=Action
ToolbarLabel[en_GB]=Convert MVE to MP4
ToolbarLabel[en]=Convert MVE to MP4
ToolbarLabel[C]=Convert MVE to MP4
Name[en_GB]=Convert MVE to MP4
Name[en]=Convert MVE to MP4
Name[C]=Convert MVE to MP4
Profiles=profile-zero;
@Lewiscowles1986
Lewiscowles1986 / sloyalty-livechat-whole-page-screenshot-prep.js
Created March 23, 2018 08:01
Moving SLoyalty & LiveChat out of my way for full-page screenies
var ensure_ss = function() {
let sel = '#sloyalty-display, #livechat-compact-container, .sloyalty-tab-widget[name="sloyalty-loyalty-widget-iframe"]';
[].slice.call(document.querySelectorAll(sel)).forEach(function(elem){
elem.style.position="absolute";
});
console.log('document mutation detected')
};
var observer = new MutationObserver(ensure_ss);
observer.observe(document, { childList: true });
document.addEventListener("DOMNodeInserted", ensure_ss, false);
@Lewiscowles1986
Lewiscowles1986 / benchmark-pc.c
Created March 13, 2018 17:56
Benchmarking PC
// Integer and float benchmark for Win32 and Win64
// Results are below main(), line 91
#include <stdlib.h>
#include <stdio.h>
#ifdef _WIN32
#include <sys/timeb.h>
#else
#include <sys/time.h>
#endif