Release IV for OSD600

In this Release, I worked with bracketsthimble, and a new repo that Mozilla forked for my brackets issue http-server. For my brackets issue, I had to switch http-server to Http-server-gzip.  humphd and gideonthomas had a discussion on what the best approach for this issue would be, and I had to wait till they agreed on what was to be done. They decided on forking the http-server repo those projects aren’t really maintained anymore. for my first fix, I had to add and if statement to check if the object was a gzip, and if true change the Content-Encoding header to gzip, here is the code:


this.headers[‘Content-Encoding’] = ‘gzip’;


Then I had to modify the package.JSON file to reference a GitHub dependency.

So I changed two lines 53, and 67


“http-server”: “^0.9.0”,

“production”: “npm start”,


“http-server”: “mozilla/http-server#gzip”,

“production”: “npm start — –gzip”,

Both of these pull requests landed smoothly http-server pull request and brackets pull request.

These fixes were pretty simple, only part I had a problem was referencing the GitHub branch, since the document showed many different ways, and said some of them were outdated I had to do some trial and error, luckily the third time was the charm!


So this fix seemed pretty simple at first since I was provided some documents within the issue. I read on the yarn website how to download it for Ubuntu (thats the Vm that thimble uses) and followed the documentation on how to replace the npm commands. I started to write the code and decided I wanted to test it, well then I found out my thimble stopped working and was rejecting the port:3500. So I tried to fix this error for about 3 days, and my roommate Ray really had no idea how to fix it, since he is a Linux man. So I decided to ask for help on the Mozilla chat system, luckily pomax was able to help me fix my port issue, but now I am on a vm issue. so most of the code I will show now is theory since I was not able to test it.

To install yarn I did the command

curl -sS | sudo apt-key add –

echo deb stable main | sudo tee /etc/apt/sources.list.d/yarn.list

Then to replace the npm I did this:


npm install -g http-server –loglevel=error # For hosting published projects

npm install –no-bin-links –loglevel=error


yarn global add http-server –loglevel=error # For hosting published projects

yarn install –no-bin-links –unsafe-perm –loglevel=error

Now, this is only a few lines, in total I’ve changed about 12 lines of code on the . I wish I could have tested it and make sure it was working before I put up my pull request , but I’ve been stuck in a rut and needed help. So now all I can really do is blog about this release until I fix the issue with thimble not loading correctly.


This Release has taught me a lot in working through problems and trying to solve them, more so with getting stuff to work and not with my code. I’ve really enjoyed working with thimble and brackets and I wish to continue working on these projects since I’ve learned to understand them & it has a great community. Through all the tips and tricks I’ve learned this semester just by talking to the developers on these projects, I am grateful for taking OSD600




So the shift from Phase II to Phase III not much has changed with my code, except for my friend Ray. Who had done some code review for his phase III and was nice enough to check over my pull request. All the changes he requested were more stylish changes then logic, so thankfully I did not have to change much.


In my report sheet for Phase II, Chris asked me to provide testing on other platforms and give a percentage wise on the improvement my function is. Please note my function is the second one in each test.

Desktop (i5 CPU running Windows):


Laptop (I7 CPU Running Fedora)


Xerxes (X86_64 Server provided by Chris)


I always tried to get my function to work on our betty server that runs AARCH64, but I kept getting this error and after a lot of googling and messing around I was still not able to get it to compile. here is the error, if anyone knows the fix please let me know!


Testing Conclusion

From what I’ve seen with my testing, my optimization provides a 20% – 40% performance boost to the function STRCSPN. Which is really good from the 10% Chris was asking.

Peer Code Review

Atm I wrote this blog there is only 6 pull request up on Chris’s repo and since one was mine, the picking’s were slim. I decided to review one of my friends pull request, Matt who decided to optimize strfry. Looking over most of his code, it made sense. So  I thought I’d ask him instead of why did he remove the strlen function, to get his mindset why that was a good way to optimize the function so I could understand his optimization.

here is his optimization:




I feel confident with my optimization, and think it is a good improvement to the function. I felt kinda bad that I could not review more of my friend’s code, but since he changed only a few things I really did not have much to comment on.


Having Fun With Vagrant!


The start of Release 3, I was looking for a challenge. After discussing with my Professor, he mentions about the  Issue he created and suggested it to me. After looking into it, and watching countless videos I decided to tackle this problem.


My professor suggested using ansible, saying his Linux guru colleague suggested it.  I first tried to get it to work on my windows machine, but through a lot of problems such as that I needed to install cygwin, and after discussing with my prof he said that he doesn’t want to force developers to install more tools to be able to use thimble. I also tried to get it to work on Linux and had more success until I tried to test the playbook ansible-playbook playbook.yml –check and kept receiving the error


Chef Zero

I was able to download the Chef Zero Provisioner, I was able to get it working, but kept receiving an error on PowerShell when I tried to test the cookbook, it filled me with errors.



Puphpet was nice and easy to setup. All I had to do is fill out the form on Puphpet website, using the thimble scripts of what packages and type of database to install. The first real problem was getting the vagrant file to load the proper scripts, and since I had to change all the file pathing since the scripts had to go into a specific folder. Once I was able to change the scripts and have the vagrant up command to start working I started to get more errors such as


I was able to fix this error, by deleting the VM and then a new error popped up!



Overall I’m glad that I took on this Issue, I’ve learned a lot about vagrant provisioners. I learned about multiple types, and how they differentiate from each other. Even though my pull request did not go through, I am still grateful for this experience. The reason for the pull request not going through is that it was such a big change, and very demanding. Also since such, I had such a limited time frame, that it would be too hard to get this pull request through.


Hopefully one day this issue will get fixed, and maybe I could be the one to fix it!

OSD lab 9 Creating a Web Server! (with Heroku)

This lab is a continue of Lab 8 & 7 that I previously blogged about. This lab was getting are repo to be hosted online and how to use Heroku to complete that process!


First, we had to create a node.js server to locally test are code and make sure it works completely.  We then tested Url’s and see if they Passed the tester we created. My code validated the emails precisely so I did not have to make any changes to that code and I was able to move onto the second part of this lab

Deploying to Heroku

This started off pretty simple, I created my account and downloaded the DLI on to my windows computer. I started facing problems when I wanted to log in though with git bash:


I was able to login with command prompt, and run the command heroku create. But nothing showed up in my repo after I ran that command, I was even able to add the remotes to Heroku, but still had no success.

ATM, I’m still stuck at this part, but I know how to fix this problem, and should be able to complete this lab at the end of the week



This lab overall was a cool addition to our labs since most of us rely on Seneca to host most things for us to complete projects, it was really cool to see how we can host our own projects free of charge (As long as it’s open source).  I’ve really enjoyed this lab series and have learned a lot about development outside of Seneca, for that, I am very grateful. I feel like I’m getting my foot in the other door, before leaving the comforts of Seneca.




SPO Final Assigment Phase II

So for Phase 2, I complete redid my plan for Optimizing the code, Instead of rewriting and after talking to my Prof we decided that optimizing the code to work on a 64-bit processor instead of a 32-bit processor would be a good idea.

So before I could optimize this, I needed to understand what this function was doing 100% and figure out to optimize it. So after looking over the entire function, I realized the first part of this function could really not be optimized. Since it is creating an ASCII table and marking what parts of the reject string are in the ASCII table. but then it was really only going through the string by fours (Supporting 32-bit processors).

if (p[s[0]]) return 0;
if (p[s[1]]) return 1;
if (p[s[2]]) return 2;
if (p[s[3]]) return 3;

unsigned int c0, c1, c2, c3;
s += 4;
c0 = p[s[0]];
c1 = p[s[1]];
c2 = p[s[2]];
c3 = p[s[3]];
} while ((c0 | c1 | c2 | c3) == 0);


So rewriting this code was pretty simple, just had to create another 4 more unsigned int.   Allowing it for cycling 8 at a time (Supporting 64-bit processors).  Here is how I rewrote it

if (p[s[0]]) return 0;
if (p[s[1]]) return 1;
if (p[s[2]]) return 2;
if (p[s[3]]) return 3;
if (p[s[4]]) return 4;
if (p[s[5]]) return 5;
if (p[s[6]]) return 6;
if (p[s[7]]) return 7;
unsigned int c0, c1, c2, c3, c4, c5, c6, c7;
s += 8;
c0 = p[s[0]];
c1 = p[s[1]];
c2 = p[s[2]];
c3 = p[s[3]];
c4 = p[s[4]];
c5 = p[s[5]];
c6 = p[s[6]];
c7 = p[s[7]];
} while ((c0 | c1 | c2 | c3 | c4 | c5 | c6 | c7) == 0);

This was a simple fix and just had to make sure my code was consistent with their code and not trying to add my own touch to it. The only problem was trying to read a return ternary statement they left.

return (c0 | c1) != 0 ? count – c0 + 1 : count – c2 + 3;

During a discussion in class, we learned that a ternary statement and if the statement had the same exact run time except in certain situation but they did not apply for my code. This allowed me to make a more readable if statements with multiple return statements.

if (c0 | c1 != 0) {
return count – c0 + 1;
else if ((c2 | c3) != 0) {
return count – c2 + 3;
else if ((c4 | c5) != 0) {
return count – c4 + 5;
else {
return count – c6 + 5;

Now the only thing was testing my code. The first thing I tested was to make sure that my function returned the proper indexes. Then I wanted to compare run times, here is a small part what my tester looked like

printf(“Test 2 for optimizing STRCSPN \n ———————— \n\n”);
int i = 0;
char * str;
str = (char*)malloc(Size2 + 1);
str[Size2 + 1] = 9;
memset(str, “A”, Size2);
char rej[] = “123456789”;
clock_t start = clock(), diff;
i = STRCSPN_GNU(str, rej);
diff = clock() – start;

int msec = diff * 1000 / CLOCKS_PER_SEC;
printf(“Time taken %d seconds %d milliseconds \n”, msec / 1000, msec % 1000);
printf(“Index found at : %d \n\n”, i);
clock_t start2 = clock(), diff2;
i = STRCSPN_JJ(str, rej);
diff2 = clock() – start2;

int msec2 = diff2 * 1000 / CLOCKS_PER_SEC;
printf(“Time taken %d seconds %d milliseconds \n”, msec2 / 1000, msec2 % 1000);
printf(“Index found at : %d \n\n”, i);

Now the runtime. unfortunately I did not notice that much of improvements in seconds but in milliseconds I did notice some difference. My function is the second one, the first one is the GNU one.


As you can see, there are subtle differences within milliseconds but not in seconds. I was able to optimize this function, but not as fast as I would like to be able to. I need to do more future testing, such as testing this on the two servers that my class has provided for me.


I believe this optimization is efficient enough to upload it. It’s not a strong as an optimization as I thought I could do, but at least it became faster instead of slower!



OSD Lab 8 (Part 2 to lab 7)

This Lab continues off from lab 7, So to understand what this blog is talking about please read my lab 7 blog! Blog lab 7.

Testing Frameworks

In the first part of this lab, we had to pick a testing framework, to make sure the code we write, does exactly what we want it to do so these were the frameworks we could use:

  1. Jest
  2. Mocha
  3. Chai
  4. Sinon
  5. Cucumber

To follow the professor’s instruction, I decided to stick to Jest. It was pretty simple to use, and the code was provided to write a test.

var seneca = require('./seneca');

test('isValid returns true for simple myseneca address', function() {
  var simpleEmail = '';

Now we had to make sure, that the test we write works and passes the Travis CI. Unfourtnenly mine does not, and I’m currently looking at it why it won’t pass.

Later in this lab, we were told to write our own code to make multiple tests.


This lab was very useful since I have not done much code testing. The only time I was ever told to test my code was in java with Junit. So it was nice to learn how to test a diff language.

SPO Project Update

Today I started to write out how I am gonna optimize my function strcspn, atm I’ve written a Tester and wrote my first version of the code. Atm, I’m trying to figure out how to avoid using a nested for loop, but it is a start none the less!

size_t STRCSPN_JJ(const char* str, const char* reject) {
const char *p, *q;

#ifdef __OPTIMIZE__
if (inside_main)

for (p = str; *p; p++) {
for (q = reject; *q; q++) {
if (*p == *q)
return p – str;


return -1;


Atm,. this is a lot slower than the gnu library function but I still feel like I can improve the function!

Here is what the tester I made had to say: entry three is my function


As you can see when we get up to a 900 array my function gets slower, while the other 2 stay as 0 milliseconds, mine went up to 2 milliseconds. So I’m still gonna have to figure out how I can fix this. I am hopeful to find a solution. At least on the upside, my function return the correct iteration!