Skip to content

Instantly share code, notes, and snippets.

@ejke
ejke / printBill.js
Created June 8, 2023 13:00
Refactoring game - how many changes would you make?
import {readFileSync} from "fs";
const plays = JSON.parse(readFileSync("../shared/plays.json"));
const invoices = JSON.parse(readFileSync("../shared/invoices.json"));
function statement(invoice, plays) {e
let totalAmount = 0;
let volumeCredits = 0;
let result = `Statement for ${
invoice.customer
}\n`;
@ejke
ejke / .tmux.conf
Last active June 30, 2021 09:35
Ubuntu 20.04 tmux config
# --- GET tmux
# 1. $: brew install tmux
# 2. $: tmux
# 3. $: touch ~/.tmux.conf
# 4. $: tmux source-file ~/.tmux.conf # <- to attach config to that new file
# 5. Copy everything below and paste into the ~/.tmux.conf file
# --- .tmux.conf content:
# Config file for tmux shortcuts.
@ejke
ejke / squash_pushed_commits.md
Last active January 10, 2022 09:13
Rebase to squash pushed commits into single commit before merge.

Rebase to squash pushed commits into single commit before merge.

  1. Print a pretty log to deteremine number of commits
git log --pretty=format:"%h %s" HEAD~11..HEAD
  1. Rebase to squash commits together in editor
git rebase -i HEAD~11
@ejke
ejke / automate_zoom_meeting.md
Last active March 24, 2022 03:40
Let your computer open those pesky meetings at the right time for you. Never miss a meeting notification anymore.

Open regular Zoom meetings automatically

Easy way to let cron to open + join to the re-occuring meeting for you.

1. Make a bash script

Create a new file in you fave code editor. Insert following

#!/bin/bash
open zoommtg://zoom.us/j/12312312312?pwd=aBaBABABaBAbAmb1abAbABBB1ABAbAb12

Change the zoom id (12312312312) and password (aBaBABABaBAbAmb1abAbABBB1ABAbAb12) to your meeting.

@ejke
ejke / bash_profile
Last active June 14, 2021 06:50
Modify the ~/.bash_profile (mac) or ~/.bashrc (ubuntu) file to add some convenient shortcuts.
... other bash stuff
# ---------------
# Change bash prompt
# 1. find PS1 from file (line 60 or so)
# 2. swap it to just show current directory and $
PS1='\[\033[01;32m\]\W\[\033[00m\]\$ ' # for green text
PS1='\[\033[01;34m\]\W\[\033[00m\]\$ ' # for blue text
# ---------------
@ejke
ejke / double_list_comprehension.py
Created June 18, 2019 11:28
Example of double list comprehension in python3
# Example of double list comprehension in python
# example key = some_numbers-some_more_numbers-message_id
found_keys = [key for message_id in all_messageids for key in returned_keys if key.endswith(message_id)]
print(found_keys)
# Following results in same but in the long way
found_keys = []
for key in returned_keys:
for message_id in all_messageids:
@ejke
ejke / .tmux.conf
Last active November 11, 2020 15:11
tmux (terminal multiplexer) personalised config. Store the following code in file called .tmux.conf under ~/
# --- GET tmux (mac)
# 1. $: brew install tmux
# 2. $: tmux
# 3. $: touch ~/.tmux.conf
# 4. $: tmux source-file ~/.tmux.conf # <- to attach config to that new file
# 5. Copy everything below and paste into the ~/.tmux.conf file
# --- .tmux.conf content:
# Config file for tmux shortcuts.
@ejke
ejke / git_aliases.txt
Last active June 11, 2021 11:28
Git Aliases to get yourself more time.
# Put the following into your ~/.bash_profile file (Mac) or ~/.bashrc file (Ubuntu)
# Enables to use shortcuts for most common git commands.
# ----------------------
# Git Aliases
# ----------------------
alias gf='git status'
alias gb='git branch'
alias gbn='git checkout'
alias gbnb='git checkout -b'
@ejke
ejke / functions.php
Created March 7, 2018 11:25
wp connect child parent css
<?php
function use_parent_theme_stylesheet() {
// Use the parent theme's stylesheet
return get_template_directory_uri() . '/style.css';
}
function my_theme_styles() {
$themeVersion = wp_get_theme()->get('Version');
// Enqueue our style.css with our own version
@ejke
ejke / js.js
Created December 1, 2017 12:27
Math random
// whole nr either 0,1,or 2
Math.floor((Math.random() * (3-0)));
// whole nr either 1,2 or 3
Math.floor((Math.random() * (3-0) + 1));