Skip to content

Instantly share code, notes, and snippets.

View CodeByAidan's full-sized avatar
💻
i love HPC/DL

aidan CodeByAidan

💻
i love HPC/DL
View GitHub Profile
@CodeByAidan
CodeByAidan / demo.gif
Last active June 2, 2024 01:36
File path not-clickable workaround in Python! Say you have a file path that has a space in a folder, womp womp! Can't click the entire path, but using file:/// with a .as_uri()[8:], it fixes it!
demo.gif
@CodeByAidan
CodeByAidan / valgrind-helper.sh
Last active June 2, 2024 01:38
A nice shell script I made for Debian that runs Valgrind, with customizable log file, pretty easy! Try `gcc -o temp -std=c2x -Wall -Og temp.c && ./valgrind-helper.sh temp`
#!/bin/bash
# ./valgrind-helper.sh my-log.txt my-program
# ./valgrind-helper.sh my-program
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
NC='\033[0m' # No Color
SEPARATOR="${YELLOW}========================================${NC}"
Introduction
Navigation
Expressions
Text formatting
Notes and comments
Conditionals (if)
Return (return)
Multiple outcome decisions (switch/match)
Traditional switch conditionals (switch)
Goto and jump loops (goto/loop)
#include <set>
#include <utility>
#include <vector>
#include <iostream>
using vpii = std::vector<std::pair<int, int>>;
std::vector<std::pair<int, int>, std::allocator<std::pair<int, int>>> twos_difference(const std::vector<int, std::allocator<int>> &v)
{
std::set<int, std::less<int>, std::allocator<int>> s = std::set<int, std::less<int>, std::allocator<int>>(v.begin(), v.end());
#include <iostream>
#include <array>
#include <utility>
#include <vector>
using ll = long long;
using pll = std::pair<ll, ll>;
const int maxN = 3005;
struct Line {
@CodeByAidan
CodeByAidan / main.cpp
Created May 28, 2024 20:03
example of a C++ class with a predecessor (base class), a main function, and usage of the numeric library’s std::accumulate function to sum an array of numbers (highly optimized, sorry)
#include <iostream>
#include <numeric>
#include <vector>
class Predecessor {
protected:
int value;
public:
inline Predecessor(int val) : value{val} {}
@CodeByAidan
CodeByAidan / Powershell-Version-Finder.ps1
Created May 28, 2024 14:22
Finds the version of PowerShell in a simple one-liner.
$PSVersionTable.PSVersion.ToString() # "5.1"
# You can also just use $PSVersionTable.PSVersion or simply $PSVersionTable
@CodeByAidan
CodeByAidan / Public-IP-Address-Finder.ps1
Created May 27, 2024 22:33
One-Liner Find Public IP Address via Powershell!
Invoke-RestMethod -Uri 'http://ipinfo.io/ip'
@CodeByAidan
CodeByAidan / demo1.ec
Last active May 24, 2024 15:07
`CLOSE` demo using Informix ESQL/C
#include <stdio.h>
EXEC SQL define FNAME_LEN 15;
EXEC SQL define LNAME_LEN 15;
int main() {
EXEC SQL BEGIN DECLARE SECTION;
char fname[FNAME_LEN + 1];
char lname[LNAME_LEN + 1];
EXEC SQL END DECLARE SECTION;
@CodeByAidan
CodeByAidan / Fast-Range.py
Last active May 24, 2024 00:14
My personal take on the classic range() (or xrange()) function in Python3
class Range:
def __init__(self, start, stop=None, step=1, /):
if stop is None:
start, stop = 0, start
self.start, self.stop, self.step = start, stop, step
if step < 0:
lo, hi, step = stop, start, -step
else:
lo, hi = start, stop
self.length = 0 if lo > hi else ((hi - lo - 1) // step) + 1