Skip to content

Instantly share code, notes, and snippets.

View Septien's full-sized avatar
🤔
Loving the life!

Jose Septien Septien

🤔
Loving the life!
  • Guanajuato.
  • 04:02 (UTC -06:00)
View GitHub Profile
@Septien
Septien / vector_hash.cpp
Last active May 23, 2024 18:44
A hash function for vector<int>
// Source: https://stackoverflow.com/questions/29855908/c-unordered-set-of-vectors
struct hashFunction {
size_t operator() (const vector<int> &v) const {
hash<int> hasher;
size_t seed = 0;
for (int i : v) {
seed ^= hasher(i) + 0x9e3779b9 +
(seed << 6) + (seed >> 2);
}
return seed;
@Septien
Septien / printbinary.c
Created August 17, 2021 20:58
A set of macros to print an integer (8, 16, 32, and 64 bits) in its bit representation. See code for reference.
/*
* Print the binary representation of an integer (8, 16, 32, and 64).
* Based on the answers from William Whyte and ideasman42 at stackoverflow:
* https://stackoverflow.com/questions/111928/is-there-a-printf-converter-to-print-in-binary-format
*/
// 8-bit integer
#define BYTE_TO_BINARY_PATTERN_INT8 "%c%c%c%c%c%c%c%c"
#define BYTE_TO_BINARY_INT8(byte) \
((byte) & 0x80 ? '1' : '0'), \
((byte) & 0x40 ? '1' : '0'), \
@Septien
Septien / fileSize.sh
Created July 8, 2020 22:08
Measure the size of a binary file
https://unix.stackexchange.com/questions/336845/how-to-view-the-size-of-the-binary-files-using-linux-command
stat -c %s file.o#binary
@Septien
Septien / changeCSVDelimiter.py
Created June 24, 2020 18:18
Change the delimiter type of a csv file
"""
Change the delimiter of a csv file.
https://stackoverflow.com/questions/6630170/python-parse-csv-file-replace-commas-with-colons
"""
import csv
def changeDelimiter(inputfile, inputdelimiter, outputfile, outputdelimiter):
reader = csv.reader(open(inputfile, "r"), delimiter=inputdelimiter)
writer = csv.writer(open(outputfile, 'w'), delimiter=outputdelimiter)
writer.writerows(reader)
@Septien
Septien / plot.py
Last active August 26, 2020 16:53
Plotting data from a .csv file
"""
Plot the performance data from the ciphers.
"""
import matplotlib.pyplot as plt
import numpy as np
import csv
import pandas as pd
import sys, getopt
@Septien
Septien / getFiles.py
Created June 23, 2020 15:44
Gets the name of all the files with .c and .h extension, and saves them on "sources.txt" and "headers.txt" correspondingly.
"""
Get files from list command
"""
import os
def readFile(file1, file2):
with open(file1, "r") as file:
with open(file2, "w") as w:
for line in file:
@Septien
Septien / symlink.sh
Last active March 3, 2020 20:02
The following script, replaces symlinks with the actual files (https://stackoverflow.com/questions/7167424/raplace-all-symlinks-with-original)
@Septien
Septien / gethome.cpp
Created October 8, 2019 22:26
A simple code for getting the home directory of the user, on unix-like systems
//https://www.linuxquestions.org/questions/programming-9/c-home-directory-379996/
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int main(int argc, char **argv)
{
string homedir = getenv("HOME");
@Septien
Septien / download.py
Last active July 20, 2018 17:09
A small script for downloading files form a web page.
# https://stackoverflow.com/questions/2792650/import-error-no-module-name-urllib2
# https://crondev.wordpress.com/2014/06/15/use-python-to-download-files-from-websites/
from urllib.request import urlopen
from bs4 import BeautifulSoup
root = 'url' # url of the page
resp = urlopen(root + 'index.html')
soup = BeautifulSoup(resp.read(), 'html.parser')
links = soup.find_all('a')