danieljon.es

index posts opinions portfolio

Posts

My posts about programming and things.
Date format is day/month/year because I'm sane.

prev 1 2 3 4 5 6 7 8 9 10 11 next


Pinned posts:
Librebooted my x200
website generator re-written in C



post #109
direct link

router and too much free time

26/2/2020

Recently I purchased a netgear wndr3801 router which now runs librecmc. Now my main system (x200 with libre(core)boot) and router run only free software. Fancy.

I also spent a day taking a screenshot of every Chito face (1505 of them) from the manga Girl's Last Tour because she's really cute. I have them online in a collage like thing at https://gnupluslinux.com/chito/. You can download all 1505 images here.

cheeky chito


post #108
direct link

Simple stack

4/2/2020

I'm exploring data structures and I find I learn best when I put something out, so first with a stack. This is my simple implementation using an array. A linked list would be better but that's more verbose.

/*
 * stack using array
 */
#include <stdio.h>
#include <stdlib.h>

struct stack
{
	ssize_t size;
	ssize_t top;
	int *array;
};

struct stack
*createstack(size_t size)
{
	struct stack *stack = malloc(sizeof(struct stack));
	stack->size = size;
	stack->top = -1;
	stack->array = malloc(sizeof(int) * stack->size);
	return stack;
}

void
destroystack(struct stack *stack)
{
	free(stack->array);
	free(stack);
}

int
isempty(struct stack *stack)
{
	return (stack->top == -1);
}

void
pushstack(struct stack *stack, int val)
{
	if (stack->top+1 > stack->size)
	{
		fprintf(stderr, "stack is full, can't push\n");
		return;
	}
	stack->top++;
	stack->array[stack->top] = val;
}

int
popstack(struct stack *stack)
{
	if (isempty(stack))
	{
		fprintf(stderr, "stack is empty, can't pop\n");
		/* in the real world we would not be holding ints so -1 will do */
		return -1;
	}
	int popped = stack->array[stack->top];
	stack->top--;
	return popped;
}

int
peekstack(struct stack *stack)
{
	if (isempty(stack))
	{
		fprintf(stderr, "stack is empty, can't peek\n");
		return -1;
	}
	return stack->array[stack->top];
}

void
printstack(struct stack *stack)
{
	if (isempty(stack))
	{
		fprintf(stderr, "stack is empty\n");
	}
	for (ssize_t i = 0; i <= stack->top; i++)
	 {
		printf("[%zd] = %d\n", i, stack->array[i]);
	 }
}

int
main(void)
{
	struct stack *stack = createstack(50);
	printf("isempty: %d\n", isempty(stack));
	pushstack(stack, 5);
	pushstack(stack, 10);
	pushstack(stack, 15);
	printf("peek: %d\n", peekstack(stack));
	printf("isempty: %d\n", isempty(stack));
	printstack(stack);
	puts("popstack()");
	printf("popped: %d\n", popstack(stack));
	printstack(stack);
	printf("popped: %d\n", popstack(stack));
	printstack(stack);
	printf("popped: %d\n", popstack(stack));
	printstack(stack);
	destroystack(stack);
	return 0;
}

post #107
direct link

Librebooted my x200

21/1/2020

Today I finally librebooted my thinkpad x200. This wont be a full tutorial because a million people have done that, instead it will be a collection of things I had to figure out and whatnot.



tl;dr: I followed this tutorial and it worked fine. Though there was an error in the pinout diagram they provide, my corrected version: (click to see larger picture)


First let me say the libreboot install docs really are a fucking mess if you don't know what you're doing, but that's on people like me not trying to improve it for others after figuring it out. Oh well. The headache is half the fun, right?



Now for some pictures of the process:

Checked the BIOS and ECC versions are the latest:



Completed the required laptop disassembly:



Wired up the pi as required:



Put the clip on and connected it to the pi correctly:



Replaced the wifi card:



First boot:



From here, I migrated the Arch install to Parabola and life was free.


post #106
direct link

Got an x200T and some figures, libreboot tools

20/1/2020

I purchased an x200T for reading manga (and because thinkpads are sexy as fuck). It has 6GB memory and came with a 120GB SanDisk SSD. The keyboard is a shitty replacement, which is unfortunate. Original charger, new (probably shitty) battery, pen (needed a good clean with IPA, it was very sticky and gross) and nice conditioned lid. I don't intend to libreboot this one anytime soon, though.

I also purchased 2 Girl's Last Tour Nendroids and the Girl's Last Tour premium boxset.

I've also purchased a raspberry pi zero w and a soic-16 clip for librebooting my x200. I had 3 pi's but they are all dead, so I needed a new one. I could have used my bluepill devboard, however that looked harder as there were no tutorials on using it.

I did also buy a ch341a USB programmer to use as a librebooting tool, however its voltages are completely wrong.


post #105
direct link

website generator RSS support

12/1/2020

I added RSS support to the website generator. This blogs RSS stream can be found here.

The source code can be found in my git repo.


post #104
direct link

website generator re-written in C

6/1/2020

For the last week or so I have been re-writing my static website genertor in C (again), but this time I finished it. This website is now generated using it.

The source code can be found in my git repo.


post #103
direct link

status bar (binstatus) changes

12/12/2019

I've rewritten my status bar that I use for dwm. It is now completely dynamic and allows customisation through a config.h header file. Yes, I am copying the suckless way of doing things - it's great.

The bar looks like this currently:
(time, battery percent, battery status - D for discharging battery)

The status bar is customised by changing an array that consists of structs. The struct used contains a pointer to a function and a flag (integer). You can use any of the provided functions (see components.h) as a part of the struct. Adding your own is easy, they must just return a char *.

static const struct component components[] ={
	 /*      function        flag    */
	        {currenttime,   NORMALTIME|SHOWMERIDIEM},
	        {battery,       NONE},
	        {charging,      NONE},
	};
The image above was made using this array. If you so desire, you can add more clocks, or any other component, just add another array element. The components are drawn in order.

Flags currently include: 12 hour time, 24 hour time, time shown in binary and whether to show AM/PM. (OR the flags together)

The source code can be found in my git repo.
post #102
direct link

Got some things

3/12/2019

I've purchased a few cool things lately:

I finally got a thinkpad x200! A friend found the listing on ebay - it was a reasonable price compared to everything else available. 4GB ram, no damage, some scratches on the lid. I am yet to libreboot it, but that is the plan. There will be a post on doing that at some point.

I have purchased a new SSD for my desktop, so this x200 will eventually get the SSD that was in that. Or I will just buy a cheap one. Honestly, the HDD is fast enough for me.




I also got some figures, wall scrolls and a boxset. The pictures are shit and don't represent real colors and detail... The yagate scroll is shit in real life, though.


post #101
direct link

Mute music while something else plays audio

1/12/2019

I wanted to mute my music when another application (mpv or browser) started playing an audio stream and unmute the music when that stream ended. To do this I had a look at the pulseaudio API and started investigating how I could go about doing this. Quickly someone pointed me to the modules page on the pulseaudio wiki, specifically the role ducking module.

"This module lowers the volume of less important streams when a more important stream appears, and raises the volume back up once the important stream has finished (this is called "ducking")."

This is exactly what I wanted. Programs run with their media.role set to "browser" will make anything run with the media.role of "music" mute themselves. Implementing it into my environment was straight forward:


post #100
direct link

MariaDB hassle

3/11/2019

For a TAFE project I am doing some stuff in PHP (simple store, see it live on https://manga.gnupluslinux.com and find the source code here) and it requires some databases.

I designed the database in WorkBench and attempted to forward engineer it to my local instance of MariaDB which lead to an error message.

Long story short, MariDB does not support the 'VISIBLE' key word, yet it claims to be a drop in replacement for MySQL. It mostly is, but that's annoying.

You can either remove the keyword 'VISIBLE' from the generated script or set your target MySQL version to 5.7 in WorkBench which does not support the keyword.


prev 1 2 3 4 5 6 7 8 9 10 11 next


RSS feed
FSF member

page generated 26/2/2020 using websitegenerator in C