Skip to content

Instantly share code, notes, and snippets.

View Cretezy's full-sized avatar

Cretezy

View GitHub Profile
@Cretezy
Cretezy / signing.js
Last active February 21, 2019 06:14
Node signing helper
import crypto from "crypto";
const separator = ":";
export function sign(content, secret) {
const signature = generateSignature(content, secret);
return {
signature,
content,
signedContent: join(content, signature)
@Cretezy
Cretezy / FirestoreBatcher.js
Last active June 3, 2018 05:36
Helper for batching operations in Firestore
export class FirestoreBatcher {
batches = [];
index = 0;
constructor(firestore) {
this.firestore = firestore;
}
getNext() {
if (this.index++ % 500 === 0) {
@Cretezy
Cretezy / Tools.md
Created May 30, 2018 15:24
Tools I use

Better react-hotkeys HOC

Usage:

withHotKeys({ new: "alt+n" }, { new: props => event => console.log(props, event) })(...)

Useful to use with recompose.

Keybase proof

I hereby claim:

  • I am cretezy on github.
  • I am cretezy (https://keybase.io/cretezy) on keybase.
  • I have a public key ASAyf6-mYb28_SnKYGRlnTBdDFIMpI4hgGlFXV21WC93Rgo

To claim this, I am signing this object:

@Cretezy
Cretezy / systemd-user-fix.md
Created May 21, 2017 18:38
systemd user "Failed to connect to bus: No such file or directory"

Simply add this snippet...

export XDG_RUNTIME_DIR="/run/user/$UID"
export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus"

...to .bashrc or .zshrc or any file ran on login.

@Cretezy
Cretezy / Shout.md
Last active October 13, 2021 01:34
ShoutPlay.js

Simple script to stream a file from Node.js to Icecast (or any libshout compatible server) using nodeshout.

Usage

const shout = ... // Shout instance
const songPath = 'song.ogg';
const playing = play(shout, songPath);
playing.on("finish", ()=>{
  // Do something (e.g.: play next song)
});
@Cretezy
Cretezy / Commands.md
Last active April 17, 2021 15:58
Forgetful Linux Commands

Mostly made for Debian/Ubuntu. Might work with other distributions/setup, be careful.

Spotify scaling

Make Spotify DPI factor of 2.1 (override)

cp /usr/share/applications/spotify.desktop ~/.local/share/applications/
sed -i 's/Exec=spotify %U/Exec=spotify --force-device-scale-factor=2.1 %U/g' ~/.local/share/applications/spotify.desktop
@Cretezy
Cretezy / 420MazeIt.cs
Last active June 25, 2020 01:03
Unity Basic Prim Maze Generator
using UnityEngine;
using System.Collections;
public class Mazer : MonoBehaviour
{
ArrayList walls = new ArrayList ();
ArrayList cells = new ArrayList ();
void MazeIt ()
{
@Cretezy
Cretezy / Tmux cheatsheet.md
Last active July 26, 2016 17:56
All you need to know for tmux

Charles' simple tmux guide

tmux is a better and more modern screen alternative. When refering to PREFIX, it usually is CTRL + B. This can be edited in the tmux config.

Basic Commands

Create session tmux new -s <name>

Attact to session tmux a -t <name>