Skip to content

Instantly share code, notes, and snippets.

@giventofly
giventofly / 8bitdo Batocera M30 mapping.md
Last active April 12, 2024 20:23
8bitdo Batocera M30 mapping

A = SOUTH B = EAST C = R bumper X = WEST Y = NORTH Z = L bumper L = Left Trigger R = Right Trigger Start = Start Minus(8bitdo) = select

@giventofly
giventofly / change img.md
Last active April 5, 2024 08:33
Change .img or mount

source: https://superuser.com/a/1409363

Here's the process:

fdisk -l raspberry_pi.img

Which gives the output below. Note the sector size in bytes (512 in this case; see line 2 below) and the Start sector of the partition (94208 for the Linux partition; see the last line below).

Disk raspberry_pi.img: 7.3 GiB, 7826571264 bytes, 15286272 sectors
Units: sectors of 1 * 512 = 512 bytes
@giventofly
giventofly / 8bitdo.m30.batocera.retropie.md
Last active July 28, 2023 00:18
8bitdo M30 on batocera/retropie/retroarch for megadrive and saturn

source: https://japanatron.com/blog/other/it/10417-batocera-how-to-pair-8bitdo-m30-controller

  1. Put the controller into pairing mode first, then start Bluetooth discovery on Batocera. Use the Android D-input (Start + B) pairing mode.
  2. After pairing it, it will likely go kinda crazy. Down doesn't work, and it keeps scrolling to the side, etc. Take a deep breath. We can fix this.
  3. Turn off the controller by holding down start.
  4. Restart Batocera.
  5. Turn on the controller by holding down start. BOOM! PROFIT!
@giventofly
giventofly / gist:9b5cc78ba41e6a77711f960fd80eda88
Last active July 17, 2023 07:31
Samsung g9 linux display resolution xrandr

Add on $HOME/.xprofile to autoload on boot:

xrandr --newmode "5120x1440_59.97" 292.75  5120 5360 5888 6656  1440 1443 1453 1468 +hsync +vsync
xrandr --addmode HDMI-2 5120x1440_59.97
xrandr --output HDMI-2 --mode 5120x1440_59.97

or run

@giventofly
giventofly / timeago.js
Created July 18, 2022 14:20
javascript unixtime time ago
const timeAgo = (unixtime)=> {
var seconds = Math.floor((new Date() - unixtime * 1000) / 1000);
var interval = seconds / 31536000;
if (interval > 1) {
return Math.floor(interval) + " years ago";
}
interval = seconds / 2592000;
@giventofly
giventofly / youtube_id_regex.php
Created July 7, 2022 12:44 — forked from ghalusa/youtube_id_regex.php
Extract the YouTube Video ID from a URL in PHP
<?php
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored)
// http://youtu.be/dQw4w9WgXcQ
// http://www.youtube.com/embed/dQw4w9WgXcQ
// http://www.youtube.com/watch?v=dQw4w9WgXcQ
// http://www.youtube.com/?v=dQw4w9WgXcQ
// http://www.youtube.com/v/dQw4w9WgXcQ
// http://www.youtube.com/e/dQw4w9WgXcQ
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ
@giventofly
giventofly / expandContractTextArea.js
Created June 30, 2022 20:17
Auto expand contract textarea
//calculates using newlines
//*** text area grow */
const calcNewLines = (value) => {
let numberOfLineBreaks = (value.match(/\n/g) || []).length;
// min-height + lines x line-height + padding + border
//let newHeight = 34 + numberOfLineBreaks * 20 + 12 + 2;
let newHeight = 34 + numberOfLineBreaks * 24 + 12 + 2;
if (!numberOfLineBreaks) {
newHeight = 36;
}
@giventofly
giventofly / linux keyboard not detected on boot need to replug
Created June 24, 2022 11:01
linux keyboard not detected on boot need to replug
https://forums.linuxmint.com/viewtopic.php?f=49&t=287775&p=1593262&hilit=SOLVED+USB+Ports+Working+Correctly#p1593262
tldr: add on grub boot: quiet splash usbcore.autosuspend=-1
@giventofly
giventofly / fix mysql database error MySQL table is marked as crashed and last (automatic?) repair failed.md
Last active June 19, 2022 11:37
fix mysql database error MySQL table is marked as crashed and last (automatic?) repair failed
@giventofly
giventofly / readme.md
Last active May 30, 2022 13:05
citrix linux use control key