Skip to content

Instantly share code, notes, and snippets.

View ChrisVilches's full-sized avatar

Chris Vilches ChrisVilches

View GitHub Profile
@ChrisVilches
ChrisVilches / c++
Last active April 25, 2022 09:37
C++ Runner
#!/bin/bash
# A bash utility for quickly running a simple C++ file using:
# c++ my_file.cpp
#
# Features:
# * stderr output becomes red (use std::cerr or fprintf(stderr, ...) to debug).
# * Caches the compiled file based on the code content (if the file doesn't change,
# it will run the same pre-compiled binary).
#
@ChrisVilches
ChrisVilches / hide_name_terminal.sh
Last active November 2, 2021 10:35
Remove name in terminal (i.e. leave only the $)
# Note: Execute directly on the terminal (it has no effect if it's inside a bash script)
export PS1="\$ "
@ChrisVilches
ChrisVilches / search-text.sh
Created December 25, 2021 19:16
Search text (inside files) in directory recursively in Linux
search-text(){
if [ ! -z "$1" ]
then
grep --exclude-dir={.git,tmp,log,node_modules,vendor} -r "$1" .
fi
}
# Example usage:
# search-text "with a suffix tree"
@ChrisVilches
ChrisVilches / vscode_fix_rubocop.md
Last active January 21, 2022 12:53
Fix VSCode RuboCop error

RuboCop (VSCode) bundle not found error

Fix the error bundle not found error or something similar. This happens when the rubocop VSCode extension is set to execute using bundle exec.

Open this file:

~/.vscode/extensions/misogi.ruby-rubocop-0.8.6/out/src/configuration.js
@ChrisVilches
ChrisVilches / ostream_istream_overload.cpp
Created May 31, 2022 20:33
How to print and read custom data in C++.
#include <bits/stdc++.h>
using namespace std;
struct Point {
int x, y;
};
ostream& operator<<(ostream& os, const Point& p) {
return os << "(" << p.x << ", " << p.y << ")";
}
@ChrisVilches
ChrisVilches / kindle_highlight_clean.py
Last active July 6, 2022 16:10
Clean HTML files generated by the Windows Kindle app when exporting highlights.
import sys
import re
# TODO: The main code should be inside a __main__, I think.
FILE = sys.argv[1]
file = open(FILE, "r", encoding="utf8")
data = file.read()
file.close()