Skip to content

Instantly share code, notes, and snippets.

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

Sonu Lohani sonulohani

🏠
Working from home
View GitHub Profile
@sonulohani
sonulohani / BraceParser.cpp
Created February 8, 2020 14:30
C++: Parses curly braces values
#include <iostream>
#include <regex>
#include <string>
#include <vector>
#include <sstream>
#include <map>
std::vector<std::string> split(const std::string& s, char delimiter)
{
std::vector<std::string> tokens;
@sonulohani
sonulohani / GoogleDorking.md
Created May 2, 2020 12:54 — forked from sundowndev/GoogleDorking.md
Google dork cheatsheet

Google dork cheatsheet

Search filters

Filter Description Example
allintext Searches for occurrences of all the keywords given. allintext:"keyword"
intext Searches for the occurrences of keywords all at once or one at a time. intext:"keyword"
inurl Searches for a URL matching one of the keywords. inurl:"keyword"
allinurl Searches for a URL matching all the keywords in the query. allinurl:"keyword"
intitle Searches for occurrences of keywords in title all or one. intitle:"keyword"
@sonulohani
sonulohani / 20-intel.conf
Last active May 16, 2020 13:16
Screen recording fix for intel gpu
Section "Device"
Identifier "Intel Graphics"
Driver "intel"
Option "DRI" "2"
Option "TearFree" "true"
Option "Backlight" "Intel_backlight"
EndSection
@sonulohani
sonulohani / readme.md
Created August 3, 2020 14:40 — forked from kiasaki/readme.md
ubuntu: vboxdrv module signing for secureboot to load it

Since kernel version 4.4.0-20, it was enforced that unsigned kernel modules will not be allowed to run with Secure Boot enabled. Because you want to keep Secure Boot, then the next logical step is to sign those modules.

So let's try it.

Create signing keys

openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Descriptive name/"
@sonulohani
sonulohani / AG tutorial.md
Last active February 22, 2023 09:22
AG tool cheatsheet
  • Find files containing "foo", and print the line matches in context: ag foo
  • Find files containing "foo" in a specific directory: ag foo path/to/directory
  • Find files containing "foo", but only list the filenames: ag -l foo
  • Find files containing "FOO" case-insensitively, and print only the match, rather than the whole line: ag -i -o FOO
  • Find "foo" in files with a name matching "bar": ag foo -G bar
@sonulohani
sonulohani / remove_c_style_comments.py
Created August 19, 2020 14:19 — forked from ChunMinChang/remove_c_style_comments.py
Python: Remove C/C++ style comments #parser
#!/usr/bin/python
import re
import sys
def removeComments(text):
""" remove c-style comments.
text: blob of text with comments (can include newlines)
returns: text with comments removed
"""
pattern = r"""
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\] \[\033[01;31m\]\$(git_branch)\[\033[00m\]\$ "

Fix stuck at dell logo boot

sudo pacman -Syyu haveged
sudo systemctl enable haveged --now

Swappiness

First, check the default swappiness value. Run in a terminal:

cat /proc/sys/vm/swappiness

@sonulohani
sonulohani / build_info.md
Last active April 21, 2021 06:03
Ubuntu source built packages(needs after every full-upgrade)

CMake

sudo apt-get build-dep cmake-qt-gui
./configure --qt-gui

libmypaint

./autogen.sh    # Only needed when building from git.
./configure
@sonulohani
sonulohani / patch_and_apply.md
Last active April 23, 2021 05:49
How to create git patch and apply between two commits

Creating the GIT Patch

The following command creates a single .patch file that contains multiple commits.

git format-patch cc1dde0dd^..6de6d4b06 --stdout > foo.patch

You can then apply it like so:

git am foo.patch
Note: Be sure to use ^.. instead of .. if you want the first commit SHA to be included.