Skip to content

Instantly share code, notes, and snippets.

View 2KAbhishek's full-sized avatar
🤩
Fixing Tpyos!

Abhishek Keshri 2KAbhishek

🤩
Fixing Tpyos!
View GitHub Profile

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@2KAbhishek
2KAbhishek / change_ext.sh
Created October 26, 2020 08:53
Batch rename extensions of files
#!/bin/bash
# Rename all *.txt to *.text
for f in *.txt; do
mv -- "$f" "${f%.txt}.text"
done
@2KAbhishek
2KAbhishek / fix_ssh.sh
Created October 26, 2020 08:35
Fix SSH key file permissions
#!/bin/bash
chmod 0644 ~/.ssh/id_rsa.pub
chmod 0600 ~/.ssh/id_rsa
@2KAbhishek
2KAbhishek / mirrorlist.sh
Created October 21, 2020 13:25
Generate fastest mirrors for Arch linux
#!/bin/bash
# Install reflector
sudo pacman -S reflector
# Update mirrorlist
reflector | sudo tee /etc/pacman.d/mirrorlist
@2KAbhishek
2KAbhishek / time_space.py
Created June 19, 2020 23:05
Time and Space used in Python
import time, sys
start = time.clock()
for x in range(1000):
pass
end = time.clock()
@2KAbhishek
2KAbhishek / sync_upstream.md
Last active June 7, 2020 03:24
Sync forked repo with upstream after merge

Clone your fork and cd into it

git clone https://github.com/yourname/repo.git
cd yourname/repo

Add upstream remote

@2KAbhishek
2KAbhishek / ffmeg.sh
Created April 6, 2020 02:41
Trim videos instantly
# With start time and duration
ffmpeg -ss $START -i $INFILE -c copy -map 0 -t $DURATION $OUTFILE
# With start time and end time
ffmpeg -ss $START -i $INFILE -c copy -map 0 -to $END $OUTFILE
@2KAbhishek
2KAbhishek / command_substitution.sh
Last active January 22, 2020 16:21
Replace part of last command
# Quick Substitution
^string1^string2
# Global Substitution
!!:gs/string1/string2
@2KAbhishek
2KAbhishek / Blank.md
Last active January 1, 2020 23:41
target="_blank" vulnerability

Example attack scenario

Create a fake "viral" page with cute cat pictures, jokes or whatever, get it shared on Facebook (which is known for opening links via _blank). Create a "phishing" website at https://fakewebsite/facebook.com/page.html for example Put this code on your "viral" page window.opener.location = 'https://fakewebsite/facebook.com/page.html'; which redirects the Facebook tab to your phishing page, asking the user to re-enter her Facebook password.

How to fix

Add this to your outgoing links.

@2KAbhishek
2KAbhishek / error_report.js
Last active January 1, 2020 22:57
Minimalist version of sentry
window.onerror = function(msg, _path, line, column, error) {
fetch('/errors', {
error: error ? error.stack : '',
column: column,
line: line,
msg: msg
})
return false
}