Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)M
Posts
1
Comments
38
Joined
3 yr. ago

  • For saving the history inside of one program run, an array is enough. For saving the history over multiple program runs (over closing by typing and invalid character or ctrl+c and restarting it), you would need to store it in a file.

    You can already print the last conversion by reading the value of f_value/c_value without writing to it (note that if no conversion of that type has happened before, you will get garbage, and that you will have to modify the if at the start of the loop to check for 'x' too):

     c
        
    		if (choice == 'x') {  // x is the letter left of c, so i chose it as an easy example
    			// we want to print the previous conversion, so we don't want to read in a new value.
    			// printf("\nEnter the temperature in Celcius: ");  
    			// scanf("%d", &c_value);  
    			// you might need to comment this getchar() back in so your program skips over the enter after the x, but i am not sure.
    			// getchar();  
    			// no modification of the following line is needed, as the c_value of the last celcius conversion was never written too and as such still exists.
    			printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
    		}  
    
      

    For a longer history you need some extra places to store the numbers. if you use an array, you need to store the length of the history too, since c does not store how far into the array you have written.

     c
        
    // at the start of your main function, where you also declare the other variables
    	// allocate the array with fixed length
    	int last_c_values[16];
    	// and store how many values you've written to it. Initialize it to zero so you don't do garbage with it later on.
    	int last_c_values_count = 0;
    
    // after printing the conversion from celsius to farenheit
    			if (last_c_values_count < 16) // we can't handle a history longer than that yet
    				// copy over the current value into the array, the first one will be at index 0
    				last_c_values[last_c_values_count] = c_value;
    				// increase the counter so the next value will be at the next place
    				last_c_values_count = last_c_values_count + 1;
    				// or shorter: last_c_values_count++;
    			}
    
    //and the new choice for printing the stuff
    		if (choice == 'x') {  // x is the letter left of c, so i chose it as an easy example
    			// start at 0, as long as i is below last_c_values_count, increment i by one at the end of each loop run
    			for (int i = 0; i < last_c_values_count; i++) {
    				// copy the value from last_c_values at index i into c_value
    				c_value = last_c_values[i]; 
    				// and do the same calculation as before again.
    				printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
    			}
    		}
    
      

    PS: the for loop in here is equivalent to the following while loop:

     c
        
    			int i = 0;
    			while (i < last_c_values_count) {
    				// copy the value from last_c_values at index i into c_value
    				c_value = last_c_values[i]; 
    				// and do the same calculation as before again.
    				printf("\n%d degrees Celcius is %.1f degrees Fahrenheit.\n", c_value, toFahrenheit(c_value));  
    				i++;
    			}
    
      
  • Deleted

    Permanently Deleted

    Jump
  • My smallest python program was for filtering wifi names according to patterns. I hab collected some wifi names atomatically via sone other programs, and had them sitting in a text file with one name per line (a very simple data format). I wanted to find interesting names out of it, but didn't want to spend much time scrolling through hundreds of names following the same pattern, like ISP-12C5, ISP-3F4B, ... So i invented my own pattern syntax for very simple patterns, (ISP-%4Ax for ISP- followed by 4 hexadecimal digits with only capital letters), and wrote up a python script that read patterns from a file, and then filtered the standard input against those patters. any line not matching any pattern was then printed.

    In short it was a small project that i wanted to do, with simple data formats that i could easily parse and relatively simpel logic that i had ideas how to implement while designing the patterns. And i had some data to test it on.

    So my advice is similar to the other people here: look for things you are interested in or you need that sound simple to program, and then go on and program one of them. No problem is too small to make a program for.

  • i use the standard git cli mostly, and sometimes the magit package for emacs (but only when i am also working in emacs already)

  • in german the z and s sounds are switched. and you missed the actual z. its Kurzgesagt (from the word "Kurz" (short) and the 3. person singular perfect of the verb "sagen" (to say), "gesagt" (said)).

    (sorry but i couldn't not correct you and explain where the word came from)

  • kde connect allows you to sync the (text) clipboard between a pc and a smartphone that are in the same network.

  • Some minecraft mods had/have a similar problem. They use javas serialization stuff for sending stuff between client and server. There is mod that partially fixes this by only allowing whitelisted classes to be deserialized.

  • I know this under the name sleepSort.

  • Drug, n

    Jump
  • What is that cowsay file?

  • If you click links in the readme (i only tried the last two ones) you get a dmca takedown message.

  • Btw that seems to be a fork/reupload of a DMCA'd repo.

  • Deleted

    Permanently Deleted

    Jump
  • First of all, review it yourself. By reading it again and thinking about it you might find some stuff. After that try static analysis tools like olap said (even some lsp (language server protocol) integrated in your editor can give you good tips). Only after those two options i would even consider using llms, but finding a community of people that are about your language/framework can yield better results. Especially if it is a small project.

  • in my .gitconfig i have

     
        
    [alias]
    	glg = log --oneline --decorate --all --graph
    
    
      

    This allows me to get a quick overview over all branches with pushes that are recent enough for most cases.

  • Mine is a bit longer and includes automatically removing unused dependencies: alias update='sudo apt update && sudo apt upgrade && flatpak update && sudo apt autoremove --purge && flatpak remove --unused --delete-data && notify-send '\''update done'\'''

  • Multiple minecraft mods have this problem. Fun times for everyone when the log complains that \u1013 (probably this one, idk if i remembered it correctly) is not an allowed character for namespaced ids.

  • for 1: kdeconnect or warpinator

  • I make videos irregularly (this year 2 iirc), only when i have an idea and take the time to make the video. Since i do a lot of other stuff it is not really one project, but each video is its own project, and the channel is just a way to publish them.

  • Selfhosted @lemmy.world

    NAS Hardware selection