Skip to content

Instantly share code, notes, and snippets.

View Noe-Sanchez's full-sized avatar
🎯
Focusing

Noe S. Sanchez Noe-Sanchez

🎯
Focusing
View GitHub Profile
@Noe-Sanchez
Noe-Sanchez / test.js
Created October 23, 2024 07:27
nodejs minimal example
// index.js
const http = require('http');
const server = http.createServer((req, res) => {
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end('Hello, World!\n');
});
server.listen(3000, () => {
@Noe-Sanchez
Noe-Sanchez / mobile_sensor.m
Created May 1, 2023 11:09
MATLAB code for logging a mobile device's sensor data, and filtering it using a low pass filter and FFT.
%% Sensor logging(live from cloud)
cla; clear; clc;
m = mobiledev("Your phone");
m.AngularVelocitySensorEnabled = 1;
m.OrientationSensorEnabled = 1;
m.AccelerationSensorEnabled = 1;
m.PositionSensorEnabled = 1;
m.SampleRate = 50;
@Noe-Sanchez
Noe-Sanchez / complex_roots.m
Created April 16, 2023 06:33
MATLAB code for finding n roots of a complex number p.
%Complex number to find roots of
p = [3, 4];
Roots(Magnitude(p), Argument(p), 3)
%Complex number magnitude
function mag = Magnitude(p)
mag = sqrt((p(1)^2)+(p(2)^2));
end
@Noe-Sanchez
Noe-Sanchez / twall.sh
Last active April 16, 2023 06:25
Script to broadcast a message to all connected terminals of a system, regarless of particular wall restrictions.
#!/bin/bash
usage="
Usage:
wall [options] [message]
Write a message to all users.
Options:
-n, --nobanner do not print banner
@Noe-Sanchez
Noe-Sanchez / VMake_installer.sh
Last active February 19, 2024 16:14
Installing script for the VMake utility, a CMake clone for VHDL projects using the ghdl compiler and gtkwave suites.
makefile_contents='project.analyze:\n\t./.handler.sh analyze\n\techo "- Done analyzing"\nproject.integrate:\n\t./.handler.sh integrate\n\techo "- Consolidated top entity"\nproject.clean:\n\tghdl --clean\n\techo "- Cleaned stack"\nwave.gen:\n\techo "- Dumping signals"\n\t./.handler.sh run\nwave.show:\n\techo "- Opening wave"\n\t./.handler.sh open\nproject.all: project.clean project.analyze project.integrate wave.gen wave.show'
touch ./Makefile
echo $makefile_contents > ./Makefile
wget https://gist.githubusercontent.com/Noe-Sanchez/c2b16bc110bb30555ad87be2c24c07c2/raw/64bba8a6a5a8e52962440e48002cfc4faef4c24c/handler.sh
mv ./handler.sh ./.handler.sh
chmod +x ./.handler.sh
rm "$0"
@Noe-Sanchez
Noe-Sanchez / handler.sh
Last active April 16, 2023 06:26
File iterator handle for VMake.
entity=$(cat ./VHLists | grep TOP | sed "s/TOP //" | sed "s/.vhd//")
case $1 in
analyze)
echo "- Analyzing design and testbench files..."
for file in $(cat ./VHLists | sed "s/TOP //g" | tr "\n" " "); do \
ghdl -a $file \
&& (echo "Hit $file") \
|| (echo "! Error at $file" && exit 1); \
done
@Noe-Sanchez
Noe-Sanchez / init.vim
Last active April 16, 2023 06:26
Personal nvim configuration.
call plug#begin(has('nvim') ? stdpath('data') . '/plugged' : '~/.vim/plugged')
let mapleader='`'
nnoremap <leader>v <cmd>CHADopen<cr>
nnoremap <leader>z <cmd>COQnow<cr>
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'ms-jpq/chadtree', {'branch': 'chad', 'do': 'python3 -m chadtree deps'}
Plug 'ms-jpq/coq_nvim', {'branch': 'coq'}
@Noe-Sanchez
Noe-Sanchez / Catmull_Rom_Spline.m
Last active April 16, 2023 06:27
MATLAB code for generation a 3d Catmull-Rom spline.
cla
clear
[X, Y, Z] = deal([]);
A = [0,0];
B = [5,0];
C = [5,5];
D = [0,5];
E = [-5,5];
@Noe-Sanchez
Noe-Sanchez / send_users.sh
Last active April 16, 2023 06:30
Crontab user monitoring code for a Medium tutorial.
#Query users
usrs=$(w -h -s | sed 's/ .*/-/g' | tr -d '\n')
#Print them
Cyan='\033[1;36m'
NC='\033[0m'
printf "${Cyan}Users logged:\n$usrs ${NC}"
echo
#Send them