Skip to content

Instantly share code, notes, and snippets.


Jovica Aleksic loopmode

  • Fulda, Frankfurt
View GitHub Profile
loopmode /
Created Nov 18, 2021
display gzipped size of files
# put this in your ~/.bashrc
gzipped() {
if [ -z $1 ]; then
echo "No file specified"
b=$(gzip -c $1 | wc -c)
echo "$b B"
KB=$(awk "BEGIN {printf \"%.2f\n\", $b/1024}")
echo "$KB KB"
MB=$(awk "BEGIN {printf \"%.2f\n\", $b/1024/1024}")
loopmode / MonacoSqlInput.tsx
Last active Jul 29, 2021
SQL editor with formatting, based on monaco-editor, plus material UI wrapper
View MonacoSqlInput.tsx
import React from 'react';
import Editor from '@monaco-editor/react';
import { format } from 'sql-formatter';
export type InputEvent = { target: { name: string; value: string } };
export default function MonacoSqlInput({
name = '',
height = 500,
loopmode / Highlighted.js
Created Mar 18, 2021
react highlight words
View Highlighted.js
import React from 'react';
import escapeRegExp from 'lodash.escaperegexp';
// based on
export function Highlighted({ children: text = '', highlight = '' }) {
if (!highlight.trim()) {
return <span>{text}</span>;
const regex = new RegExp(`(${escapeRegExp(highlight)})`, 'gi');
loopmode /
Created Mar 4, 2021
abs_path for bash
# realpath is not available on mac os
# this might be a useful alternative
abs_path () {
echo "$(cd $(dirname "$1");pwd)/$(basename "$1")"
echo $(abs_path .)
loopmode / example.js
Last active Feb 16, 2021
Better console.trace
View example.js
// Using console.trace in several places when debugging can be quite the PITA because it prints the entire
// stack directly to the output and makes it difficult to find and read other log messages
// this variant will print a neatly collapsed object with a "stack" property that you can manually expand when needed
console.log('>>', { trace: new Error().stack?.slice(12).split('\n') });
loopmode /
Last active Nov 11, 2020
Bookmarklet: Gitlab Secrets

gitlab secrets bookmarklets

Helper bookmarklets to display all keys and values of a gitlab secrets page in a single element. This way, you can copy them all in one go.


Why? Because otherwise, you'd have to select, copy and paste each key and value manually, which is tedious.

Not a common use case, but I needed this several times, e.g. when requested by project managers, or when you need to replicate deployments or builds on a different system or locally.

loopmode / hosts
Created Oct 6, 2020
genymotion hosts file
View hosts localhost
loopmode /
Created Jul 11, 2020
replace audio in video files without re-encoding
# replace audio in a video file without re-encoding the video
# based on
# CLI usage: ./ video.mp4 audio.mp4 output.mp4
# interactive usage: run script, enter filenames when asked, confirm with ENTER
function run() {
loopmode / fullscreen.js
Created Jul 3, 2020
cross-browse rfullscreen utils
View fullscreen.js
// see
/** @private */
const ERR_NO_API = 'The Fullscreen API not supported on this device';
export function requestFullscreen(elem) {
if (elem.requestFullscreen) {
} else if (elem.msRequestFullscreen) {
loopmode / bp-query-by-json.js
Created Jun 9, 2020
bp query by json field (knex, sqllite vs postgres)
View bp-query-by-json.js
let query = bp.database('web_messages')
if (bp.database.isLite) {
.where('attr_fookey', 'like', `%foo_value%`)
.select(bp.database.raw(`, json_extract(web_messages.payload, '$.foo') as attr_fookey`))
} else {
query.whereRaw(`web_messages.payload ->>'foo' like '%foo_value%'`)``))