• Categories
    • Unread
    • Recent
    • Popular
    • Users
    • Groups
    • Register
    • Login
    1. Home
    2. Scuzz
    3. Posts
    Offline
    • Profile
    • Following 0
    • Followers 3
    • Topics 91
    • Posts 375
    • Groups 1

    Posts

    Recent
    • Game of Thrones Season 5 Trailer

      Here is the leaked Game of Thrones Season 5 Trailer.

      https://www.youtube.com/watch?v=ZDb4sJVK2wU

      I really wish I enjoyed the last couple season as much as I did with the first 2.

      posted in The lounge game of thrones season 5
      ScuzzS
      Scuzz
    • RE: nodebb-plugin-shoutbox

      Any updates on this @schamper?

      posted in Development and Coding
      ScuzzS
      Scuzz
    • [C] Printer queue emulation with child processes

      Just showing another project I did while I was at Uni.

      I dont know if it works, it should work as i submitted it as complete. But knowing me, i probably didnt care if it did work or not.

      I’m pretty sure we had to emulate a printer queue. Each printer job was a child process.
      Unix based OS only.

      Producer

      Producer
      /* Some printf functions are comment out, these are for debuggin purposes. */
      
      #include <stdio.h>
      #include <unistd.h>
      #include <sys/types.h>
      #include <sys/ipc.h>
      #include <sys/shm.h>
      
      void fChildProcess();
      
      int main(int argc, char *argv[])
      {
      	if (argc != 3) //Error out if correct command isnt entered
      	{	
      		printf("Usage: %s SizeOfQueue NumberOfJobs\n", argv[0]);
      		exit(0);
      	}
      	
      	int columns = 2;
      	int rows;
      	int row;
      	int *matrix;
      	int shmid;
      	int i, k, j, iNoj, iSoq;
      	
      	iSoq = atoi (argv[1]);
      	iNoj = atoi (argv[2]); 
      	
      	if (iNoj > iSoq) //Error if number of jobs is > than the size of the queue
      	{
      		printf("Number of Jobs has to be less than the Size of queue\n");
      		exit(0);
      	}
      	
      	FILE *fp;
      	pid_t pid;
      	key_t key;
      	key = 1220; //Identifier for shared memory
      	rows = iSoq; //Sets the rows in the shared memory to +1 so there is space for flags
      	k = 1;
      	
      	/* Makes a file that has the size of the queue in it */
      	fp = fopen("size", "w");
      	fprintf(fp, "%d", rows);
      	fclose(fp);
      	
      	shmid = shmget(key, sizeof(int)*rows*columns, IPC_CREAT | 0666);
      	if(shmid < 0)
      	{
      		perror("shmget");
      		_Exit(1);
      	}
      	//printf("Segment created\n");
      	matrix = (int *)shmat(shmid, 0, 0);	//Attatch
      	matrix[0*2 + 0] = 0; // Read/write flag
      	matrix[0*2 + 1] = 1;
      	
      	//printf("%d\t%d\n", matrix[0*2 + 0], matrix[0*2 + 1]);
      	
      
      	while(1)
      	{
      		//printf("WHILE LOOP\n");
      		if(matrix[0*2 + 0] == 0)
      		{
      			for(i = 0; i < iNoj; i++)
      			{
      				if(matrix[0*2 + 1] <= iSoq)
      				{
      					//printf("FOR LOOP\n");
      					pid = fork();
      					if(pid < 0)
      					{
      						printf("fork Error");
      						exit(1);
      					}
      					if(pid == 0)
      					{
      						fChildProcess();
      					}
      					else
      					{
      						//printf("PARENT\n");
      						k = matrix[0*2 + 1];
      						matrix[k*2 + 0] = pid; //Adds PID to shared memory
      						matrix[0*2 + 1]++;	
      						printf("PID %d added\n", matrix[k*2 + 0]);
      					}
      				}
      			}
      			//printf("SHARED MEM\n");
      			//for(i = 0; i < iSoq; i++)
      			//{
      				//printf("%d\t%d\n", matrix[(i+1)*2 + 0], matrix[(i+1)*2 + 1]);
      			//}
      			matrix[0*2 + 0] = 1; 
      		}
      		else
      		{
      			sleep(1); //Wait for consumer
      			wait(1); //Wait for child process
      		}
      			
      	}	
      	shmctl( shmid, IPC_RMID, 0 );
      }
      
      void fChildProcess()
      {
      	for(;;); //infinite loop, child process runs forever.
      }
      
      

      Consumer

      Consumer
      /* Some printf functions are commented out, they are used for debugging purpses*/
      
      #include <stdio.h>
      #include <unistd.h>
      #include <stdlib.h>
      #include <sys/signal.h>
      #include <sys/types.h>
      #include <sys/ipc.h>
      #include <sys/shm.h>
      
      int main (int argc, char *argv[])
      {
      	if (argc != 2)	 //Errors out if correct arguments are not entered
      	{
      		printf ("Usage: %s AmmountToDelete\n", argv[0]);
      		exit(1);
      	}
      	
      	int rows;
      	int columns = 2;
      	int *matrix;
      	int shmid;
      	int i, j, iAtd;
      	
      	iAtd = atoi(argv[1]);
      	
      	FILE *fp;
      	key_t key;
      
      	//Opens the size file to get the size of the queue
      	fp = fopen("size", "r"); 
      	fscanf(fp, "%d", &rows);
      	fclose(fp);
      	
      	if(iAtd > rows)
      	{
      		printf("Please enter a number <= %d\n", rows);
      		exit(0);
      	}
      	
      	k = 0;
      	key = 1220;
      	shmid = shmget(key, sizeof(int)*rows*columns, 0666);
      	if(shmid < 0)
      	{
      		perror("shmget"); 	//Error out if shared mem not found
      		exit(EXIT_FAILURE);
      	}
      	printf("Segment found\n");
      	matrix = (int *)shmat(shmid, 0, 0); //Attatch
      	
      	//printf("Shared mem\n");
      	//for(i = 0; i < rows; i++)
      	//{
      	//	printf("SHARED MEM\n%d\t%d\n", matrix[i*2 + 0], matrix[i*2 + 1]);
      	//}
      	
      	while(1)
      	{
      		if(matrix[0*2 + 0] == 1)
      		{
      			//printf("SHARED MEM BEFORE\n");
      			//for(i = 0; i < rows; i++)
      			//{
      			//	printf("%d\t%d\n", matrix[(i+1)*2 + 0], matrix[(i+1)*2 + 1]);
      			//}
      			//printf("KILLING PIDs\n");
      			for(i = 0; i < iAtd; i++)
      			{
      				if(matrix[(i+1)*2 + 0] > 0)
      				{
      					printf("KILLING\t%d\n", matrix[(i+1)*2 + 0]);
      					kill(matrix[(i+1)*2 + 0], SIGTERM); //Kills the process
      					printf("KILLED\t%d\n", matrix[(i+1)*2 + 0]);
      					matrix[0*2 + 1]--;
      				}
      			}
      			for(j = 0; j < matrix[0*2 + 1]; j++) 
      			{
      				matrix[(j + 1)*2 + 0] = matrix[(j + 2)*2 + 0];
      			}
      			//printf("SHARED MEM AFTER\n");
      			//for(i = 0; i < rows; i++)
      			//{
      			//	printf("%d\t%d\n", matrix[(i+1)*2 + 0], matrix[(i+1)*2 + 1]);
      			//}
      			matrix[0*2 + 0] = 0;
      		}
      		else
      		{
      			sleep(1);
      		}
      	}
      	exit(0);
      }
      
      
      posted in Development and Coding printe queue
      ScuzzS
      Scuzz
    • [nodebb-plugin-imdb] IMDB Information

      I am actually working on a NodeBB plugin. I know, I’m as shocked as you guys. Scuzz actually doing something productive.

      The movie thread got me thinking about a plugin that would pull down some film information from IMDb, title, poster and a short plot when someone posts a link to an IMDb page.

      I started working on this the other night and should have carried on last night but some Vodka took control and I kinda didn’t do anything.

      Today have managed to get some regex working with the help of @Almost and @Schamper.
      Currently I have some test code to select the ID of the film from an IMDb link and add it to a OMDb URL.

      OMDB

      The OMDb API is a free web service to obtain movie information, all content and images on the site are contributed and maintained by our users.

      var omdurl;
      var html = 'dassdffdgf<a href="http://www.imdb.com/title/tt0816692/asdfsdfg">Interstellar</a>sfgfgsfgxxregadfsdfggrereaer';
      omdburl = 'http://www.omdbapi.com/?i=' + html.split(/<a href="(?:https?:\/\/)?(?:www\.)?(?:imdb\.com)\/(?:title)\/(.+)\/.+">.+<\/a>/g)[1] + '&plot=short&r=json';
      console.log(omdburl);
      

      The link that is created returns a JSON object with a tone of information that can be used.

      Tonight I will try and add this code to the code I already have working with a NodeBB instance. Then I will be looking into adding the content into an actual post.

      posted in Development and Coding nodebb imdb plugin
      ScuzzS
      Scuzz
    • RE: Must watch films

      I watched American Sniper last night.
      I quite enjoyed it.
      I have read a lot of articles and reddit comment about this being a huge piece of propaganda. I think any war film can be propaganda but then I think the people who say this read way to much into the film.

      If you don’t read into the film and just take it as a film, even ignoring the fact that it is based on a real person, the film is good. It gets really intense in some places and I think it shows war can change a person and their families.
      If you do not know anything about Chris Kyle I suggest you don’t read about him until you have seen the film as it may change your perspective on the film. I’m guessing most Americans have heard of him but for people who are from other countries probably won’t have.

      Worth a watching.

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Must watch films

      I watched Nightcrawler yesterday. It was not as good as I expected it to be but I would say it is worth a watch. Lou Bloom is pretty psycho.

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Must watch films

      Update the original post, let me know if the categories seem a bit off.

      posted in The lounge
      ScuzzS
      Scuzz
    • [nodebb-theme-classic] BitBangers Classic Theme

      Classic Theme for NodeBB

      A classic theme for NodeBB. For those who want a more traditional feel to their forums.
      This is a modified version of the original classic theme for a more flat look and feel.

      Screenshot

      Home View

      Installation

      cd /to/nodebb/node_module
      git clone https://github.com/BitBangersCode/nodebb-theme-classic.git 
      

      Credits

      Credits to the original theme creator Paaltomo

      posted in Development and Coding nodebb theme
      ScuzzS
      Scuzz
    • RE: Minecraft Server

      Minecraft back online. Requested by @Jellyforme .

      posted in Gaming
      ScuzzS
      Scuzz
    • Blog Theme

      Our BitBangers Blog has been up for a long time now. As you can tell, we are still running the default theme. I am planning on either purchasing a theme or creating my own. I have been told that themeing Ghost is extremely easy and that for the experience I should create one myself.

      I have found Nerdy. I quite like how it is very simple and flat. I think with a few changes I can make it fit in with the theme over at the BitBangers Forum.

      With a few CSS changes I am hoping to have it looking something similar to this:

      Blog

      Which, in my opinion, fits in very well with our forum theme.
      I just need to make the purchase, make the changes and then upload it.

      Hopefully I will have this done in the next few days!

      posted in Announcements blog theme
      ScuzzS
      Scuzz
    • RE: Must watch films

      Updated the first post with a better list.
      When listing a new film i think it might be best to put a category the film fits into, “Drama”, “Crime Drama”, “Action”, etc…

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Gumwrapper Truth or Truth

      #9 I’m pretty sure you all know how I like to celebrate. Extreme amounts of cider.

      posted in The lounge
      ScuzzS
      Scuzz
    • How to Upgrade Ghost

      Usually the upgrade process for various web based software is very simple. Enter a few commands over SSH, run a script or even upgrade via an admin control panel. Upgrading the Ghost blogging platform is very similar.
      In this post I will run you through a very quick way of upgrading Ghost to the latest version.

      How to Upgrade a Ghost Blog

      Before you upgrade any software it is always recommended to backup all your data. Luckily Ghost has a simple way of backing up.
      Log into your blog admin control panel and then go to Settings > Labs. Now click the export button. This will download a .JSON file. This file can be used to restore your blog.

      It is also recommended that you backup your images and theme in your \ghost\content\ directory. This can be done by logging into your server via FTP, SFTP or any other method of accessing your server for file transfers.

      1. SSH into your server
      2. CD \to\ghost\installation\folder
      3. wget http://allaboutghost.com/updateghost
      4. chmod +x updateghost
      5. ./updateghost

      The script will run and once it has finished you can now run ghost with your preferred method. At BitBangers we like to run our Ghost blog with Forever. So to get our blog up and running again we need to enter the following command.

      NODE_ENV=production forever start index.js

      If the script has run correctly you should have a fully update Ghost instance running.

      Below is the contents of the updateghost script.

      #!/bin/bash
      # Written by Andy Boutte and David Balderston of howtoinstallghost.com, ghostforbeginners.com and allaboutghost.com
      # updateghost.sh will update your current ghost install to the latest version without you losing any content
      
      if [ -f config.js ]
      	then
      	echo `whoami`
      	# Make temporary directory and download latest Ghost.
      	mkdir temp
      	cd temp
      	curl -L -O https://ghost.org/zip/ghost-latest.zip
      	unzip *.zip
      	cd ..
      
      	# Make database backups.
      	for file in content/data/*.db;
      		do cp "$file" "${file}-backup-`date +%Y%m%d`";
      	done
      
      	# Copy the new files over.
      	yes | cp temp/*.md temp/*.js temp/*.json .
      	rm -R core
      	yes | cp -R temp/core .
      	yes | cp -R temp/content/themes/casper content/themes
      	npm install --production
      
      	# Delete temp folder.
      	rm -R temp
      
      	echo "You can now start Ghost with npm, forever or whatever else you use."
      else
      	echo "Please cd to your Ghost directory."
      
      fi
      
      

      Thanks to HowToInstallGhost for proving the script and instructions.

      posted in General Computing ghost blog upgrade how to
      ScuzzS
      Scuzz
    • RE: Offers from Google Play

      You get sweet deals with Chromecast too.

      posted in Tech
      ScuzzS
      Scuzz
    • RE: List of Python resources

      @Sly said:

      Dive into Python 3 - You get it.

      That fucking font though.

      posted in Development and Coding
      ScuzzS
      Scuzz
    • How to remove the name icon in the new Google Chrome update

      Today I noticed a slightly annoying new feature in chrome.

      AnnoyingChrome

      As you can see, next to the close, minimise and the restore down button there is a new “Name” button. This feature seems to be added so you can easily see who’s Chrome you are signed in to. It’s nice if you have multiple people signing in and out of your web browser but for me who is a single user I do not need to know that I am signed in. I am always signed in.

      It looks really ugly too.

      To remove it all you need to do is copy the following into your address bar and press Enter.

      chrome://flags/#enable-new-avatar-menu
      

      You can now choose to disable the new avatar menu and have your Chrome looking nice and clean once more.

      posted in General Computing google chrome update name
      ScuzzS
      Scuzz
    • RE: Gumwrapper Truth or Truth

      Mine is always full with cider.

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Must watch films

      I watched Locke over the weekend. I really don’t know what to think about it. Without spoiling much, the film is about a guy driving down UK motorways speaking to various people on his mobile. That is it.
      I was bored during the film as nothing really happens, there are no huge explosions, no car chases and you don’t even see another on screen character. After it had finished I found myself thinking that it was one of the worst films i have ever seen. Thinking about it now, while typing this reply, I think I have changed my mind.

      The amount of information you get from conversations with the various people is amazing. Thinking back on the film now, you know the characters past, his current situation and possibly his future situation. This is the same for the other characters you hear too. All this character development from a few phone calls.

      I would recommend seeing this film and not to turn it off after the first half hour.

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Gumwrapper Truth or Truth

      Cider flavour

      posted in The lounge
      ScuzzS
      Scuzz
    • RE: Must watch films

      I enjoyed both version of let the right one in.

      posted in The lounge
      ScuzzS
      Scuzz
    • 1 / 1