Skip to content

Instantly share code, notes, and snippets.

@giventofly
giventofly / gist:53e6b594fde7cea977f8d262919c3978
Created September 16, 2024 08:42
count umber of loans levvy.js
let elements = document.querySelectorAll('.h-24');
let totalLoan = 0;
elements.forEach(element => {
totalLoan++;
});
alert('Total Loan: ' + totalLoan);
@giventofly
giventofly / wiiu_cemu_gamepad_exit.md
Created September 8, 2024 23:39
Batocera wiiu gamepad exit

ssh into batocera nano /usr/share/evmapy/wiiu.keys add this entry to use select+start to exit the emulator:

{
           "trigger": ["select", "start"],
            "type": "key",
            "target": ["KEY_LEFTALT", "KEY_F4"],
            "description": "Exit emulator"
 },
@giventofly
giventofly / levvy.calculate.loans.js
Last active August 28, 2024 08:10
Levvy.fi calculate loans+interest per token and total
// Seleciona todos os elementos com a classe 'h-24'
let elements = document.querySelectorAll('.h-24');
// Inicializa uma variável para manter a soma total
let totalSum = {loan: 0, interest: 0, total: 0};
// guardar os valores
let loans = {};
// Itera através de cada elemento selecionado
@giventofly
giventofly / 8bitdo Batocera M30 mapping.md
Last active July 10, 2024 18:22
8bitdo Batocera M30 mapping
A = SOUTH
B = EAST
X = WEST
Y = NORTH
Z = L bumper
C = R bumper
L = Left Trigger
R = Right Trigger
Start = Start
@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;
}