Skip to content

Instantly share code, notes, and snippets.

View richardnfag's full-sized avatar
👽

Richard do Nascimento Fagundes richardnfag

👽
View GitHub Profile
[package]
name = "factorial"
version = "0.1.0"
authors = ["Richard do Nascimento Fagundes <richardnas_@outlook.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib"]
[dependencies]
@richardnfag
richardnfag / lib.rs
Created April 14, 2019 22:20
Rust FFI no stdlib
#![feature(lang_items)]
#![no_std]
use core::panic::PanicInfo;
#[no_mangle]
pub extern "C" fn factorial(x: u32) -> u32 {
(1..).take_while(|&i| i <= x).product()
}
@richardnfag
richardnfag / .bashrc
Last active June 27, 2019 11:28
My bash customization
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
@richardnfag
richardnfag / hex_to_rgb.py
Created November 16, 2019 01:09
Python Hex Code to RGB Value
def hex_to_rgb(hex):
return ','.join(list(
map(
lambda x: str(int(hex[x:x+2], 16)),
range(0, len(hex), 2)
)
))
@richardnfag
richardnfag / rgb_to_hex.py
Created November 16, 2019 01:10
Python RGB Value to Hex Code
def rgb_to_hex(rgb):
return ''.join(list(
map(
lambda x: format(int(x), '02X'),
rgb.split(',')
)
))
@richardnfag
richardnfag / mount_partitions.sh
Created December 13, 2019 16:28
Mount partitions in IMG file
# LIST PARTITIONS
fdisk -l image.img
sudo losetup --find --show image.img
sudo partprobe /dev/loop0
sudo mount /dev/loop0p1 /mnt/img1
sudo mount /dev/loop0p2 /mnt/img2
@richardnfag
richardnfag / minikube.sh
Created March 7, 2020 16:21
Minikube installation
sudo mkdir -p /usr/local/bin/
# kubectl
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
# minikube
curl -Lo minikube https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
chmod +x ./minikube
sudo mv ./minikube /usr/local/bin/
@richardnfag
richardnfag / firefox-install.sh
Created May 18, 2020 14:35
Firefox Nightly intallation on Linux
curl -L -o firefox.tar.bz2 "https://download.mozilla.org/?product=firefox-nightly-latest-ssl&os=linux64&lang=en-US"
tar -xjf firefox.tar.bz2
sudo mv firefox /opt/
cat <<EOF >>firefox-nightly.desktop
[Desktop Entry]
Version=1.0
Name=Firefox Nightly
@richardnfag
richardnfag / remove_node_modules.sh
Created December 10, 2020 23:44
Delete all node_modules folders in a directory
find . -name 'node_modules' -type d -prune -print -exec rm -rfv '{}' \;
@richardnfag
richardnfag / zsh.sh
Created April 23, 2021 02:09
ZSH customization script
#!/bin/sh
user_setup(){
sed -e '/PROMPT/ s/^#*/#/' -i $1 2> /dev/null
cat >> $1 <<EOF
# Find and set branch name var if in git repository.
function git_branch_name()
{
echo $(git branch 2>/dev/null | grep '^*' | colrm 1 2)