Skip to content

Instantly share code, notes, and snippets.

@x8BitRain
x8BitRain / Dell XPS 13 Xorg touchpad settings
Last active May 14, 2019 11:26
File as /etc/X11/xorg.conf.d/30-touchpad.conf
Section "InputClass"
Identifier "libinput"
Driver "libinput"
MatchDevicePath "/dev/input/event*"
MatchIsTouchpad "true"
Option "Tapping" "True"
Option "TappingDragLock" "False"
Option "PalmDetection" "True"
Option "ButtonMapping" "1 2 3"
@x8BitRain
x8BitRain / Random Meta Theme Value
Created October 9, 2019 17:23
Random Meta Theme Value
//Generate Random Color
function getRandomColor() {
var letters = '0123456789ABCDEF';
var color = '#';
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
@x8BitRain
x8BitRain / corruptSVG.jsx
Last active November 4, 2019 17:23
Neat piece of React code that manipulates/corrupts SVGs
// This is a react component that's a part of an SVG corrupting web app I made:
// https://x8bitrain.github.io/svg-emoji-corrupt/
// While code is long the main function that does the actual manipulation is just a
// for loop that changes integer values when it matches a certain regex.
import React, { Component } from 'react';
import UIkit from 'uikit';
let svgDataLock = 0; // This stops svgOG from being updated the first execution.
let svgOG = []; // This is used to store a clone of the original values the
//paste into your browser dev console and mouse over your contribution graph.
document.querySelectorAll("rect.day").forEach(c => c.addEventListener('mouseover', function (e) {e.target.style.fill = '#196127'}));
def clock(time)
time = time.split(':')
hour = time.first.to_i
minute = time.last.to_i
angle = ((minute * 6) - (hour * 30))
if angle < 0
angle = angle.abs + minute * 0.5
<template>
<details :style="unknownCountry ? 'pointer-events: none;' : null">
<summary @click="getShippingData(country[1])" >
<img :src="getFlag(country)" alt="">
<h3>{{ country[0] }}</h3>
</summary>
<div class="listContainer">
<img v-if="!shippingData" src="../assets/img/loader.svg" />
<div v-if="shippingData" class="list">
<h2><u>{{ country[0] }}</u></h2>
@x8BitRain
x8BitRain / simulate_mouseover.js
Last active April 27, 2021 12:23
Simulate a Mouseover Event in JS
document.querySelector('#element').dispatchEvent(new MouseEvent('mouseover', {bubbles: true}))
@x8BitRain
x8BitRain / generateManifest.js
Last active October 15, 2022 17:14
PWA Share Target API accept any file type
// using 'application/*' doesn't do the trick but adding as many mimetypes and filetypes as you can seems to get the serviceworker to accept them if they are listed explicitly.
import mimeDb from 'mime-db'
import fileTypes from './src/utils/fileTypes' // from https://github.com/dyne/file-extension-list/blob/master/pub/extensions.json
const allFileTypesAndMimes = () => {
return process.env.NODE_ENV === 'production'
? [...Object.keys(mimeDb), ...fileTypes]
: []
}
@x8BitRain
x8BitRain / DragDropOverlay.vue
Last active October 15, 2022 17:14
Vue 3 Drag & Drop Overlay
<template>
<div
class="file-drop overlay"
@dragover="handleDrag"
@dragleave="toggleFileDrop"
@drop="handleDrop"
></div>
<div class="file-drop-text">
<h1>Upload File</h1>
<i-feather-upload />
@x8BitRain
x8BitRain / CustomLineChart.js
Last active October 15, 2022 17:16
ChartJS 3 Line Chart with vertical line on hover
import { LineController } from 'chart.js';
class CustomLineChart extends LineController {
draw() {
super.draw();
if (this.chart.tooltip._active && this.chart.tooltip._active.length) {
let activePoint = this.chart.tooltip._active[0],
ctx = this.chart.ctx,
x = activePoint.element.x,