Skip to content

Instantly share code, notes, and snippets.

View luckasRanarison's full-sized avatar
📚
Learning stuff

Luckas luckasRanarison

📚
Learning stuff
View GitHub Profile
@luckasRanarison
luckasRanarison / TruthTable.java
Last active June 6, 2024 02:46
Static truth table generator using Java for showcasing polymorphism.
import java.util.HashMap;
class Program {
public static void main(String[] args) {
char[] variables = {'p', 'q'};
int variableCount = variables.length;
int possibleCases = (int)Math.pow(2, variableCount);
Eval expression = new Impl(new Var('p'), new Var('q')); // p -> q
HashMap<Character, Boolean> env = new HashMap<>();
@luckasRanarison
luckasRanarison / gdrive.py
Created April 12, 2024 08:35
Upload file to gdrive
from google.colab import drive
drive.mount('/content/gdrive')
import requests
file_url ="https://download.fedoraproject.org/pub/fedora/linux/releases/39/Workstation/x86_64/iso/Fedora-Workstation-Live-x86_64-39-1.5.iso"
r = requests.get(file_url, stream = True)
with open("/content/gdrive/My Drive/fedora.iso", "wb") as file:
for block in r.iter_content(chunk_size = 1024):
@luckasRanarison
luckasRanarison / client.sh
Created December 29, 2023 13:28
hello-UDS-node
echo "Hello world!" | nc -U /tmp/test-socket/socket.sock
# Hi!
@luckasRanarison
luckasRanarison / actions.lua
Last active October 25, 2023 09:44
Neovim code actions
local M = {}
local code_action = vim.lsp.buf.code_action
--- Applies the code action with the given prefix
--- Example: `actions.apply("Wrap in Some")`
--- @param prefix string
M.apply = function(prefix)
code_action({
apply = true,
@luckasRanarison
luckasRanarison / script.lua
Created August 31, 2023 15:54
nvim-help-float
open_help_float = function()
local ui = vim.api.nvim_list_uis()[1]
local width = 80
local height = 25
local row = (ui.height - height) * 0.4
local col = (ui.width - width) * 0.5
local win = vim.api.nvim_get_current_win()
local buf = vim.api.nvim_win_get_buf(win)
vim.api.nvim_win_set_config(win, {
@luckasRanarison
luckasRanarison / cargo.toml
Last active June 19, 2023 08:24
Terminal snake game in Rust using crossterm
[package]
name = "snake-term"
version = "0.1.0"
edition = "2021"
[dependencies]
crossterm = "0.26.1"
rand = "0.8.5"
@luckasRanarison
luckasRanarison / cpu.rs
Last active May 30, 2023 07:04
6502-rs (base 2A03)
use crate::opcodes::CPU_OPCODES;
use self::{AddressMode::*, AsmInstr::*, StatusFlag::*};
#[rustfmt::skip]
#[derive(Debug, Clone, Copy)]
pub enum AsmInstr {
LDA, LDX, LDY,
STA, STX, STY,
TAX, TAY, TSX, TXA, TXS, TYA,
@luckasRanarison
luckasRanarison / 2x2-solver.js
Last active May 6, 2023 04:13
Implentation of a brute force algorithm for solving a 2x2 cube
/**
* @fileoverview Brute force algorithm for solving a 2x2 cube
* @author LIOKA Ranarison Fiderana
*/
// These constants represent the corner pieces (see the picture in the comment)
const UBL = 0;
const UBR = 1;
const UFR = 2;
const UFL = 3;