Skip to content

Instantly share code, notes, and snippets.

View midwire's full-sized avatar
🏠
Working from home

Chris Blackburn midwire

🏠
Working from home
View GitHub Profile
@midwire
midwire / jquery.js
Created November 23, 2022 19:23
[Determine jQuery version in the browser]
// Paste this into the console
if (typeof jQuery != 'undefined') {
// jQuery is loaded => print the version
alert(jQuery.fn.jquery);
}
@midwire
midwire / flash_all.sh
Last active November 17, 2022 17:41 — forked from willwm/flash_all.sh
[Flash complete stock ROM for OnePlus 8T] fastboot: Flash All Partitions (OnePlus 8T)
fastboot flash product product.img
fastboot flash abl abl.img
fastboot flash aop aop.img
fastboot flash bluetooth bluetooth.img
fastboot flash boot boot.img
fastboot flash cmnlib cmnlib.img
fastboot flash cmnlib64 cmnlib64.img
fastboot flash devcfg devcfg.img
fastboot flash dsp dsp.img
fastboot flash dtbo dtbo.img
@midwire
midwire / remove_residual_config.sh
Created September 23, 2022 15:25
[Remove all residual configs in Ubuntu] One-liner to remov all residual config packages in Ubuntu #ubuntu #apt
# Remove all the packages with residual configuration.
# http://stuzhao.blogspot.com/2012/07/removing-all-residual-config-packages.html
sudo apt-get remove --purge `dpkg -l | grep '^rc' | awk '{print $2}'`
@midwire
midwire / handlers.rb
Created September 16, 2022 19:31
[Rails renderer formats and handlers] list of rendering formats and handlers for Rails #ruby #rails
# You can pass these to `render`
formats: [
:atom,
:bmp,
:css,
:csv,
:doc,
:doc,
:docx,
:docx,
@midwire
midwire / git-branch-sync.sh
Created August 26, 2022 13:40
[Git - sync local branches with remote] Remove local branches if they don't exist on the remote #git
# Use git branch -D to remove branches even if they are not fully merged
git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
@midwire
midwire / file_exists.rb
Created August 23, 2022 21:57
[Capistrano - detect if a remote file exists] #ruby
def file_exists?(path)
capture(:ls, path)
true
rescue SSHKit::Command::Failed
false
end
def state_page
stage = fetch(:stage)
parts = stage.to_s.split('_')
@midwire
midwire / git commands.md
Last active August 23, 2022 17:07 — forked from scootcho/git commands.md
[Common Git Commands] #git #shell

initialize git depository in the current directory

git init .

display the git remote/origin

cat .git/config
@midwire
midwire / splat.rb
Created August 19, 2022 18:08
[Ruby Splat and Double-Splat] #ruby
def foo(a, *b, **c)
[a, b, c]
end
> foo 10
=> [10, [], {}]
> foo 10, 20, 30
=> [10, [20, 30], {}]
> foo 10, 20, 30, d: 40, e: 50
=> [10, [20, 30], {:d=>40, :e=>50}]
@midwire
midwire / args.exp
Created August 17, 2022 15:09
[Use arguments in Expect] #expect #command
set username [lindex $argv 0];
set password [lindex $argv 1];
send_user "$username $password"
@midwire
midwire / git-remove.sh
Last active August 15, 2022 20:22
[Git remove file from history] #git #shell
# Example file is `.env`
# Remove the file from the disk
# Add the file path to .gitignore
echo ".env" >> .gitignore
# Permanently remove it from the git history
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch .env" HEAD
# Force push
git push --force