Skip to content

Instantly share code, notes, and snippets.

View mhitza's full-sized avatar

Marius Ghita mhitza

View GitHub Profile
@mhitza
mhitza / Makefile
Last active April 6, 2024 17:20
Programming Arduino Uno (ATmega386P) in assembly
%.hex: %.asm
avra -fI $<
rm *.eep.hex *.obj *.cof
all: $(patsubst %.asm,%.hex,$(wildcard *.asm))
upload: ${program}.hex
avrdude -c arduino -p m328p -P /dev/arduino-uno -b 115200 -U flash:w:$<
monitor:
@mhitza
mhitza / psp_on_linux.md
Created October 8, 2015 02:37
How to connect your PSP on Linux

It should work by default when connected, however you might reach this page with the same issue I had, where you where missing a few essential steps.

  1. Be sure that your PSP is set into USB mode: Settings -> USB connection
  2. Be sure the kernel module usb-storage is enabled, you can check with sudo modinfo usb-storage and enable it with sudo modprobe usb-storage
  3. Reconnect your cable after trying any of the previous steps
  4. If it doesn't get automounted, run dmesg to find the device (on my local machine it's sdb as seen in the output) and mount it manually (prefered with your user access rights so you don't have to use sudo for file copy)
@mhitza
mhitza / vim-guile.md
Last active October 24, 2023 07:19
vim + GNU Guile development environment

This document was based on my local [GNU Guile][1]-3.0.5 setup. I'm not sure if it works as is with an older version of GNU Guile.

Because of a [dependency in Fedora][2] I had to compile GNU Guile from source release. As such, in your local setup the paths will differ. This is only relevant when defining the GUILE shell variable, and referencing the tags file in the vimrc.

Note that when building GNU Guile from source be sure that you have the readline-devel (or distro equivalent package) installed. That way the ./configure step will pick that up, and the ice-9 readline module will be usable.

@mhitza
mhitza / attempt.md
Last active September 5, 2023 10:59
Two lines of shell script in 4 hours of custom Ansible module development

In the last couple of days I've typed away at some Ansible automation, and one specific group of tasks I dealt with was the creation of a target symlink and parent directories. I wasn't able to do this in one go, and thus arrived at the following result:

- name: "absolute home {{ config_path }}"
  set_fact:
    absolute_home_config_path: "{{ user_home_dir + '/.' + config_path }}"

- name: "{{ absolute_home_config_path|dirname }} present"
@mhitza
mhitza / sculpin_for_github_pages.md
Last active August 22, 2023 17:16
Sculpin for Github pages

After a couple hesitating months to move to github pages, and from my hacked together static site generator, yesterday was my 4th attempt in getting started with github pages blogging, just because there where a few annoyances with the different variations I've tried.

Decided to go with Octopress, just for their nice logo. And for their Github pages oriented focus. That didn't pan out, but at least I learned a few things about their blogging process and setup, which I'm adapting for sculpin.

Sculpin for Github pages (Déjà vu)

@mhitza
mhitza / strip-js-comments-run.md
Created August 6, 2023 12:16
Script using babel to strip all comments from JavaScript files
chmod +x strip-js-comments.mjs
npm install --save @babel/generator
npm install --save @babel/parser
./strip-js-comments.mjs assets/js/script.js
@mhitza
mhitza / main.hs
Last active December 14, 2022 10:12
Day 14 advent of code broken code
{-# LANGUAGE BlockArguments, Strict, LambdaCase, NoMonomorphismRestriction, MultiWayIf #-}
import Control.Monad.State.Strict
import Data.List
import Data.Char
import Data.Ord hiding (Down)
import Data.Bifunctor
import Data.Function
import Data.Functor.Identity
import Debug.Trace
@mhitza
mhitza / main.hs
Last active December 11, 2022 08:38
Day 11 advent of code 2022
{-# LANGUAGE BlockArguments, BangPatterns, LambdaCase, NoMonomorphismRestriction #-}
import Control.Monad.State.Strict
import Data.List
import Data.Bifunctor
import Data.Maybe
forEach xs st f = snd $ foldM (\st x -> runState (f x) st) st xs
alterF = modify . first
alterS = modify . second
getF = gets fst
@mhitza
mhitza / main.hs
Last active December 8, 2022 13:14
Day 8 advent of code 2022
{-# LANGUAGE BlockArguments, Strict #-}
import Control.Monad.State
import Data.List
import Data.Char
import Data.Bifunctor
takeUntilIncluding p [] = []
takeUntilIncluding p (x:xs)
| p x == True = x : takeUntilIncluding p xs
| otherwise = [x]
@mhitza
mhitza / main.hs
Created December 5, 2022 11:31
Day 5 advent of code 2022
{-# LANGUAGE BlockArguments, Strict #-}
import Control.Monad.State
import Data.List
import Data.Bifunctor (first)
import Data.Char
forEach xs state' f = foldM (\st v -> runState (f v) st) state' xs