/dpt/ - Daily Programming Thread

What are you >working on?

Attached: 1527753806839.png (855x1000, 762K)

Other urls found in this thread:

steveperkins.com/migrating-projects-from-github-to-gitlab/
othersite.com/user/repo.git
server-world.info/en/
github.com/mfyuce/GitTorrent
youtube.com/watch?v=9RJTQmK0YPI
docs.opencv.org/2.4/doc/user_guide/ug_mat.html
learnyouahaskell.com/higher-order-functions#curried-functions
twitter.com/AnonBabble

eroge

Quit your job, make video games

Attached: 07.jpg (1000x667, 55K)

Please use a programming related image next time

Previous thread: frustrum culling. currently werking out all the math, i.e. making sure I don't fuck up signs. To think that "standard form" they made me learn in 5th grade is actually meaningful and not just some bullshit. Too bad it took me a couple decades to find a meaning for it. If only they taught me homogeneous coordinates in 5th grade too.

extracts left frustum plane.
vec4 eqn;
for(int i = 0; i

Let's filter out all the brainlets.

Attached: 1528071040963.png (822x850, 48K)

I've seen this before. I think this a question 12 from a putnam.You'll filter out the brainlets for sure, and most of the people with PhDs in math too.

Still working on that Sieve Carving algorithm.

Starting to move the ~300 LOC project to C++.
However, I'm finding it to be *really* slow to use ImageMagick
I have an array of 500 x 500 pixel PNG image, but when I traverse an array and do a small amount of calculations (subtracting six numbers, squaring the differences, and adding them), it takes *much* longer than what I would expect. Should this program take more than two minutes to run?

I'll upload it to Github in a bit, but here's the part that's giving me run-time troubles

double
SeamGrid::getEnergyAt(const int64_t row, const int64_t column)
{
return getXEnergy(row, column) + getYEnergy(row, column);
}

void
SeamGrid::getImageEnergy()
{
const int64_t NROWS = seamImage.rows();
const int64_t NCOLS = seamImage.cols();
for(int row = 0; row < NROWS; row++)
{
for(int col = 0; col < NCOLS; col++)
this->imageEnergy[row][col] = getEnergyAt(row, col);
}
}

double
SeamGrid::getXEnergy(const int64_t row, const int64_t column)
{
int64_t leftX = column-1, rightX = column+1;

//Left OOB, wrap around right
if(! (this->seamImage.inBounds(row, leftX)) )
leftX = this->seamImage.cols() - 1;

//Right OOB, wrap to col # 0
if(! (this->seamImage.inBounds(row, rightX)) )
rightX = 0;

int64_t differenceArr[RGB_LEN];
ImgPixel leftPix = this->seamImage[row][leftX];
ImgPixel rightPix = this->seamImage[row][rightX];

getDeriv(leftPix, rightPix, differenceArr);
return getNorm(differenceArr);
}
/* Similar for Y-direction, but up/down instead of left/right */


Is there anything wrong you guys are seeing that leads to a much larger runtime than expected?
Pic related is runtime for 500 x 500 px image

Attached: Screen Shot 2018-06-04 at 9.58.49 PM.png (488x166, 11K)

>Github
user, did you mean Gitlab?

EZ
I did it in my head.

Attached: 1519522870472.jpg (1024x1186, 218K)

Just checked, and MS acquired github, so yeah, I'll upload it there too

daily reminder that you can overload origin to be multiple urls so you push/pull to places simultaneously

Is it possible to build a Java app that sends files to a directory on a shared server such as Go-Daddy?
If so can someone point me in the right direction?

I don't want to have to manually move the files with an FTP.

What do you mean by manually? Not sure how else you expect to get them transferred

well not simultaneously of course but with one command

>Overload
How do you do this?

steveperkins.com/migrating-projects-from-github-to-gitlab/
this shows two ways, one which gives a different name other than origin, the second which gives two urls to origin

But GitHub is the home for devs :(
Let's live together plz (p.s I will buy gitlab if it gets popular)

I have an app that generates an image. I want to have it save to server when running it on my PC. Instead of saving the file to a local folder and manually transferring it to the server with an FTP.

I did something similar, saving it to a dropbox.

I don't know web shit at all or what terminology to use, so I don't even know if its possible, but it seems like it should be.

your font has less pixels than the one in the commodore 64 and most of the ones in NES games, you disgusting hipster. and you're using int64_t's like such a fucking faggot holy shit. are you really going to throw 2 billion by 2 billion images at your algorithm? that's roughly 15 thousand times the library of congress including its massive fuckin digital catalog. not even the ancient aliens could hope to process such an image. such an image would be large enough to contain millions of copies of the entire earth's surface, down to inch precision. AND, that is merely the upper bound of just using ints for your indices like a normal fucking human.

might wanna consider a compute shader or something for this. GPUs were designed for this. 500 by 500 px is 250,000 calls of getEnergy.

Uploading? lol
Just grab their file transfer API if there is any and use it

You know you dont need to use ftp interactively though? You can have ftp run inside your java program

if you don't want to click anything
git remote set-url ––add origin othersite.com/user/repo.git

but if you use ssh of course it will be different, [email protected]:/repo.git
or if you set in .ssh/config something like
Host hi-there
User git
Hostname github.com
etc

then it's git@hi-there:/repo.git

New programmer here. All I know how to do is go through basic python tutorials and don't know a thing about how it works. It is kinda hard and takes brainpower.

But anyway...how hard would it be to create a program that makes Tony Robbins and other inspirational quotes go off on my computer at random points in the day?

Attached: tony-robbins-getty.jpg (644x430, 36K)

Ok thats cool. Looks like its more of a trick though. Would be nice if git had a feature to push to 3 or more repos if you wanted

yes why can't you

I did not know that. The last time I used an FTP was like 12 years ago.

Thanks, that's actually a good thing to look in to.

If you still want to do it on CPU, the step forward from here is to rewrite it to be cache optimized.

try doing the getX energies of 2 rows at a time, interleaving each of them, i.e. pixel 1 from row 1, pixel 1 from row 3; then performing the getY energy calculation for the pixels in between the rows. that also has the slight advantage of making those branches unnecessary as you know exactly when the odd cases occur.

Yea ftp is just a protocol like http

>Python is kinda hard and takes brainpower

Because you're overloading "origin" when you set that url. So push origin pushes to both locations. I dont think you could overload it twice or more though

I would assume you can, too lazy to test but why would 2 be the magic number?

>steveperkins.com/migrating-projects-from-github-to-gitlab/
>but in git the relationship between a remote name and remote URL is not necessarily one-to-one! Git will quite happily map a remote name to multiple repository URL’s.
Just read through that link again and looks like I was wrong you can use it with multiple urls

yes the urls are just entries in .git/config

Okay... I think I get what you're saying.

My only concern is that when I did this in python, the energy calculation was a *lot* faster, and it was essentially the same algorithm
Does having function calls make the program that much slower?
def getEnergyPixel(image_grid, row, col, NROWS, NCOLS, toPrint = False):
x_mag = getEnergyX(image_grid, row, col, NROWS, NCOLS)
y_mag = getEnergyY(image_grid, row, col, NROWS, NCOLS)
return x_mag + y_mag

def getEnergy(image_grid, toPrint = False):
shape = image_grid.shape
NROWS = shape[0]
NCOLS = shape[1]
energy_Matrix = numpy.zeros((NROWS, NCOLS))

for rInd in range(0, NROWS):
for cInd in range(0, NCOLS):
curr_energy = getEnergyPixel(image_grid, rInd, cInd, NROWS, NCOLS, toPrint)
energy_Matrix[rInd][cInd] = numpy.int64(curr_energy)
return energy_Matrix

def getEnergyX(image_grid, row, col, NROWS, NCOLS):
pixel_arr = []
#Visit each neighboring pixel (x)
for cInd in range(-1, 2):
curr_pixel = [0,0,0]
curr_col = cInd + col

if(inBounds(image_grid,
row, curr_col,
NROWS, NCOLS)):
curr_pixel = image_grid[row][ curr_col ]
elif curr_col < 0 : ##Wrap around to rightmost column
curr_pixel = image_grid[row][ NCOLS + cInd]
elif curr_col >= NCOLS: ##wrap around to beginning
curr_pixel = image_grid[row][ curr_col - NCOLS ]
pixel_arr.append(curr_pixel)
return getNormSquared(pixel_arr)
def getNormSquared(pixel_arr):
pixel_arr = numpy.array(pixel_arr)

grad_vec = []
for ind in range(0, 3):
col = pixel_arr[:,ind]
gradient = abs(numpy.dot(col , [-1, 0, 1]))
grad_vec.append(gradient)
n = numpy.linalg.norm(grad_vec)
return n * n


The main difference in the two is that in here, I store the RGB values in an array vs a function call... Does that make a difference in runtime?

server-world.info/en/

Hey just found this pretty cool site. It has all kinds of short tutorials for configuring different services

Decentralized GutHub NOW github.com/mfyuce/GitTorrent
Decentralized GutHub NOW github.com/mfyuce/GitTorrent
Decentralized GutHub NOW github.com/mfyuce/GitTorrent
Decentralized GutHub NOW github.com/mfyuce/GitTorrent

Attached: what the fuck.jpg (706x480, 96K)

hmm in that case don't bother with my suggestion, thinking about it, not much of an improvement desu.

post your implementation of derivative and norm.

I'm trying to understand the relationship between .c files and headers.
Is there anything wrong with putting all of my #include directives in the headers.h and having #include "headers.h" in each .c file?

I commented it out in the .c files because I expected it to break, but it was fine.

Attached: 1528177717.png (1353x1048, 102K)

>Latest commit 3e1d3b5 on Mar 5, 2017
Its literally nuffins

>you can have a remote with multiple URLs
neat, didn't know this

Will do:
void
SeamGrid::getDeriv(ImgPixel& pLeft, ImgPixel& pRight, int64_t diffArray[RGB_LEN])
{
for(int ind = 0; ind < RGB_LEN; ind++)
diffArray[ind] = getColor(pRight, ind) - getColor(pLeft, ind);
}

double
SeamGrid::getNorm(const int64_t diffArray[RGB_LEN])
{
double retVal = 0.0;
for(int i = 0; i < RGB_LEN; i++)
retVal += (diffArray[i] * diffArray[i]); //square each value of the difference

return retVal;
}

int16_t
SeamGrid::getColor(ImgPixel& pix, int ind)
{
int16_t retval = 0;
switch(ind){
case RED:
retval = pix.quantumRed();
break;
case GREEN:
retval = pix.quantumGreen();
break;
case BLUE:
retval = pix.quantumBlue();
break;
case ALPHA:
retval = pix.quantumAlpha();
break;
}
return retval;
}


Again, I don't really know if anything here really warrants the function taking this long for an 500 x 500 array, but I'm honestly not sure about anything at this point.
Attached is some info as to how I'm going about the general implementation of the algorithm (in case it was needed)

Attached: Screen Shot 2018-06-04 at 10.52.55 PM.png (1368x740, 145K)

The header files are basically just a way for the compiler to understand the interface to some precompiled library. It cant read through already compiled code obviously so it checks the header file instead.

Also dont do that because whoever is reading your code will not understand whats included.

hmm, I still don't really understand unfortunately. Thanks though

Yes. So what exactly is a header file? It's a piece of text that's copied into a c file.
int foo();

is short for
extern int foo();

which is a promise to the compiler that there is an int foo() somewhere. a header file is a list of promises that functions and variables are elsewhere. Header files merely copy paste these promises that said functions and variables exist somewhere.

if you include say math.h in foo.h, and want the functions in foo.h, then including foo.h includes math.h even though you only wanted foo.h's functions, not math.h's functions.

youtube.com/watch?v=9RJTQmK0YPI
sepples but they essentially work the same in C

Whooooa ok huh

this guy is a little much but I'll try watching it again later, thanks!

yeah you just got boned by the long dick of oop lmao no wonder your performance is ass. Mike Actin would have a seizure on the spot. getColor should be replaced with an array access. your image is just a giant array of colors right?
>int64_t diffArray
>int16_t getColor
user...

Excellent showcase of why I tell people to learn C before C++.

>int64_t diffArray
>int16_t getColor
>user...

Oh woops. Just changed them to be both 16_t. (Didn't change performance tho... It's still ass)

Are you saying instead of calling
retval = pix.quantumblue();


I should have it such that when I initialize my array of values, I have them be arrays of length 3, and use array indexing to get the individual color values?

Could you elaborate a bit more? I don' think I'm doing anything *particularly* cringeworthy here, aside from maybe over-decomposing a little in the getColor() method

so I should have in each .c file, #include if I'm using something from that library in that .c file
and I should also #include "headers.h" in every .c file that uses functions which need declaration because they are defined elsewhere
and this is probably why I was able to comment out #include "headers.h" of the bottom left pane, because the definition there served also as the declaration.
any of that wrong? additional thoughts?

You shouldnt have a bunch of includes in your .h though. Include those as you need them in the .c files.

come on anons, there's a blog called "Weekend...." something that talked about writing 3d rendering in C/C++. Does anyone remember?

I see, yes. Actually I was poorly trying to say that's what I should do.
Is putting all the includes in .h poor form because of readability and maintainability, or some reason with regards to the compiler/linker/stuff

Both. Its mostly for readability and design because theyre not required but can lead to complicated circular dependancies

uncompressed images are merely arrays of ints or floats or whatever, so treat them like that. You having an object with boilerplate getters for every pixel is maximum lol and definitely a cause of performance woes.

int width;
int num_colors;
inline uint8_t getSubPixel(uint8_t const * image, int x, int y, int color) {
return image[x * num_colors + y * width + color];
}


also slows down compilation, especially in C++.

Javascript scripts to fix website functionality that I hate.

Is this the write way to go about overriding styles? Seems tedious.

(function () {
var sr_header_area = document.getElementById("sr-header-area");
sr_header_area.style.fontSize = "100%";
sr_header_area.style.height = "20px";
sr_header_area.style.lineHeight = "20px";
sr_header_area.style.textTransform = "lowercase";
sr_header_area.style.fontFamily = "verdana, arial, helvetica, sans-serif";
})();

Okay... I think I'll start using OpenCV, as they store the images as a Matrix
docs.opencv.org/2.4/doc/user_guide/ug_mat.html

I'll post progress!
Also thank you very much! gtg for the moment because I'm helping lift a solar car.

>write way

>––
N-dashes are gay. Use -

just install stylebot, lad.

The style changes are an afterthought. Most of the scripts are changing links, avoiding redesigns, and reverting shitty changes.

C++ is the systems programming language of choice for cute anime girls.

Attached: 1506409575387.jpg (1409x2000, 465K)

Attached: yep.jpg (1280x720, 69K)

>tfw no cute nene programmer gf to make gamus with

I don't get haskell at all.
They said behind the scene all of haskell's functions with multiple arguments are a function that accept single argument, and return another function, so this is possible:
foo :: a -> a -> a
foo = undefined

bar :: a -> a
bar = foo 12

and calling bar 10 is equal to calling foo 12 10
and foo :: a -> a -> a is actually a foo :: a -> (a -> a)

Why is it possible to assign something in the second argument?
for example :
foo' :: a -> a -> a
foo' = undefined

bar' :: a -> a
bar' = (`foo'` 12)

What kind of function bar' is?
How can foo return a function that get assigned to bar without any argument in the first place?

True, and you should use Rust unless you're one of them.

Attached: xge8H9ROodsse8Xki7o7dhGgtrrygKFlZw7NOqpIU_o.png (500x500, 23K)

>unless you're one of them.
Good thing I am.
C++ it is!

It's just an equivalent to
bar' = \x -> foo x 12

Attached: RICK3.png (400x430, 245K)

so bar' isn't actually assigned to a function that returned by foo' as claimed by learnyouahaskell.com/higher-order-functions#curried-functions but instead a new function that wrap foo' ?

Well actually foo doesn't return a function either, it's just a way of thinking about it, the first example is equivalent to
bar = \x -> foo 12 x

To be clear, by "actually" I mean how the code works on the CPU, some may say it's irrelevant and `foo` actually returns a function.

reading the Atom text editor's wikipedia page

install vs code

Why tho? It's basically dead now MS owns GitHub, vs code is much better and more popular.

>get new job
>everything is written in Java
>call everyone brain-dead Pajeet street shitter
>start to rewrite in C
>fizz buzz proof of concept done in only 5 days
>fired for not doing my job
???

Attached: 1502032056584.jpg (680x680, 69K)

>more popular.
Great argument.
Facebook is popular too.

I didn't mean VS Code is better because it's more popular (even though it is better), I'm saying that out of Atom and VS Code MS is more likely to kill the former.

A Java question. lets say i have to program a cage. it should be allowed to put animals in a cage, but only of same type. like any breed of dog or any kind of cat in a cage.

I made a generic class 'Cage' that puts the superclasses in its instance variable Objetcts[].

Question: lets say its possible to put any baby animal together in a cage but no adult animal species.

VSC is the most just works editor without any bullshit.
Electron sucks, but tinkering for a million years with vim sucks even more.

because someone edited it to say Atom supported the feature of "consuming excess RAM" so I was looking through WikiBlame to find this cretin

God damn, these fucking gitlab shills are annoying.
I'm a member of a somewhat large github project, and they just crap up our issue tracker and IRC channel with their shit. This kind of shit has absolutely no bearing on users, and is a decision entirely up to the development team.
They also seem to delete their accounts and immediately leave channels too when you call out their shit even slightly.

They're even more obnoxious than Rust fags.

Attached: 1524271363143.jpg (553x572, 83K)

I really hope the projects I contribute to won't move, but people were discussing it in the chat. Such a hysterical reaction to a mundane stuff like a company buying another company really makes me cringe.

I want to fuck that NEET

would not be difficult

I can now spam hundreds of models in my OpenGL 3D game engine.

Attached: 2018-06-05.png (1280x720, 41K)

How about you spam some antialiasing first?

Show your work.

AA is bloat.

>Not looking like shit is bloat

fuck off microshaft shill

There is actually a war between atom-fag and better-text-editor-fag in Atom's wikipedia page

A naive implementation of AA means rendering the same frame multiple times so it's pretty bloated. I'd rather use supersampling.

Attached: 1528141000414.png (272x367, 82K)

I am guessing it is reddit again.They are probably at it jerking eachother off with muh M$ and muh moving to gitlab.
Big business swallowed another business in a friendly way to get the smaller one more integrated with their shit and push their current propaganda (love open sores). Probably a non issue unless you are linux fanboy who is too scared to look at the kernel code. For me, I benefit from less fragmentation and more integration with clouds like aws which makes my life easier. I like getting this "one button click" feel on centOS

Attached: sighiv2.jpg (1920x1080, 127K)

Use generics.

kill yourself

You can heal your anus back where you belong

I had one of my projects moving to gitlab. It's just the same thing with a different UI. That said, the fragmentation is a real pain, and having some to switch on 2 different websites now is fucking annoying.

t. NEET

it is a great argument. more users means more bug reports, more contributors, more (and better maintained) extensions