1. I have a quick question for those of you experienced with bit-alignment.

I've been using the same algorithm for years:
Code:
`(value + (alignment - (value % alignment)) % alignment)`
Nothing like good old modulo, right? Trying to calculate alignment in your head (or even in a calculator) seems like a daunting task.

However, I always wondered if there was a much simpler way to do this. Using nothing more than the Windows calculator and a theory of mine, I narrowed it down to this:
Code:
`((value + alignment) & -alignment)`
Which is technically a shorter version of this:
Code:
`((value + alignment) & ~(alignment - 1))`
It behaves exactly as expected:
Code:
```> ((3 + 8) & -8)
> (11 & -8)
> (0xB & 0xFFFFFFF8)
>> = 8 (0x3 -> 0x8)```
Code:
```> ((3 + 4) & -4)
> (7 & -4)
> (0x7 & 0xFFFFFFFC)
>> = 4 (0x3 -> 0x4)```
Code:
```> ((123 + 16) & -16)
> (139 & -16)
> (0x8B & 0xFFFFFFF0)
>> = 128 (0x7B -> 0x80)```
Does anyone know if this is a shorter version of the modulo-based algorithm, or is this just similar yet error prone? I'd love to be able to update my code if it's actually correct.

EDIT:
Ah yes, I just realized numbers that are already aligned to the requested alignment will be changed from their original value.

The correct formula should be:
Code:
`((value + (alignment - 1)) & -alignment)`
Still smaller than the modulo version and works just the same. Guess I should've posted this in the other thread since it's not really a question anymore

2. Say I have a triangle that is randomly oriented in 3D space in any particular direction

How can I compute a rotation matrix from it, such that I can use it to transform its own points into "triangle space"?

Since all 3 points of a triangle define a plane, then their coordinates relative to the plane only change on 2 axes. In a nutshell I want to get the local coordinates of points on a triangle relative to its plane.
I'm sure there is a way, but there are also infinite ways that the space could be rotated on the 3rd axis. I'm not sure how I would define which way is up relative to the plane.

3. Say I have a triangle that is randomly oriented in 3D space in any particular direction

How can I compute a rotation matrix from it, such that I can use it to transform its own points into "triangle space"?

Since all 3 points of a triangle define a plane, then their coordinates relative to the plane only change on 2 axes. In a nutshell I want to get the local coordinates of points on a triangle relative to its plane.
I'm sure there is a way, but there are also infinite ways that the space could be rotated on the 3rd axis. I'm not sure how I would define which way is up relative to the plane.
Sounds like this is what you need right?
https://gamedev.stackexchange.com/qu...angent-vectors

A triangle can only have two normals, figuring out which way normal is correct can be done by following the winding order of a mesh. If you have just a triangle, either direction could be valid, whereas with a mesh normals facing inwards are usually wrong.
But if your triangle normal is facing the wrong way, you can just reverse list of vertices it consists of and it'll point in the other direction.

4. Sounds like this is what you need right?
https://gamedev.stackexchange.com/qu...angent-vectors

A triangle can only have two normals, figuring out which way normal is correct can be done by following the winding order of a mesh. If you have just a triangle, either direction could be valid, whereas with a mesh normals facing inwards are usually wrong.
But if your triangle normal is facing the wrong way, you can just reverse list of vertices it consists of and it'll point in the other direction.
That's in a similar vein to what I need.

I'm trying to generate UV coordinates from my geometry. I've generated a convex hull from a point cloud, and I'm looking for ways to uv wrap my triangles. If I could even get something as basic as each triangle wrapped between 0-1 that would be great, because then I can actually do some math in tangent space.

5. I'm trying to prank some friends by running a background application which would display some image over their screen from time to time (on top of all open tabs, possibly animated image). I'm thinking C# forms would be a good job for this, though I've never looked into that. Maybe anyone has some experience with this and could direct me to some resources?

6. Theoretical question:

Could I run a script of some sort (JS script on Node.js server) that would crawl through website and convert every single image on it into hash string (say using blockhash-js) so even if image is different size - hash would be somewhat similar (can be easily compared) and then store that in database.

So that later if I want to upload my own image - it would get converted into hash string as well and compare hash value of my uploaded image and those stored in DB already and that way see if that image ever existed on server?

Would that kind of reverse image search work? (Talking about 4000-5000 images on small website).

7. Anyone who has recommendations for documentation? - I mean like, of course editor works - but documentation of API's etc?
I'm especially interested in solutions that can be self-hosted.

8. So I'm really bad with Apache and all that fun stuff. I'm trying to use WSGI to host two flask apps on an Ubuntu server. So far I've followed a tutorial to set it up but I don't think I'm getting any results.

Here is my .wsgi for the first app:

Code:
```#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Simon/")

from Simon import simon as application
application.secret_key = ...
activate_this = '/var/www/Simon/Simon/bin/activate.py'
execfile(activate_this, dict(__file__=activate_this))```
It's supposed to run inside a virtual env obviously.

Next is my app's .conf in /etc/apache2/sites-available

Code:
```<VirtualHost *:80>
ServerName glencoverx.com
WSGIScriptAlias / /var/www/Simon/Simon.wsgi
<Directory /var/www/Simon>
Require all granted
</Directory>
Alias /static /var/www/Simon/static
<Directory /var/www/Simon/static/>
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>```
Upon running curl, I just get a 500 error. I have no idea what I'm doing.

9. How do save files work for big games like Half life 2? How do they keep the exact moment in a save file? Do they just dump the memory?
Not sure how Source works but Half-Life's looks simple enough (or at least the game code part of it does).
I assume when you hit save the engine iterates through all entities and you can see in the game code each entity has some configuration data that returns details about the state of each entity. When you reload a game the each entity is recreated and its internal state is set to what was saved from the game code. That way each entity ends up in the same spot, with the same health, at the same point in the same animation etc.

Anyone who has recommendations for documentation? - I mean like, of course editor works - but documentation of API's etc?
I'm especially interested in solutions that can be self-hosted.
https://swagger.io/ for documenting APIs. You may want to use a library to generate it though.

So I'm really bad with Apache and all that fun stuff. I'm trying to use WSGI to host two flask apps on an Ubuntu server. So far I've followed a tutorial to set it up but I don't think I'm getting any results.

Here is my .wsgi for the first app:

Code:
```#!/usr/bin/python
import sys
import logging
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0,"/var/www/Simon/")

from Simon import simon as application
application.secret_key = ...
activate_this = '/var/www/Simon/Simon/bin/activate.py'
execfile(activate_this, dict(__file__=activate_this))```
It's supposed to run inside a virtual env obviously.

Next is my app's .conf in /etc/apache2/sites-available

Code:
```<VirtualHost *:80>
ServerName glencoverx.com
WSGIScriptAlias / /var/www/Simon/Simon.wsgi
<Directory /var/www/Simon>
Require all granted
</Directory>
Alias /static /var/www/Simon/static
<Directory /var/www/Simon/static/>
Require all granted
</Directory>
ErrorLog \${APACHE_LOG_DIR}/error.log
LogLevel warn
CustomLog \${APACHE_LOG_DIR}/access.log combined
</VirtualHost>```
Upon running curl, I just get a 500 error. I have no idea what I'm doing.
What do the Apache error logs say?

10. Open-Source/github question.
What would be a way of having assets I paid for but still having an open source repository?
Maybe open source the code but not the whole repo?

11. Open-Source/github question.
What would be a way of having assets I paid for but still having an open source repository?
Maybe open source the code but not the whole repo?
You could use a .gitnore file to ignore the paid for stuff, but still keep the folder names so people know what to purchase
Winner x 1 (list)

12. Not sure how Source works but Half-Life's looks simple enough (or at least the game code part of it does).
I assume when you hit save the engine iterates through all entities and you can see in the game code each entity has some configuration data that returns details about the state of each entity. When you reload a game the each entity is recreated and its internal state is set to what was saved from the game code. That way each entity ends up in the same spot, with the same health, at the same point in the same animation etc.

https://swagger.io/ for documenting APIs. You may want to use a library to generate it though.

What do the Apache error logs say?
Nothing actually. Just a warning about using Python 2.7.12 instead of 2.7.11.

13. So I finished setting up the domain, and now I'm just getting the Apache test page when I go to the domain.

14. Open-Source/github question.
What would be a way of having assets I paid for but still having an open source repository?
Maybe open source the code but not the whole repo?
Does Github let you have a private sub-repo in a public repo? That might be the easiest thing to do.
Otherwise I think some some version control systems (like Perforce?) let you export sub-directories as a Git repo.

Nothing actually. Just a warning about using Python 2.7.12 instead of 2.7.11.
Hm, that doesn't sound right - maybe turn up the logging settings so everything gets logged. Is there anything at all in error.log?
Also, if you're getting the Apache test page is your config file in the sites-enabled directory or whatever?

15. Does Github let you have a private sub-repo in a public repo? That might be the easiest thing to do.
Otherwise I think some some version control systems (like Perforce?) let you export sub-directories as a Git repo.

Hm, that doesn't sound right - maybe turn up the logging settings so everything gets logged. Is there anything at all in error.log?
Also, if you're getting the Apache test page is your config file in the sites-enabled directory or whatever?
False alarm on the test page. I entered one digit of the IP wrong when I changed the A record of my domain and it ended up pointing to the Apache test page of a porn site.

Edited:

We're back to the 500 error though. Even setting the Flask instance to debug doesn't bring up the debug page. I have no idea how to tell if it's running the WSGI and starting the virtual env.

Edited:

Here's the Apache error.log with logging set to info.

Code:
```[Sat Aug 12 22:31:15.250908 2017] [wsgi:warn] [pid 2430:tid 140371370882944] mod_wsgi: Compiled for Python/2.7.11.
[Sat Aug 12 22:31:15.250965 2017] [wsgi:warn] [pid 2430:tid 140371370882944] mod_wsgi: Runtime using Python/2.7.12.
[Sat Aug 12 22:31:15.251487 2017] [mpm_event:notice] [pid 2430:tid 140371370882944] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi\$
[Sat Aug 12 22:31:15.251505 2017] [core:notice] [pid 2430:tid 140371370882944] AH00094: Command line: '/usr/sbin/apache2'```

16. What tutorial are you following?
It may be worth getting the right version of Python/mod_wsgi anyway - it's only a minor version change but something important may well have changed.

17. What is the opinion about being older as a programmer in industry? Recently I've considered becoming a CS, but my parents are very against it. They claim that as a CS, while you're 20-30 you can happily work long hours for good pay, but as you age and have other life priorities like family you'll want to settle down, and that as you get older you'll have a much more difficult time keeping up with new technologies when compared to fresh college graduates.

They claim that if I continue to do engineering (electrical) that I'll have better job security and that my age/experience will actually help me when compared to computer science.

I don't know, I've read articles about age discrimination and stuff, and how often times older applicants will want to hide the years as not to reveal their age. At the same time, people claim that the median age of companies like Google being relatively young (only 29 when compared to the average of 42 across all industries/professions) is just because CS has been growing recently, and eventually this number will rise as the workforce grows older.

I'm not looking to argue with anyone, or prove anyone wrong. I just want people's opinions on this matter.

18. I tried using clang (on Windows with VS2015 as part of the LLVM-vs2014 platform toolset) to compile my C++ program which uses some boost header-only features (property tree), but it seems to be spewing out a shitload of errors about boost, hundreds of them. This is weird because the default VS2015 compiler had no problems compiling at all. Did I do something wrong? Nothing urgent since I can still use the default VS2015 compiler, but I would really rather use clang.

19. What is the opinion about being older as a programmer in industry? Recently I've considered becoming a CS, but my parents are very against it.
I'd say go for whatever you think is best, and not let anyone else tell you what's good or bad. The worst thing you can do is give in to peer pressure (friends, family, etc) because it's not what you wanted to do, but rather what other people told you to do.

Just go with your gut instinct, that's all I can say.
Agree x 1 (list)

20. What is the opinion about being older as a programmer in industry? Recently I've considered becoming a CS, but my parents are very against it. They claim that as a CS, while you're 20-30 you can happily work long hours for good pay, but as you age and have other life priorities like family you'll want to settle down, and that as you get older you'll have a much more difficult time keeping up with new technologies when compared to fresh college graduates.

They claim that if I continue to do engineering (electrical) that I'll have better job security and that my age/experience will actually help me when compared to computer science.

I don't know, I've read articles about age discrimination and stuff, and how often times older applicants will want to hide the years as not to reveal their age. At the same time, people claim that the median age of companies like Google being relatively young (only 29 when compared to the average of 42 across all industries/professions) is just because CS has been growing recently, and eventually this number will rise as the workforce grows older.

I'm not looking to argue with anyone, or prove anyone wrong. I just want people's opinions on this matter.
I work with/have worked with programmers in their 40s and 50s and they have no issues as far as I can see. They bring a lot experience to the table; I've got no issue working with them and they're probably on better money because of their experience.
I would absolutely agree that the median age thing is just because the industry is really growing right now too.

21. What is the opinion about being older as a programmer in industry? Recently I've considered becoming a CS, but my parents are very against it. They claim that as a CS, while you're 20-30 you can happily work long hours for good pay, but as you age and have other life priorities like family you'll want to settle down, and that as you get older you'll have a much more difficult time keeping up with new technologies when compared to fresh college graduates.

They claim that if I continue to do engineering (electrical) that I'll have better job security and that my age/experience will actually help me when compared to computer science.

I don't know, I've read articles about age discrimination and stuff, and how often times older applicants will want to hide the years as not to reveal their age. At the same time, people claim that the median age of companies like Google being relatively young (only 29 when compared to the average of 42 across all industries/professions) is just because CS has been growing recently, and eventually this number will rise as the workforce grows older.

I'm not looking to argue with anyone, or prove anyone wrong. I just want people's opinions on this matter.
It really depends. I would say some CS people have a hard time following new trends, but I think it's a person thing, not an age thing. In my company and similar companies, the older you are, the higher your abstraction level. So you're managing in some way. Architecture, team, accounts.

22. What is the opinion about being older as a programmer in industry? Recently I've considered becoming a CS, but my parents are very against it. They claim that as a CS, while you're 20-30 you can happily work long hours for good pay, but as you age and have other life priorities like family you'll want to settle down, and that as you get older you'll have a much more difficult time keeping up with new technologies when compared to fresh college graduates.

They claim that if I continue to do engineering (electrical) that I'll have better job security and that my age/experience will actually help me when compared to computer science.

I don't know, I've read articles about age discrimination and stuff, and how often times older applicants will want to hide the years as not to reveal their age. At the same time, people claim that the median age of companies like Google being relatively young (only 29 when compared to the average of 42 across all industries/professions) is just because CS has been growing recently, and eventually this number will rise as the workforce grows older.

I'm not looking to argue with anyone, or prove anyone wrong. I just want people's opinions on this matter.
I don't know if this really helps, but try to make the most informed decision possible that you can live with.
I had to grind my way through my first degree because I kinda lied to myself into wanting to do it. It was a grind because as time went on I liked it less and less. Now 6 years after starting, I'm starting over in Applied Computer Science.

23. They claim that if I continue to do engineering (electrical) that I'll have better job security and that my age/experience will actually help me when compared to computer science.
I believe this is actually still true at the moment but it's a minor issue overall and from what I know the demand for people in the field of computer science is growing at a very quick pace. Demand for electrical engineers is growing too but it's at a slower pace. So I'd personally just go for the one you enjoy more.

24. So I've narrowed the error a little. It's resulting from the WSGI script. I've followed a whole bunch of tutorials all resulting in a similar looking script.

Here's the current state of /var/log/apache2/error.log

Code:
```[Tue Aug 15 18:29:51.988712 2017] [wsgi:warn] [pid 4407:tid 139794006046592] mod_wsgi: Compiled for Python/2.7.11.
[Tue Aug 15 18:29:51.988719 2017] [wsgi:warn] [pid 4407:tid 139794006046592] mod_wsgi: Runtime using Python/2.7.12.
[Tue Aug 15 18:29:51.989018 2017] [mpm_event:notice] [pid 4407:tid 139794006046592] AH00489: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g mod_wsgi/4.3.0 Python/2.7.12 configured -- resuming normal operations
[Tue Aug 15 18:29:51.989033 2017] [core:notice] [pid 4407:tid 139794006046592] AH00094: Command line: '/usr/sbin/apache2'
[Tue Aug 15 18:29:51.998541 2017] [wsgi:info] [pid 31452:tid 139794006046592] mod_wsgi (pid=31452): Attach interpreter ''.
[Tue Aug 15 18:29:55.392230 2017] [ssl:info] [pid 31454:tid 139793895741184]  AH01964: Connection to child 64 established (server xxxx.com:443)
[Tue Aug 15 18:29:55.393068 2017] [ssl:info] [pid 31453:tid 139793769936640]  AH01964: Connection to child 198 established (server xxxx.com:443)
[Tue Aug 15 18:29:55.394889 2017] [ssl:info] [pid 31454:tid 139793887348480]  AH01964: Connection to child 65 established (server xxxxx.com:443)
[Tue Aug 15 18:29:55.470346 2017] [wsgi:info] [pid 31452:tid 139793853777664] mod_wsgi (pid=31452): Create interpreter 'xxxx.com|'.
[Tue Aug 15 18:29:55.471281 2017] [wsgi:info] [pid 31452:tid 139793853777664]  mod_wsgi (pid=31452, process='Simon', application='xxxxx.com|'): Loading WSGI script '/var/www/Simon/Simon.wsgi'.
[Tue Aug 15 18:29:55.474876 2017] [wsgi:error] [pid 31452:tid 139793853777664]  mod_wsgi (pid=31452): Target WSGI script '/var/www/Simon/Simon.wsgi' cannot be loaded as Python module.
[Tue Aug 15 18:29:55.474889 2017] [wsgi:error] [pid 31452:tid 139793853777664]  mod_wsgi (pid=31452): Exception occurred processing WSGI script '/var/www/Simon/Simon.wsgi'.
[Tue Aug 15 18:29:55.474904 2017] [wsgi:error] [pid 31452:tid 139793853777664]  Traceback (most recent call last):
[Tue Aug 15 18:29:55.474925 2017] [wsgi:error] [pid 31452:tid 139793853777664]    File "/var/www/Simon/Simon.wsgi", line 10, in <module>
[Tue Aug 15 18:29:55.474968 2017] [wsgi:error] [pid 31452:tid 139793853777664]      from Simon import simon as application
[Tue Aug 15 18:29:55.474984 2017] [wsgi:error] [pid 31452:tid 139793853777664]  ImportError: No module named Simon
[Tue Aug 15 18:29:55.863019 2017] [wsgi:info] [pid 31452:tid 139793887348480]   mod_wsgi (pid=31452, process='Simon', application='xxxxx.com|'): Loading WSGI script '/var/www/Simon/Simon.wsgi'.
[Tue Aug 15 18:29:55.863855 2017] [wsgi:error] [pid 31452:tid 139793887348480]  mod_wsgi (pid=31452): Target WSGI script '/var/www/Simon/Simon.wsgi' cannot be loaded as Python module.
[Tue Aug 15 18:29:55.863870 2017] [wsgi:error] [pid 31452:tid 139793887348480]  mod_wsgi (pid=31452): Exception occurred processing WSGI script '/var/www/Simon/Simon.wsgi'.
[Tue Aug 15 18:29:55.863894 2017] [wsgi:error] [pid 31452:tid 139793887348480] Traceback (most recent call last):
[Tue Aug 15 18:29:55.863917 2017] [wsgi:error] [pid 31452:tid 139793887348480]  File "/var/www/Simon/Simon.wsgi", line 10, in <module>
[Tue Aug 15 18:29:55.863940 2017] [wsgi:error] [pid 31452:tid 139793887348480]    from Simon import simon as application
[Tue Aug 15 18:29:55.863957 2017] [wsgi:error] [pid 31452:tid 139793887348480] ImportError: No module named Simon
[Tue Aug 15 18:34:55.529604 2017] [ssl:info] [pid 31454:tid 139793895741184] (70007)The timeout specified has expired: [client 100.2.224.37:62891] AH01991: SSL input filter read failed.```
The apps codename is Simon obviously. It's supposed to be calling the instance of simon = Flask(__name__) from Simon.py, the main app script.

Edited:

This runs perfectly in PyCharm, no import error so I don't really know what to try next.

25. I'm not sure how Python's package resolution all works but maybe it's runnig the .wsgi file from a directory that doesn't contain your package.

26. Now is suddenly not ruining the script at all. I'm considering dumping Apache.

27. I've never used Apache for personal projects but I get the impression it requires a bit of tuning if you're not doing something simple.
I have used nginx and uWSGI before though and the only way I got it working was with a tutorial.

28. So If I were to make a simple Windows application which I would use for creating .md files for my blog with some extra meta data and likely. Which library or framework would you guys recommend for C#?

29. When I compile a C++ project with Visual Studio I end up with a projectname.pdb and a vc141.pdb - I understand I should hang on to the .pdb file for a tagged release so that I can debug crashes regardless of code or compiler changes but I haven't been able to find the use of or reason for the existence of vc141.pdb - I assume that projectname.pdb is the bulk of the information as it is bigger but vc141.pdb seems like it could contain toolset-specific stuff (I think I'm using toolset v141) but I'm not sure - anyone know for sure?

30. So I ditched Apache altogether and went with Nginx and Gunicorn. This is the closest I've gotten to getting this shit to work.

As of right now, the app launches properly in the background using Supervisor. My current issue is Nginx not passing any connections (http or https; I have SSL.) to Gunicorn. I'm simply stuck with the "Welcome to Nginx" page even though I've deleted the default conf from /etc/nginx/sites-available and sites-enabled.

This is what my app's conf looks like:
Code:
```upstream simon_server {
server unix:/var/www/Simon/simon.sock fail_timeout=0;
}

server {

listen   443 ssl;
server_name glencoverx.com;

client_max_body_size 4G;

access_log /var/www/Simon/logs/nginx-access.log;
error_log /var/www/Simon/logs/nginx-error.log;

location /static/ {
alias   /var/www/Simon/static/;
}

location / {
proxy_redirect off;
}

ssl_certificate /etc/letsencrypt/live/glencoverx.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/glencoverx.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

if (\$scheme != "https") {
return 301 https://\$host\$request_uri;
}
}```
The sock is present in that directory and is created by Gunicorn upon start. It's just that Nginx won't touch it.

31. Does the nginx process have the right permissions to use the .sock file?
Not sure why you'd be seeing the Welcome to nginx page (I assume you've started nginx) - I think nginx has its own log files separate to what you configure - possibly there's something in those that will help?

edit: also, that 301 may never occur - it would need to be in a separate server block listening on port 80 I think?

32. Does the nginx process have the right permissions to use the .sock file?
Not sure why you'd be seeing the Welcome to nginx page (I assume you've started nginx) - I think nginx has its own log files separate to what you configure - possibly there's something in those that will help?

edit: also, that 301 may never occur - it would need to be in a separate server block listening on port 80 I think?
There's nothing in the nginx logs saying that it can't access the sock. What's weird is that I've deleted the conf that usually shows the welcome page. I have no idea where it's going to even get the html for the page. HTTPS is working fine as far as I can tell. Even if I was accessing as http, it's redirecting to https anyway.