Skip to content

Instantly share code, notes, and snippets.

View Luctins's full-sized avatar
🦀

Lucas Martins Mendes Luctins

🦀
View GitHub Profile
@Luctins
Luctins / spinnyThing.rs
Last active July 21, 2022 12:35
Little ASCII spinner I wrote in rust to learn how to use iterators
struct SpinnyThing {
index: usize,
}
impl SpinnyThing {
const V: [&'static str; 4] = ["/","-", "\\", "|"];
fn new() -> SpinnyThing {
SpinnyThing { index: 0 }
}
}
@Luctins
Luctins / oneko-band
Created May 20, 2020 19:19
A simple script that creates a string of oneko's that follow each other, $1 is the amount or if == a create all sprites, $2 is aditional param to first cat (like -tofocus)
#!/bin/bash
trap 'exit' INT
stop()
{
killall oneko
exit
}
(defun org-format-hyperlink (link-text-start link-text-end)
"Format the selected text as a orgmode link prompting for the link"
(interactive "r")
;(setq clip (shell-command-to-string "xclip -selection clip -t TEXT -o"))
(setq dest-link (read-string "Link to insert: ")); nil nil (nth 0 kill-ring)))
(if (not (string-blank-p dest-link))
(progn (goto-char link-text-start)
(setq tmp-link (concat `"[[" dest-link `"][" (buffer-substring link-text-start link-text-end) '"]]"))
(delete-region link-text-start link-text-end)
(insert tmp-link))
@Luctins
Luctins / dither_image_blocks.py
Created October 21, 2021 03:41
1 Bit image dithering with blocks
from PIL import Image
# from functools import reduce
import numpy as np
def pxmean(m, y0, x0, s):
c = 0
for _x in range(0, pxsize):
@Luctins
Luctins / ir-remote.json
Last active September 25, 2021 21:28
RGB Lamp remote controller buttons (IR remote, mapped by time)
{
"on": [ 9630, 4420, 630, 570, 580, 570, 580, 570, 630, 520, 630, 570, 580, 570, 630, 570, 580, 570, 580, 1670, 630, 1620, 630, 1670, 580, 1670, 630, 1670, 580, 1670, 630, 1620, 630, 1670, 630, 1620, 630, 570, 630, 1620, 630, 570, 580, 570, 630, 570, 580, 1670, 630, 570, 580, 570, 630, 1670, 630, 520, 680, 1620, 630, 1670, 580, 1670, 680, 520, 680, 1570, 630 ],
"off": [ 9580, 4420, 680, 470, 680, 470, 680, 520, 680, 470, 680, 470, 680, 470, 680, 520, 680, 470, 680, 1570, 680, 1620, 680, 1570, 680, 1570, 680, 1620, 680, 1570, 680, 1570, 680, 1620, 680, 1570, 680, 1570, 730, 1570, 680, 470, 680, 520, 680, 470, 680, 1620, 680, 470, 680, 520, 680, 470, 680, 520, 680, 1570, 680, 1570, 730, 1570, 680, 470, 730, 1570, 680 ],
"red": [ 9580, 4470, 630, 520, 630, 570, 580, 570, 630, 570, 580, 570, 580, 570, 630, 520, 630, 570, 580, 1670, 580, 1670, 630, 1620, 630, 1620, 630, 1620, 630, 1620, 630, 1670, 630, 1620, 580, 570, 630, 1670, 630, 1620, 630, 520, 630, 1670, 630, 520, 630, 570, 630, 520, 630, 1620, 630, 570,
@Luctins
Luctins / util.h
Last active September 8, 2021 17:36
C Utilities
/**
Copyright (c) 2020 Lucas Martins Mendes.
All rights reserved.
Redistribution and use in source and binary forms are permitted
provided that the above copyright notice and this paragraph are
duplicated in all such forms and that any documentation,
advertising materials, and other materials related to such
distribution and use acknowledge that the software was developed
by the Lucas M. The name of the
@Luctins
Luctins / quartus20.01.desktop
Created May 28, 2021 12:29
Quartus .desktop file
[Desktop Entry]
Type=Application
Name=Quartus Intel FPGA Lite 20.1
Exec=/home/mluctins/.intelFPGA/20.1/quartus/bin/quartus
Terminal=false
GenericName=EDA
Icon=/home/mluctins/.local/share/icons/quartus.ico
Categories=Development;EDA;
StartupWMClass=Quartus
# Settle time
# @author: Lucas Martins Mendes - contact@luctins.me
function ret = settle_t(F, X = [], T = [], tolerance=0.02)
if size(X) == [0 0] || size(T) == [0 0]
[X, T] = step(F);
endif
_X = flip(X);
_T = flip(T);
s_top = (1+tolerance)*dcgain(F);
s_bot = (1-tolerance)*dcgain(F);
@Luctins
Luctins / stophd.sh
Created March 16, 2021 20:49
Alias to make silly USB hard drives stop spinning
alias stophd='sudo hdparm -B1' #<path to drive>
#Usage: stophd /dev/sdb
@Luctins
Luctins / insert-image.el
Last active January 26, 2021 19:31
orgmode image inserter
(defun org-insert-image-from-clipboard ()
"Take a screenshot into a time stamped unique-named file in the
same directory as the org-buffer and insert a link to this file. Depends in X.org to work (for now)"
(interactive)
(setq folder-name (concat (file-name-sans-extension (buffer-file-name)) "-orgimg"))
(message folder-name)
(if (not (file-directory-p folder-name))
(make-directory folder-name nil))
(setq filename
(concat