Skip to content

Instantly share code, notes, and snippets.

@yardenlaif
yardenlaif / injection.md
Created August 30, 2023 16:17
Injecting Javascript in Chrome Extension
  1. Create javascript file with code to inject.
  2. Add to accessible resources in manifest.json:
  "web_accessible_resources": [
    {
      "resources": [<javascript file path>],
      "matches": [...]
    }
  ],
package main
import (
"crypto/sha1"
"fmt"
"sync"
"testing"
)
var cases = []struct {
@yardenlaif
yardenlaif / bluetooth_connect.sh
Last active April 20, 2023 09:20
Toggle connection to bluetooth device
#!/bin/bash
deviceID=$(bluetoothctl devices 2>&1 | grep $device | cut -d" " -f2)
command=$(bluetoothctl info $deviceID | grep Connected | grep -q no && echo "connect" || echo "disconnect")
bluetoothctl $command $deviceID
@yardenlaif
yardenlaif / repo_auth.sh
Created December 24, 2022 11:34
Authenticate with different user for specific repo
git clone https://$GHP_KEY@github.com/$REPO_OWNER/$REPO
# -- OR --
git remote -set-url originl https://$GHP_KEY@github.com/$REPO_OWNER/$REPO
# Set user
git config user.name $NAME
git config user.email $EMAIL
@yardenlaif
yardenlaif / install_notion.sh
Last active December 13, 2022 12:48
Script to install notion website as a desktop app on linux
#! /bin/sh
# Prerequisites:
# nativefier:
# sudo npm install -g nativefier
nativefier --name Notion --single-instance notion.so
cd Notion-linux-x64/
chmod +x Notion
@yardenlaif
yardenlaif / mini-surround.lua
Last active December 24, 2022 13:35
My implementation for surround in visual mode.
-- Surround
function Surround_with(start_surround, end_surround)
local vstart = vim.fn.getpos("'<")
local vend = vim.fn.getpos("'>")
local start_column = vstart[3] - 1
local start_line = vstart[2]
local end_column = vend[3] - 1
local end_line = vend[2]
-- Skip whitespaces at the start of lines