Skip to content

Instantly share code, notes, and snippets.

View squio's full-sized avatar

Johannes la Poutre squio

View GitHub Profile
@squio
squio / howto-git-cherry-pick-for-release.md
Last active October 23, 2024 07:24
HOWTO git: cherry-pick from merged commits

If you need to cherry pick merge commits

First switch to the branch you merged into (likely develop), then

git log --since=2024-10-01 --reverse --merges \
  --author="$(git config --get user.name)" >merges.txt

Now switch to the target branch you want to merge into (maybe release-20240501 or so)

@squio
squio / watchman-reset.sh
Created March 5, 2024 15:18
Reset watchman
#!/bin/sh
# for issue https://stackoverflow.com/a/71779949/885397
watchman watch-del-all
watchman shutdown-server
@squio
squio / audio2mp3.sh
Created April 16, 2023 10:15
convert any file containing an audio stream to MP3
#!/bin/sh
# convert any file containing an audio stream to MP3
while [ -s "$1" ]
do
FILE="$1"
BASE=${FILE%.*}
ffmpeg -i "$FILE" -ab 128k -ac 2 -codec:a libmp3lame "${BASE}.mp3"
shift
@squio
squio / tweetdelete.js
Last active May 9, 2023 16:05
Delete all your tweets and retweets from your browser's debug console
// Delete all your tweets and retweets (based on https://stackoverflow.com/a/74878105/885397)
// 1. Open Inspector in your browser
// 2. Switch to the Console tab
// 3. Copy and paste the code below after the >> prompt
// 4. leave your browser tab open, sit back and enjoy seeing all your tweets going one by one ;-)
(async () => {
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
@squio
squio / rem_to_pixels.ts
Created April 19, 2022 07:59
Convert size in rem to pixel size based on computedStyle
export function convertRemToPixels(rem: number) {
if (document?.documentElement) {
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
} else {
console.warn('No "document" context, unable to calculate effective pixel size');
return rem;
}
}
@squio
squio / ipv4toint.js
Created March 25, 2022 14:32
Translate an IPv4 address into an integer
const ip='192.168.1.123';
const decimal_ip = ip.split('.').reverse().map((e,i) => parseInt(e)*(2**(8*i))).reduce((sum, n) => sum + n);
// decimal_ip = 3232235899
@squio
squio / submit_line.html.md
Last active April 7, 2022 14:11
Override Django Admin submit_line.html

Enhancing https://stackoverflow.com/posts/65938495/

It is also possible to override/extend the innermost {% block submit-row %} like so:

{% extends 'admin/submit_line.html' %}
{% load i18n admin_urls %}

{% block submit-row %}
 {% if extra_button_allowed %}
@squio
squio / RoundRobinArray.js
Last active November 26, 2021 11:43
Round robin array iterator in Javascript
/**
* Round robin array iterator
* @param {string | any[]} arr
*/
function* RoundRobinArray(arr) {
let idx = 0;
for (;;) {
yield arr[idx];
idx++;
if (idx >= arr.length) {
@squio
squio / settings.py
Created October 25, 2021 15:43
Add 2fa authentication to dj_rest_auth login
# in settings.py
REST_AUTH_SERIALIZERS = {
# override dj_rest_auth serializer for 2fa
'LOGIN_SERIALIZER': 'my_app.serializers.user.LoginSerializer'
}
@squio
squio / app-resume.service.spec.ts
Last active April 5, 2022 10:35
Ionic App Resume
import { TestBed } from '@angular/core/testing';
import { AppResumeService } from './app-resume.service';
describe('AppResumeService', () => {
let service: AppResumeService;
beforeEach(() => {
TestBed.configureTestingModule({});
service = TestBed.inject(AppResumeService);