Skip to content

Instantly share code, notes, and snippets.

View loopmode's full-sized avatar

Jovica Aleksic loopmode

  • ETECTURE
  • Fulda, Frankfurt
View GitHub Profile
@loopmode
loopmode / replace-audio.sh
Created July 11, 2020 08:24
replace audio in video files without re-encoding
#!/bin/sh
# replace audio in a video file without re-encoding the video
# based on https://superuser.com/a/1096239
# CLI usage: ./replace-audio.sh video.mp4 audio.mp4 output.mp4
# interactive usage: run script, enter filenames when asked, confirm with ENTER
function run() {
@loopmode
loopmode / fullscreen.js
Last active November 8, 2022 08:19
cross-browser fullscreen utils
// see https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API
/** @private */
const ERR_NO_API = 'The Fullscreen API not supported on this device';
export function requestFullscreen(elem) {
if (elem.requestFullscreen) {
elem.requestFullscreen();
} else if (elem.msRequestFullscreen) {
elem.msRequestFullscreen();
@loopmode
loopmode / botpress-query-by-json.js
Last active November 8, 2022 08:20
botpress query by json field (knex, sqllite vs postgres)
let query = bp.database('web_messages')
if (bp.database.isLite) {
query
.where('attr_fookey', 'like', `%foo_value%`)
.select(bp.database.raw(`web_messages.id, json_extract(web_messages.payload, '$.foo') as attr_fookey`))
} else {
query.whereRaw(`web_messages.payload ->>'foo' like '%foo_value%'`)
query.select(this.knex.raw(`web_messages.id`))
}
@loopmode
loopmode / find_packages.sh
Last active May 25, 2020 12:35
Bash script to find folder paths of installed node packages by name
#!/bin/sh
# finds node packages installed in a given directory
# - takes a directory path and one or more package names
# - finds all package.json files in the directory that have a matching name
# - returns the paths to the package folders
#
# Usage example:
#
# $ find_installed_packages.sh ./project/.cache/ foo foo-utils
@loopmode
loopmode / propellerhead-reason-junctions.bat
Last active November 8, 2022 08:21
Moving Propellerhead Reason to another disk to free space
# Reason 11 eats up lots of space for content files
# An easy solution is to move the contents to another drive and create symlinks to the new locations
# --- These steps/commands are for Windows ---
mkdir D:\Reason\_symlinks\AppData
mkdir D:\Reason\_symlinks\ProgramData
mkdir D:\Reason\_symlinks\UserData
mv "%USERPROFILE%\AppData\Roaming\Propellerhead Software" "D:\Reason\_symlinks\AppData"
mv "%USERPROFILE%\Music\Propellerhead Content" "D:\Reason\_symlinks\UserData"
@loopmode
loopmode / App.tsx
Created April 15, 2020 10:06
use-electron-context-menu
/**
* example of making inspector menu item available on everything from the "root" component
*/
import { hot } from 'react-hot-loader/root';
import React from 'react';
import useContextMenu from './hooks/use-context-menu';
const App: React.FC = React.memo(() => {
@loopmode
loopmode / machine.js
Last active March 16, 2020 07:35
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@loopmode
loopmode / nuke.bashrc
Last active September 28, 2023 09:11
nuke: getting rid of stuff
# just delete all node_modules recursively without reinstalling
alias delete-node-modules='find . -name node_modules -type d -exec rm -rf "{}" + '
# delete all node_modules and reinstall via npm
nuke-npm() {
if [ "$1" == "-f" ]; then
rm -f package-lock.json
fi
find . -name node_modules -type d -exec rm -rf "{}" +
npm install
@loopmode
loopmode / use-context-menu.ts
Created October 19, 2019 08:21
Hook for displaying electron context menu for an element
import {
remote,
MenuItemConstructorOptions,
ContextMenuParams,
Event as ElectronEvent
} from 'electron';
import contextMenu from 'electron-context-menu';
import React from 'react';
@loopmode
loopmode / _variate.scss
Last active September 26, 2019 23:37
Sass mixin for creating margin and padding utils
// ------------------------------------------------------------------------
//
// @mixin variate($style, $sizes, $variations, $withUnits)
//
// creates a list of shortcut utitlity classes, with variations for each side
//
// Usage:
//
// variate(margin);
// variate(margin, (0em, 6em, 12em, 24em, 48em));