Skip to content

Instantly share code, notes, and snippets.

#!/bin/bash
set -eu
_UID=$(id -u)
GID=$(id -g)
# give lxd permission to map your user/group id through
grep root:$_UID:1 /etc/subuid -qs || sudo usermod --add-subuids ${_UID}-${_UID} --add-subgids ${GID}-${GID} root
# set up a separate key to make sure we can log in automatically via ssh
# with $HOME mounted
// ==UserScript==
// @name Youtube Playlist Cleanser
// @version 2.1.0
// @description Removes watched videos from playlist either by %watched or all
// @author js6pak
// @include http*://*.youtube.com/*
// @include http*://youtube.com/*
// @run-at document-idle
// @homepageURL https://gist.github.com/js6pak/33bdefdefac09c387f55d08c5b9526fa
// @downloadURL https://gist.github.com/js6pak/33bdefdefac09c387f55d08c5b9526fa/raw/youtube-playlist-cleanser.user.js
@ismet55555
ismet55555 / tmux-install-upgrade.sh
Last active April 26, 2024 10:53
Install or Upgrade tmux
#!/bin/bash
set -o errexit
#################################################################
# Install/Upgrade tmux
#################################################################
#
# This script installs or updates tmux onto a Debian (ie Ubuntu),
# CentOS/RHEL, or MacOS platform. This script is based on:
@edonosotti
edonosotti / chatbase-howto.js
Last active April 26, 2024 10:51
How to integrate chatbase in a chatbot project.
# Integrating Chatbase in your chatbot - Node.JS version
#
# The purpose of this code is to show how to integrate the Chatbase service in any chatbot.
#
# See my article on Chatbots Magazine for details:
# https://chatbotsmagazine.com/advanced-chatbot-analytics-and-sentiment-analysis-part-1-17a8e674d7e1
#
# License: MIT (https://opensource.org/licenses/MIT) (C) Edoardo Nosotti, 2017
const chatbase = require('@google/chatbase');
@hadware
hadware / bytes_to_wav.py
Last active April 26, 2024 10:50
Convert wav in bytes for to numpy ndarray, then back to bytes
from scipy.io.wavfile import read, write
import io
## This may look a bit intricate/useless, considering the fact that scipy's read() and write() function already return a
## numpy ndarray, but the BytesIO "hack" may be useful in case you get the wav not through a file, but trough some websocket or
## HTTP Post request. This should obviously work with any other sound format, as long as you have the proper decoding function
with open("input_wav.wav", "rb") as wavfile:
input_wav = wavfile.read()

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
[
{
"id": "c154697af277016d452b1bc815f5d1787fa2d694",
"thumbnail": "https://media.guim.co.uk/9fd1d41b23d3831ee8b918930cdd1bdc0c8045e1/0_0_2560_1536/500.jpg",
"title": "There is a wounded pigeon in the garden. Should I intervene?",
"url": "https://www.theguardian.com/lifeandstyle/2022/oct/15/there-is-a-wounded-pigeon-in-the-garden-should-i-intervene",
"words": "795",
"section": "Life and style",
"date": "2022-10-15T05:00:58Z",
"image": "https://media.guim.co.uk/9fd1d41b23d3831ee8b918930cdd1bdc0c8045e1/0_0_2560_1536/1000.jpg",
@stephenhandley
stephenhandley / exportQueue.js
Last active April 26, 2024 10:46
Rdio queue to json
var queue = [];
var $albums = $('.QueueList .Album');
for (var i = 0; i < $albums.length; i++) {
var $album = $($albums[i]);
var $title = $album.find('.album_title');
var $artist = $album.find('.artist_title');
queue.push({
title : $title.text(),
href : $title.attr('href'),
artist : $artist.text()
@oclockvn
oclockvn / dictionary.js
Created January 25, 2018 20:54
find a word contains letter
var source = ["the",
"of",
"and",
"to",
"a",
"in",
"for",
"is",
"on",
"that",