Post your coding projects

Making own little cli text editor like nano.
Called it planck coz of Planck Length trying to be kinda relevant with nano and pico theme.

(It's on the right, on the left is vim :wink:)

Atm can't edit stuff, but can read files into the buffer and scroll it. Code really needs refactoring, as everything is in main.c atm. Used ncurses for the first time, so there's that.

EDIT: small update, line numbers, status bar, better scrolling

4 Likes

forgot to add the -a for -p lol

but had already added to the -h list for the other commands but not totally happy with it yet

still liking the indenting and the general layout mostly

bump

added an extra lower power state to mserv,

if its been in the wait/low power whatever state for over 3600seconds will stop checking once a second and instead do one check per 10 seconds but this isnt much of a drop in utilization as the previous setup was much more impressive.

being before, it would have been,
top of loop
check control file(checking if its there/if it can open it etc then read if it can, then close if it had opened)
skip basically entire majority of the loop if nothing had been instructed other than wait
end of loop

into adding a sleep(1);(wait/do nothing for 1 second basically)
as opposed to checking possibly 10s of thousands of times a second depending on processor speed, so 1/10th(nearly has the extra check to add to the time count if it hadnt gone over the 3600 yet) isnt as impressive as 1000x> reduction in cycle usage

but it seemed reasonable enough compromise as.. only situation id see it really being used in that way, where it had been instructed to low power state for over an hour, would be if you had it as home automated tv or something like that, where it auto turned off for the night, if you have it auto turn on for the day, 10seconds isnt that bad as you can just schedule it for exactly when you get up/want it to go, not 10 seconds after you press the button and stare at it

and was no big deal to add aswell lol

added a scripting toggle basically.. where if you pass the commands with -s as the final argument it will check if the number is 0, else it will drop the command, the point being, if you manually issue a command but have some scripting/cron jobs whatever to issue commands it wont interrupt a command you gave it manually, until you set it back to the automated mode

also added to -sp and -n, where if you dont specify a number it just fills in 1, for if you want to play say a movie which has its own list but is the only file in the movie, it could play that one time, then switch back to the previous command.

added into the actual 'server' program, where if you run -sp or -n, it also switches back the toggle when it reverts back to the previous command

so if it was playing something and you do -p moviename -a it would play that movie after the current file ends, then switch back to the list it was on and the automated/usercontrol toggle, so if it was 0, during the duration of that command it would be 1, then switch back to 0 allowing the next scripted command to run as normal

edit: also worked on the help output a little, and added -a for the shutdown/stop commands

@SEP

1 Like

minor bump,

removed some redundant options, ex. if you did mcli -n movies 1 -aro it would denote to play after the file ends, but then restart the original operation i.e., start at the previous file you had just watched instead before the -n command, instead of at the next file as normal operation. being redundant as -a already ensures it doesnt run until after the file ends so it would only be useful if you purposefully wanted to watch it again, where if you interrupted the file then maybe you would want to restart it

but can always just use setpos to rewind the list if they really want to watch it again lol.

but also was able to simplify the helptext a bit and now it denotes fully all the options isntead of just implying some of them

@SEP

I did a short project during my week off from classes a month or so ago. At that point, I was interested in the Tox protocol, but I didn't like how both users needed to be online at the same time. That requirement caused difficulties when using the system on a phone. So, I ended up coding a program to act as an intermediary between two users. It probably has some security issues, but it did what I wanted to.

Trailer Logging software for work.
Made with meteorJS.

Cool project. What was your reason for switching from php to meteorJS?

javascript full stack development, its much faster than dealing with a lot of seperate languges. As our last project we had 3 people working on it in spare time and it was like 10k lines of code just to do what I can do with meteor in less than 300.

Oh, and our site only have PHP5 on the webserver, and we can't upgrade it, so I wanted something that would give good performance.

1 Like

Most recent project.

Away to visit relatives in another state, got bored and decided to make a roguelike cli game.

2 Likes

This one is for you @Miguel_Sensacion.

Below we have an example of a nasty little "green/red" PHP script written by yours truly, which attempts to automate our site's "Service Status Board," for our fellow non-IT people to know when service interruptions are occurring. We have sweet monitoring, the regular/normal people don't, so they use our service status board. I'll run it as a cron every 3-5 minutes.

Per standard sysadmin procedure, I've made sure to leave all the commented out debugging code and strictly use procedural and function programming to give all the good programmers and devs the full sysadmin treatment.

There is one outstanding tablepress library I need to include, but I'll do that Wednesday when I get back to work and put this into production. Then we'll never have update our status board again, until WordPress releases 4.9 and totally ravages our site again.

Lastly, when things slow down (LOL!) I'll probably write a quick function which actually authenticates into two of the services, because even though the page loads, tomcat listeners sometimes like to stop working and reverse proxies sometimes just don't want to forward traffic. That will be 2.0, for now this is enough for a hacked up script.

Enjoy!

PS - Code written using Vi on an Ubuntu 16.04 Laptop.

#!/usr/bin/php

//THIS SCRIPT UPDATES OUR SERVICE STATUS BOARD

#####################################################################################
#										    #
#				DEFINE FUNCTIONS				    #
#										    #
#####################################################################################


//THIS FUNCTION CHECKS IF A URL IS "ONLINE" BY RETURNING "FALSE" IF THE HTTP HEADERS DON'T RETURN A 200
	function URLIsValid($url)
	{
	//	echo "checking " . $url;
		$exists = true;
		$file_headers = @get_headers($url); //gets headers from url
		$headers = array('HTTP/1.1 200 OK','HTTP/1.0 404 Not Found', 'HTTP/1.0 403 Forbidden', 'HTTP/1.0 500 Internal Server Error'); //array of possible header
		foreach($headers as $headerVal)
		{
	//		echo  $file_headers[0];
			if($file_headers[0] != $headers[0])
			{
				$exists = false;
			}
		}
	
		return $exists;
	}

//THIS FUNCTION ITERATES THROUGH THE SITES AND GENERATES THE OUTPUT FOR THE TABLE
	function runIt($sites, $urls)
	{
		$table_id = 1; //TABLEPRESS TABLE NUMBER ID
		$table = TablePress::$model_table->load( $table_id ); //LOAD THAT TABLE INTO MEMORY

		$numDown = 0; //HOW MANY SERVICES DOWN
		$i=0; //COUNTER
		$pattern='/^man|^unknown|^degraded/'; //MATCH PATTERNS WHICH INDICATED WE'VE MANUALLY UPDATED THE STATUS
		
		//LOOP THROUGH EACH URL		
		foreach($urls as $url)
		{
	//		$friendlyName=$sites[$url]; //TEMP ASSIGN THE FRIENDLY NAME FOR THE URL
			$trValue=table[data][' . $i . ']; //GET THE HTML TAG FOR THIS ROW
	//		$trValue="<span class = \"ok status\">OK</span>"; 
			
			//IF WE'VE MANUALLY UPDATED THE TABLE DON'T MESS WITH IT OTHERWISE PROCEED TO UPDATE TABLE
			if (!preg_match($pattern, substr($trValue,15), $matches))
			{
				if (URLIsValid($url))//SEE IF WE'RE UP
				{
	//				echo $friendlyName . " is up \n";
					table[data][' . $i . '] = "<span class = \"ok status\">OK</span>"; 
			//		echo "\n";
				}
				else
				{
			//		echo $friendlyName[$i] . " is down \n";
	       		 		table[data][' . $i . '] = "<span class = \"do status\">DOWN</span>"; 
			//		echo "\n";
					$numDown++;
				}
			
			}

			$i++;
		}
		
		//GET THE VALUE OF THE NETWORK ROW	
		$trValue=table[data][' . 5 . '];
//		$trValue="<span class = \"ok status\">OK</span>"; 

		//IF WE'VE MANUALLY SET IT LEAVE IT ALONE
		if (!preg_match($pattern, substr($trValue,15), $matches))
		{
			if($numDown == 2)//IF TWO SERVICES ARE DOWN THE NETWORK IS LIKELY DEGRADED
			{
	        //		echo "Network degraded \n";
	         		table[data][' . 5  . '] = "<span class = \"de status\">Degraded</span>"; 
			}
			else if ($numDown > 2)//IF MORE THAN TWO ARE DOWN THE ISP IS PROBABLY DOWN 
			{
		//		echo "Network Down \n";			
	         		table[data][' . 5  . '] = "<span class = \"do status\">Down</span>"; 
			}
			else
			{
		//		echo "Network Okay \n";
	        		table[data][' . 5  . '] = "<span class = \"ok status\">OK</span>"; 
			}
		}		
	
			TablePress::$model_table->save( $table ); //UPDATE THAT TABLE
	}
		
//DEFINE MAIN
	function main()
	{
		//Hashmap of our sites
		//Order is important here so make sure you put them in the correct or they appear on the table
		$sites=[
			"http://www.companyhomepage.com" => "Company_Site",       //Company's Webpage
			"https://mail.company.com"=>"Email",                      //Email
			"https://application.oursite.com"=>"Hosted_App1",         //Hosted App1
			"https://emportal.oursite.com/lolz"=>"EmployeePortal",                 //Employee Portal
			];

		//GET JUST THE KEYS FROM ABOVE
		foreach($sites as $key => $value)
		{
			$urls[]=$key;		
		}	
		
		//BUILD THE TABLE
		runIt($sites, $urls);
	}


#######################################################################
#								      #
#                           SHOW TIME				      #
#                                                                     #
#######################################################################


main();


//AND.....WE CAN ALL GO HOME NOW
1 Like

Well i don't have anything to present here at this point but there are two things I am working on in coding.
Nr1: For a school end of year kind of project we are recreating the game 2048 in Javascript.

Nr2: For a project in cooperation between my school and tente, a company that is developing a motorized tire for hospital beds to ease the workers in a hospital and to enable a single person to move a heavy bed more efficiently. For this project we are just writing code. All contributors from our school get a free raspberry pi and if we do good work we get a job offer. However this second project didn't properly start yet.

1 Like

At the suggestion of @MFZuul:

I pulled the DictDiffer class from somewhere on the web, as well as a template for sending email, so not all original, but nonetheless, useful.

3 Likes

I'm making a C++ bioinformatics library, and am using it to rebase for version 3 of TF-Cluster. Granted, soon TF-Cluster and TF-Finder will both die off as they are absorbed (rightfully so) into orange.

github.com/anadon/madlib

There's a non-0 chance that I might accidentally DDOS NCBI from the new TF-Cluster version, though...

1 Like

added a thing to say if it completes over 10k for finalizing a list file for the mcli program..

added a higher retry allowance for failing to open a file before mserv will just drop back to the low power/wait state.
was previously 10 tries as fast as possible, now its 10 tries, then 1 second delay, upto 10times.

also changed mserv, so it fully doesnt create position files for lists which only have 1 segment(as theres no position to differentiate), instead of them previously being temp files.

the position tracking is such that it gets updated every time it finishes playing a segment, as depending on how the user sets up the thing the potential for dataloss could be pretty high, if there was an unexpcted shutdown, powerloss etc.

as, if you have a list thats say 25k segments, of ~25m episodes or ~434days if they just left it running 24/7 the probability of powerloss or something like that within the time of playing the list 1 time is probably guaranteed. by writing every time the only way you could lose data from say powerloss, would be if it happened during the write, which is a tiny fraction of the time for a small single block file vs say 3m for a music video, or 2hrs for a movie whatever, otherwise it will resume on the same segment

otherwise still looking into optimization for if the lists become very large

is currently single threaded but dont think thats the issue is the scanning in of the data for the individual segments using only a single pointer, such that it has to rescan files many many times but cant really just use the novell solution of using one pointer per file as, not all operating systems may be cool with you just potentially opening up say anywhere between 1 and something billions of pointers

currently thinking of some kinda indexing/see if theres some other ways i can advance through the files.
ex: if did once thte total for the list goes over 1000 say, create a subdir, and have 1 file per 1000 which would substantially improve it over having lists 5-10000> long, which is pretty high candidate currently just looking into some other options first :stuck_out_tongue:

@SEP @MFZuul

2 Likes

Wrote a small package which implements a template string tag that can be used to write SQL queries from Javascript in a fairly succinct way. Automatic prepared statements...

JESUS

OH

ow...

I made a website for my database class using PHP and MySQL (mariadb version).





My last project was text editor plank. I decided to halt it, because I am doing something more interesting.

Introducing:

FermiOS

This "state of the art" "Operating System" has such amazing and revolutionary features as:

  • receiving input from PS/2 keyboard (and USB because of hardware emulation);
  • printing text on CGA compliant graphics monitors (and other because of hardware emulation);
  • it has a timer.

It's stylish white on blue all text UI will set the standards for millennia into future. It will transform your IBM compatible PC with Intel i386 or better compatible CPU into... into... magnificent post-modern art piece.

Here you can see our engineer use it:

And you just wait and hear what people say about it:

"So, can I type ls? No? Oh, it doesn't have HDD support, yet? Cool..."
-My Dad


Anyways, it's in C + some x86 assembly sparkled here and there. Here's the repo: https://bitbucket.org/redpandaua/fermios


You asked for it @dinscurge

3 Likes

I'm gonna have a look at your creation :smiley:
But a question. Where do you start if you want to do something like this?