Skip to content

Instantly share code, notes, and snippets.

View srgpsk's full-sized avatar

Serge Paskal srgpsk

View GitHub Profile
@andrebrait
andrebrait / keychron_linux.md
Last active June 16, 2024 19:44
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Note: many newer Keychron keyboards use QMK as firmware and most tips here do not apply to them. Maybe the ones related to Bluetooth can be useful, but everything related to Apple's keyboard module (hid_apple) on Linux, won't work. As far as I know, all QMK-based boards use the hid_generic module instead. Examples of QMK-based boards are: Q, Q-Pro, V, K-Pro, etc.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work (NOT FOR QMK-BASED BOARDS)

Older Keychron keyboards (those not based on QMK) use the hid_apple driver on Linux, even in the Windows/Android mode, both in Bluetooth and Wired modes.

@stof
stof / ComplexSqlBuilder.php
Created October 16, 2020 13:52
Building SQL queries using CTE with Doctrine DBAL
<?php
namespace Incenteev\WebBundle\Doctrine;
class ComplexSqlBuilder
{
/**
* @param string $mainSql
* @param string[] $cteQueries
* @param bool $recursive
@jonathantneal
jonathantneal / detect-autofill.js
Created September 11, 2018 14:56
Detect autofill in Chrome, Edge, Firefox, and Safari
export default scope => {
// match the filter on autofilled elements in Firefox
const mozFilterMatch = /^grayscale\(.+\) brightness\((1)?.*\) contrast\(.+\) invert\(.+\) sepia\(.+\) saturate\(.+\)$/
scope.addEventListener('animationstart', onAnimationStart)
scope.addEventListener('input', onInput)
scope.addEventListener('transitionstart', onTransitionStart)
function onAnimationStart(event) {
// detect autofills in Chrome and Safari by:
@jwilson8767
jwilson8767 / es6-element-ready.js
Last active April 22, 2024 20:28
Wait for an element to exist. ES6, Promise, MutationObserver
// MIT Licensed
// Author: jwilson8767
/**
* Waits for an element satisfying selector to exist, then resolves promise with the element.
* Useful for resolving race conditions.
*
* @param selector
* @returns {Promise}
*/
@dylants
dylants / proton-mail.css
Last active April 28, 2022 20:39
Dark Theme for Proton Mail
/* ProtonMail */
/* CLASSIC THEME */
body { font-size: 14px }
body,
.pm_opensans {
font-family: 'Lucida Grande', Verdana, Arial, sans-serif
}
// XPath CheatSheet
// To test XPath in your Chrome Debugger: $x('/html/body')
// http://www.jittuu.com/2012/2/14/Testing-XPath-In-Chrome/
// 0. XPath Examples.
// More: http://xpath.alephzarro.com/content/cheatsheet.html
'//hr[@class="edge" and position()=1]' // every first hr of 'edge' class
@brunobraga
brunobraga / pingi
Created November 1, 2013 00:04
A simple script wrapping ping for better output on issues (host unreachable or timeout).
#!/bin/bash
#
# File: pingi
#
# Purpose: Ping Improved. Actually just handles better the timeout/unreachable.
#
# Author: BRAGA, Bruno <bruno.braga@gmail.com>
#
# Copyright:
#
@sergeylukin
sergeylukin / optimg.sh
Last active July 3, 2019 07:15
Shell script for JPGs and PNGs optimization
#!/usr/bin/env sh
#
# This script automates images optimization
# is mainly used by a developer who manually
# can execute it when adding new images to the
# project
#
# Download and compile following binaries:
#
# - [jpegtran](http://www.ijg.org/)
@codecat
codecat / imgur-uploader
Created July 4, 2012 22:23 — forked from robertbasic/imgur-uploader
xfce4-screenshooter to imgur
#!/bin/bash
# Ubuntu Keyboard settings shortcut:
# xfce4-screenshooter -r -o "sh /location/to/imgur-uploader.sh"
API_KEY=YOUR_API_KEY_GOES_HERE
URL=http://api.imgur.com/2/upload
RESPONSE=$(curl -s -F "key=$API_KEY" -F "image=@$1" $URL)
echo "$RESPONSE" | grep -o -E "<original>.*</original>" | grep -o -E "http://.*\.png" | xsel -i -b