Skip to content

Instantly share code, notes, and snippets.

View lacostenycoder's full-sized avatar
👓
Tooling not fooling

Lance Jordan lacostenycoder

👓
Tooling not fooling
View GitHub Profile
@lacostenycoder
lacostenycoder / README.md
Last active November 2, 2023 17:18
Ruby script to toggle night-mode hack on Slack Desktop app - Mac only, maybe linux

- IMPORTANT

For security, since this script injects CSS via AJAX, first fork the main slack night mode repo. The reason is explained here

UPDATE: The code has been modified to download the remote css to a local file and use ruby sass compiler to verify there is no malicious code in the remote css. This will error if the code has been modified to include anything malicious (i.e. script or img tags etc.) It's also been refactored to use the local file inside the js injection, it makes sure it's safe first in the very unlikely event the local file somehow differs from the remote css. The chances of this happening are remote, but this should suffice for safety.

Installation

  • save this script wherever you keep your ruby scripts for example ~/lacostenycoder/scripts/ruby/
  • change the URL in the remote_repo variable in ruby script to use YOUR repo. The rawgit.com file is crea
@lacostenycoder
lacostenycoder / current_chrome_theme.rb
Last active May 9, 2023 03:42
Find your current Google Chrome Theme on the Web store (Mac only)
#!/usr/bin/env ruby
username = `whoami`.strip
filename = "/Users/#{username}/Library/Application\ Support/Google/Chrome/Default/Preferences"
data = File.read filename
string = data.split("theme")[1]
sha = string.split(/\W/)[7]
chrome_store_url = "https://chrome.google.com/webstore/detail/#{sha}"
puts chrome_store_url
`open #{chrome_store_url}`
@lacostenycoder
lacostenycoder / toggle_dock.rb
Created December 13, 2022 19:32
Toggle showing or hiding MacOS Dock
#!/usr/bin/ruby
# idea from https://gist.github.com/mattitanskane/43eb9a4b59f16ce46d2a6dbf6c02b87d
if ['-h','--hide'].any?{|h| h == ARGV[0]}
# Hide Dock
shell = <<~BASH
defaults write com.apple.dock autohide -bool true && killall Dock
defaults write com.apple.dock autohide-delay -float 1000 && killall Dock
defaults write com.apple.dock no-bouncing -bool TRUE && killall Dock
BASH
good = 'hidden'
@lacostenycoder
lacostenycoder / suppress_ruby_output.rb
Created April 22, 2022 01:34 — forked from moertel/suppress_ruby_output.rb
Temporarily suppress STDOUT and STDERR (ruby)
# Temporarily redirects STDOUT and STDERR to /dev/null
# but does print exceptions should there occur any.
# Call as:
# suppress_output { puts 'never printed' }
#
def suppress_output
original_stderr = $stderr.clone
original_stdout = $stdout.clone
$stderr.reopen(File.new('/dev/null', 'w'))
$stdout.reopen(File.new('/dev/null', 'w'))
@lacostenycoder
lacostenycoder / screen-brightness
Created December 24, 2021 09:53 — forked from lagerone/screen-brightness
A script for adjusting screen brightness in Dell laptops with OLED screens in Ubuntu. It requires xrandr to be installed.
#!/usr/bin/python3
import logging
import os
import subprocess
import sys
from typing import Literal
logging.basicConfig(level=logging.DEBUG)
@lacostenycoder
lacostenycoder / find_use_env_vars.rb
Created July 29, 2019 14:56
Find used and unused environment variables in .env file
#!/usr/bin/env ruby
#Run this in the root of your local github repo to find used env vars located in .env file
vars = File.readlines('.env')
keys = vars.map{|e| e[/^\w+/]}.compact.sort
used_keys = keys.select{|k| !`git grep #{k}`.empty? rescue nil}
puts "THESE ARE USED IN THE PROJECT\n\n"
puts used_keys
puts "\nThese env vars NOT used in codebase\n\n"
puts keys - used_keys
@lacostenycoder
lacostenycoder / install-open.sh
Last active October 21, 2021 14:28 — forked from ozanmuyes/install-open.sh
Mac OSX 'open' equivalent for Debian for zsh
#!/bin/bash
# echoes '#!/bin/bash xdg-open "$1" &> $HOME/.xdg-open-error &' to /usr/sbin/open
echo -e "\043\041/bin/bash\n\nxdg-open \042\044\061\042 &> $HOME/.xdg-open-error &" > ozanmuyes-open
sudo mv ozanmuyes-open /usr/sbin/open
sudo chmod +x /usr/sbin/open
echo -e "\n# Mac OSX \047open\047 equivalent for Debian\nalias 'open'='/usr/sbin/open'" >> $HOME/.zshrc
. $HOME/.zshrc
@lacostenycoder
lacostenycoder / .functions
Last active March 29, 2021 22:05
helpful functions
# Show listing ports in MacOS from https://stackoverflow.com/a/30029855/3625433
listening_ports() {
if [ $# -eq 0 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P
elif [ $# -eq 1 ]; then
sudo lsof -iTCP -sTCP:LISTEN -n -P | grep -i --color $1
else
echo "Usage: listening [pattern]"
fi
@lacostenycoder
lacostenycoder / README.md
Last active February 14, 2021 14:59 — forked from zaydek-old/bookmark.min.js
A *simple* CSS debugger. To use, bookmark "Debug CSS" at https://zaydek.github.io/debug.css. Learn more here https://medium.freecodecamp.org/88529aa5a6a3 and https://youtu.be/2QdzahteCCs?t=1m25s (starts at 1:25)

In newer versions of chrome you may not be able to just drag the code to your quick shortcuts. As a workaround you can just do:

  1. Copy the raw javascript in bookmark.min.js to your clipboard.
  2. right-click on the the bookmarks bar and add select add page
  3. for the name type DebugCSS
  4. for page type javascript:/ then paste the js you copied in step 1
  5. click save.
  6. Do a happy dance, your done! Happy Dance
@lacostenycoder
lacostenycoder / slack_cleaner.sh
Last active January 8, 2021 14:04
slack_cleaner.sh
#!/bin/bash
TOKEN="paste slack token here"
bdate=$(date -d "$date -30 days" +"%Y%m%d")
slack-cleaner --token $TOKEN --message --channel dev --before $bdate --bot --perform --as_user --rate 0.2 --quiet
slack-cleaner --token $TOKEN --message --channel ci-builds --before $bdate --bot --perform --as_user --rate 0.2 --quiet
slack-cleaner --token $TOKEN --message --channel sentry --before $bdate --bot --perform --as_user --rate 0.2 --quiet
slack-cleaner --token $TOKEN --message --channel server_status --before $bdate --bot --perform --as_user --rate 0.2 --quiet