Skip to content

Instantly share code, notes, and snippets.

View ravexina's full-sized avatar
💭

Ravexina ravexina

💭
View GitHub Profile
@ravexina
ravexina / fix-git-line-endings
Created August 16, 2023 11:58 — forked from ajdruff/fix-git-line-endings
Forces all line endings to LF in your git repo.
#####################
#
# Use this with or without the .gitattributes snippet with this Gist
# create a fixle.sh file, paste this in and run it.
# Why do you want this ? Because Git will see diffs between files shared between Linux and Windows due to differences in line ending handling ( Windows uses CRLF and Unix LF)
# This Gist normalizes handling by forcing everything to use Unix style.
#####################
# Fix Line Endings - Force All Line Endings to LF and Not Windows Default CR or CRLF
@ravexina
ravexina / postgres-cheatsheet.md
Created May 30, 2021 16:17 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@ravexina
ravexina / users.rules
Created May 9, 2020 20:12
Polkit users rules
polkit.addRule(function(action, subject) {
if (action.id.match("org.freedesktop.udisks2.") && subject.isInGroup("storage")) {
return polkit.Result.YES;
}
});
polkit.addRule(function(action, subject) {
if ( (action.id.match("org.freedesktop.login1.") || action.id.match("org.freedesktop.upower.")) && subject.isInGroup("power")) {
return polkit.Result.YES;
@ravexina
ravexina / lastfm-remove-duplicates.js
Last active March 13, 2020 11:44 — forked from sk22/lastfm-remove-duplicates.js
Last.fm duplicate scrobble deleter
var max = 20; var num = 5; var counter = 1;
var sections = Array.from(document.getElementsByTagName("tbody"));
sections.forEach(function (section) {
var elements = Array.from(section.rows);
var titles = elements.map(function (element) {
var nameElement = element.querySelector('.chartlist-name');
var artistElement = element.querySelector('.chartlist-artist');
return nameElement && artistElement && nameElement.textContent.replace(/\s+/g, ' ').trim()+':'+artistElement.textContent.replace(/\s+/g, ' ').trim();
});
@ravexina
ravexina / netplan.yaml
Created April 1, 2019 16:41
Netplan example configuration and simple usage
# - - - - - - - - - - - - - - - - - -
# > $ sudo netplay try
# > $ sudo netplan apply
# > $ ip link set ens3 down/up
# > $ ip addr show ens3
# - - - - - - - - - - - - - - - - - -
# - - - - - - - - - - - - - - - - - -
# Static configuration
# - - - - - - - - - - - - - - - - - -
@ravexina
ravexina / search-docker-image-tags.sh
Created March 23, 2019 10:17
Search for Docker image tags
#!/bin/bash
IMAGE="$1"
QUERY="$2"
curl -s "https://hub.docker.com/v2/repositories/library/${IMAGE}/tags/?page_size=500" | jq -r ".results[] .name" | grep "$QUERY"
###
#
@ravexina
ravexina / output-duplicate-lines.php
Last active August 6, 2017 18:43
PHP - Output only lines with duplicate words (singular or plural)
<?php
// Ravexina
// A more canonical answer has been sent here: "https://stackoverflow.com/questions/45528160/output-only-lines-with-duplicate-words"
// The included class.php is from here: "https://gist.github.com/tbrianjones/ba0460cc1d55f357e00b"
// This code tries to address the OP's comments
$text = "This is a best website of all the websites out there
This is a great website