[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 34
File: 1458188416314.jpg (54 KB, 465x604) Image search: [Google]
1458188416314.jpg
54 KB, 465x604
Previous thread: >>53736758

What are you working on, /g/?
>>
first for SFML
>>
fake thread, no anime image
>>
How do you guys feel about programming?
>>
There's definitely no way to add behaviour other than a straight memcpy to moves in Rust, right? I asked SO about a week or so ago (I gave a basic C++ example that I couldn't figure out how to replicate and asked how it could be done) and never got a satisfactory reply.
>>
Hey guys I just had a crazy idea while thinking of something to code... This would probably have a lot of benefit to many people including myself. Although I'm not very experienced/knowledgeable but I want to invest a lot of time for fun.

Anyway my idea is a program(probably made in python because I'm not sure how to webscrape using other languages) that would visit Grocery Stores to grab their weekly deals and either output them or save them in a LibreOffice(tm) spreadsheet. - It might even need to utilize some image recognition for image-only flyers from some grocers.

Then it would do some calculation and show the optimal Price/Nutrition/Calorie value for each grocery store, for each week.

How difficult would this be to create? Each part seems simple enough but altogether it seems a little hefty. Should I bother trying to do this or would it just end up as an unusable meme?
>>
>please, tell me WHAT exactly that java struggles with when it comes to generics
I'm not him, I haven't used Java enough to find anything that bad about its generics (other than the obvious shortcoming that they work on type erasure and thus don't work with primitive types).

>and please, tell me a valid use-case for generics, preferably a real one that you can see in a respected project on github
This is like asking me for a valid use-case for using function parameters. Generics are EVERYWHERE, especially though with data structures and their algorithms because the whole point of data structures is that you don't have to rewrite them for each contained type. You write one list and you can use it to hold integers, strings, points, anything. You can write one sorting algorithm and as long as you can define an order over a type, you can use it with a list or whatever of that type.
>>
i could have sworn there was a reply ITT about neanderthal genes and the zionist agenda... am i dreaming?
>>
>>53741450
How do you think you would do it? Have you built anything similar before?
>>
>>53741484
>something to code
>have you built anything before?

Fixed it for you
>>
File: 1388287475548.png (19 KB, 560x560) Image search: [Google]
1388287475548.png
19 KB, 560x560
>get simple error in program
>spend almost two days trying to fix problem
>cant find any fix
>copy entire program 1:1 into a new project
>it works perfectly

i dont like this meme
>>
>>53741471
>Generics are EVERYWHERE
not at all. maybe in your CRUDshit

please, show me an example in the android codebase or whatever

>You can write one sorting algorithm
CRUDfag confirmed. programming isn't only about sorting things
>You write one list
for fuck's sake anon. and it's built in to java's standard library
>>
>>53741484
>How do you think you would do it? Have you built anything similar before?

No I have not, I am kind of a noob who just learns the basics of different programming languages/reads a couple books about a topic and then gets bored and abandons it completely.

Or I would generally start making something then give up half way through because I realized my way of doing it is inefficient and someone has already implemented the idea much better than I could, and thus I would be re-inventing their wheel.
>>
>>53741500
Language?
>>
>>53741324
It's fun, if its making some useful for yourself or doing challenges online
>>
>>53741517
c++
>>
>>53741514
delete this, and go to bed, you have school 2morrow.
>>
go doesn't have generics, i wonder how it even exists at all since 99% of programming is generics and muh dater strugers
>>
>>53741514
Well, you can choose anything if you spend enough time on it. If you get stuck, Google is your best friend. Go for it, but do yourself a favor and don't give up this time.
>>
>>53741524
i-i-i just want to make something cool, anon
>>
>>53741522
>babbys first compiler flags

This is your chance to learn a real language anon
>>
i fucking hate arrogant CRUDfags you fucking suck

generics are mostly fucking useless for "real" programming, it's not something you should use on a day-to-day basis
>>
>>53741539
pls explain

i dont think i have ever been that frustrated in my life
>>
>>53741522
No experience with that. Can't help.
>>
>>53741561
What was the error
>>
>>53741555
generics/templates are great!
abstraction on a miniscule level is however often overblown.
>>
>>53741538
>>53741484
>Price/Nutrition/Calorie value
>LibreOffice(tm)

You have other issues to worry about, sounds like a boring and unfeasible app, but don't me stop you...
>>
>>53741535
But is it a good idea? Should I bother with it?

It would be screwed if the website changed its layout, and I'm guessing there's probably some sites that already do this similar to camelcamelcamel but for grocery stores.
>>
>>53741509
You asked for a valid use case and I gave you one.

>>53741526
Go is not a useful language.

>>53741555
You should use generics whenever you can. No reason not to in almost all cases.

The only time I can see generics being not useful at all is if 100% of the code you are writing is literally just steps for the computer to execute, e.g. in a driver or embedded control program.

Everything else involves generic data structures and algorithms. Either that or a metric tonne of code duplication. I'd like to hear why you disagree.
>>
>>53741608
Let me consult my latest animal entrails, then I'll get back to you on that.
>>
File: caver.jpg (193 KB, 1280x720) Image search: [Google]
caver.jpg
193 KB, 1280x720
writing a twitter bot in python for retrieving files from the internet, uploading them, and tweeting the url to people

new to coding and I don't have a complete understanding of OOP, inheritance, etc. yet

Can anyone sort of tl;dr the basic structure of this kind of program? Do I have a parent class for the bot itself and then a class for each file downloader source, like one which pulls files from irc, one for a website via http, etc., each of which inherits from some main file getter class? That's the best that I can think of right now

Also, where do I put functions that don't need to belong to an object, like a function that unzips a file?
>>
Has anybody on here played tis-100?

I enjoyed spacechem, would I enjoy it?
>>
>>53741619
>You asked for a valid use case and I gave you one.
no you didn't

>Go is not a useful language.
it's redundant but it's a fully functioning language

>You should use generics whenever you can. No reason not to in almost all cases.
ok CRUDfag

>
The only time I can see generics being not useful at all is if 100% of the code you are writing is literally just steps for the computer to execute, e.g. in a driver or embedded control program.
or any non-CRUDshit

>Everything else involves generic data structures and algorithms. Either that or a metric tonne of code duplication. I'd like to hear why you disagree.
you're only seeing it from your shitty CRUD perspective
>>
>>53741608
I imagine that many stores have an api as well.
>>
>>53741295
Why what you making? Super flimsy media library
>>
>>53741648
I'd like to hear why you think my use case isn't valid.
>>
>>53741585
it was a undeclared identifier error
>>
>>53741658
which use case are you even talking about? ShitDecorator? ArrayList<int>?

why not real-world examples such as in the android codebase or whatever
>>
>>53741636
Lrn2python. Seriously, those are basic questions that easily be answered by a quick look at the docs. Do you know what __init__.py does?
>>
>>53741644
>Has anybody on here played tis-100?
I played it for a couple hours but then I realized it was no more fun than Leetcode and way more useless. Why spend your time coding for a deliberately hard-to-use made-up architecture when you could be getting better at real programming?
>>
>>53741674
The docs seem to cover these things in general, and I kind of understand these topics but I've never coded anything myself before. I'm just wondering how it's supposed to be done as opposed to my shitty interpretation. As far as I'm concerned I can do it all without using classes whatsoever, so I just want to know how people ITT might do it

just trying to learn my man
>>
>>53741652
GB emu for fun

Easy shit, op code implementation gets repetitive.
>>
for a "generic" sorting CRUDshitter you need some way to determine the order of the elements, so you implement an INTERFACE like Comparable so you can determine the order! because you sure as hell can't just take any random object and determine a meaningful "order"! and what's with CRUDfags and their obsession with sorting anyway!
>>
>>53741524
>>53741588
>>53741624
S-sorry guys...

I guess it was a stupid idea after all. I never come up with any smart or feasible ideas.
>>
>>53741671
They used List in here.
https://github.com/android/platform_frameworks_base/blob/master/core/java/android/accessibilityservice/AccessibilityService.java

>>53741704
Using an interface doesn't preclude using generics. I don't even know why you're getting so worked up over this.
>>
>>53741709
I bet you would look qt in a dress.
>>
>>53741669
Most likely you were missing a library or header
>>
>>53741714
>They used List in here.
ooh la di fucking da
>>
>>53741735
If they didn't use a generic list they would have had to implement their own list just to store whatever type of thing they wanted to put in a list.
>>
>>53741686
>Why spend your time coding for a deliberately hard-to-use made-up architecture when you could be getting better at real programming?
for "fun"

>no more fun than Leetcode
although this makes me rethink buying it. I still might pick it up though, it's only $7.

Would you say it's approximately the same amount of fun, or less fun?

Also, does the story come into account when you're saying this?
>>
>>53741709
Keep hanging around here. You'll think of something while getting harassed for not knowing anything. That, btw, is the best way to learn.
>>
>>53741758
where's your great idea anon?
>>
>>53741754
and where's the problem? how did java "fail" at the task? and how can generics be useful beyond simple data structures, most of which are already built in to the standard library?
>>
>>53741776
>how did java "fail" at the task?
I already said that I'm a different guy.

>and how can generics be useful beyond simple data structures, most of which are already built in to the standard library?
They are useful anywhere you write code that in some way isn't dependent on a type of something in it. Generics are like type parameters in the same sense that functions have value parameters.
>>
>>53741792
fair enough
>>
>>53741774
Webscraper that finds the optimal diet for trap-mode aesthetics
>>
>>53741809
That IS a case where Java generics fall short, because for example in C++ you have template specialization which is analogous to switch, just over types instead of values. Haskell can do this too with type classes.

Then you have dependently-typed "meme" languages where type parameters are just normal parameters and types are just values.
>>
File: catface.jpg (57 KB, 500x581) Image search: [Google]
catface.jpg
57 KB, 500x581
>>53741822
HOLY FUCK, this will be a gold-mine! Let's get started!
>>
>>53741809
>>53741839
This kind of thing is basically just for optimizations for generics (such as packing a bool vector into bits) or using templates for overloading, anyways.
>>
any idea why this line is asking me to cast request.setEntity with (HttpResponse)? This is code literally pulled from M$ and I pulled down the apache libraries they suggested. Ive never worked with these HttpGet or request before.

import java.net.URI;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;

public class HaloMainTest
{

public static void main( String[] args )
{
HttpClient httpclient = HttpClients.createDefault();

try
{
URIBuilder builder = new URIBuilder(
"https://www.haloapi.com/stats/{title}/servicerecords/warzone?players={players}" );

URI uri = builder.build();
HttpGet request = new HttpGet( uri );

// Request body
StringEntity reqEntity = new StringEntity( "{body}" );
request.setEntity( reqEntity ); //The method setEntity(StringEntity) is undefined for the type HttpGet <--- THIS LINE

HttpResponse response = httpclient.execute( request );
HttpEntity entity = response.getEntity();

if ( entity != null )
{
System.out.println( EntityUtils.toString( entity ) );
}
} catch ( Exception e )
{
System.out.println( e.getMessage() );
}
}

}
>>
Has anyone here actually worked with TDD, or even heard of someone who used TDD at least once outside of college?

Every month i see an arcticle about TDD but nobody uses it, it's weird as fuck.
>>
>>53742046
TDD is a retarded meme for sub-105 IQ pseudonormies
>>
Are there any in-depth tests to evaluate one's competence as a programmer? i.e 1 being you can write hello world, and 10 being you can disassemble an .exe by hand and then translate it into a higher level language.

>inb4 fizzbuzz
>>
>>53741990
request is type HttpGet which has no setEntity method http://hc.apache.org/httpcomponents-client-ga/httpclient/apidocs/org/apache/http/client/methods/HttpGet.html
>>
>>53742179
>being you can disassemble an .exe by hand and then translate it into a higher level language
That doesn't take a huge amount of skill. It's just ridiculously tedious.

To answer your question: no.
>>
spent 2 hours trying to debug until i found out i used object.isBoolean instead of the custom isBoolean(object) that i made to look through the array for the object. i'm 90% sure this assignment was just made in the convoluted way that we had to make it in because she wanted us to learn unit testing. but fuck unit testing
>>
File: CirnoQuestionHard.png (671 KB, 1000x1000) Image search: [Google]
CirnoQuestionHard.png
671 KB, 1000x1000
I could really use help understanding Big O Notation.
Anyone got a VERY explicit link to help me get it?
For instance, this thing in my book asks which is a higher order O(log (log n)) or O(log* n)?

And above it says O(log* n) is to log n what log2 n is to n/2.
I mean, I get log2 to n/2, because the algorithm halves repeatedly. But how can you log it? So, log* n is when you log(log(log(log))), whereas log2 n is when you n/2/2/2/2?

So, what the hell is log(log n)?
I'm not bad at very explicit math, but I don't really get some of these relations. Anyone got a good site or description of how the orders are actually related?

For note: if you can find a way to explain it to an autist, that's probably best. I probably have mild Asperger's or something, because high levels of abstraction confuse the shit outta me.

As a side note, can someone explain to me how Towers of Hanoi can be solved without comparisons? The book I'm reading somehow did it, but I really can't understand the recursive algorithm. It ONLY passed peg numbers. There was NO comparison between shape sizes.
>>
>>53742179
1. hello world
2. fizzbuzz
3-9. idk
10. average 2 ints
11. safely getchar
>>
>>53742299
Big O notation describes the growth rate at for the time an algorithm takes depending on the number of objects.

O(1) takes the same time regardless of the elements.

O(n) increases linear to the elements. An example would be a for loop

O(n^2) increases quadratically. An example would be 2 nested for loops.

O(2^n) increases exponentially, so whenever an element is added, the time doubles.

O(n log n) is slightly longer than O(n) but much faster than O(n^2)

O(log n) is slow for a small number of elements, but increases less and less with more elements added.
>>
>>53742256
basically think of this
>>
>>53742521
Thanks for the (You), but I think that's the wrong post.
>>
File: awooo.jpg (77 KB, 720x556) Image search: [Google]
awooo.jpg
77 KB, 720x556
>>53742299
>>
>>53742299
So I don't really get what you mean by O(log* n), but if you have problem imagining what log(log n) is, maybe try to think about it this way:
The opposite of logarithms are exponentials.
2^2 = 4
2^10 = 1024
2^2^2 = 2^4 = 16
2^2^10 = 2^1024
My point is it gets faster bigger.
So log(log n) gets slower bigger and log(log(log n)) gets even slower bigger.
>>
>>53742179
you have the right idea.

learn what every programming construct you use is at the hardware level. learn how it is compiled. how it is optimized even.

that's a huge amount of education, but basically at that point there's absolutely no problem that can stop you other than typos.
>>
>>53741608
Stop being a miserable fuck and do it. Jesus.
>>
>>53742369
Ok, that much I was able to get, except O(n log n)

What exactly is that type of relationship though?
For each element, it increases by 1 PLUS the log of the elements?

So... the whole O(log(log n)) means what exactly? And what is O(log* n)?
It literally uses the notation "log* n"
Apparently, it goes up like:
N - >log* n
2 -> 1
4 -> 2
16 -> 3
65536 -> 4
2^65536 ->5
I don't get what this relationship is.
>>
>>53742369

And then the whole system gets ruined by big constants.
>>
>>53742299
>As a side note, can someone explain to me how Towers of Hanoi can be solved without comparisons?
because you always have to move n-1 discs to a temporary peg before you can move the nth disc to the destination peg. the pegs start already ordered so there is no need for comparisons.
>>
File: Screenshot_2016-03-29-12-27-18.png (1 MB, 1600x2560) Image search: [Google]
Screenshot_2016-03-29-12-27-18.png
1 MB, 1600x2560
I actually just uploaded most of the source from this shit I'm working on and I'm going to share it with you guys so you can all vomit together.

The majority of the code is in this one file.
https://github.com/bitcores/ProjectDivaArcadeMap/blob/master/projectDivaArcadeMap/src/main/java/net/bitcores/projectdivaarcademap/MainActivity.java

I'm going to move those map click listeners inline instead of having them separate objects seeing they don't need to be but otherwise this shit is hilarious.
>>
>>53741500
Did you try cleaning the project?
>>
>>53742772
what do you mean?
>>
>>53742710
the amount of time it takes for the program to finish or how much memory it uses
>>
Finally got off my ass and started learning C. Wrote an image manipulation program that takes an uncompressed bitmap image, allocates heap space for it, and lets the user do things like convert to greyscale, convert to 8 colors, pixelate, floyd-steinberg dithering, etc.
>>
>>53742784
What IDE were you using?
>>
>>53742678
I think it is asking the difference between log squared n and log of log of n. The latter is super tiny and the former is just squaring the log of n. The actual notation on log^2(x) differs depending on the math text.
>>
>>53742821
visual studio
>>
Do any of you fa/g/s want to make some money chatting about JS with me?
>$12 an hour, sporadic but scheduled at your convenience (maybe anywhere from three to six hours a week).
>you know what you're doing, know JS at a late intermediate or advanced level, have done projects
>able to explain things to novices moderately well.

Thought I'd post here first before going to a legitimate service. I've read and practiced through "a smarter way to learn Javascript" and am now a third of the way through "eloquent javascript". I'm trying to get more project-focused. We could do it on Skype, phone, google docs, or or even in a thread on /g/ if people want to spectate, I don't care. Email is in name, cheers.
>>
>>53742728
I wish more people would realize this.
>>
>>53742840
https://msdn.microsoft.com/en-us/library/5tdasz7h.aspx
It's a fairly common problem you can come across where intermediate files aren't deleted or recompiled during a make/build and get in the way of the project compiling correctly.
>>
>>53742875
read a book
it's free
>>
File: CirnoQuestioning.jpg (21 KB, 224x224) Image search: [Google]
CirnoQuestioning.jpg
21 KB, 224x224
>>53742730
Ok... that kinda makes sense...
but wouldn't it be n to temp, then n - 1 to dest if it's that way?
But, I'm also kinda confused, because what exactly is dest and temp? Isn't it just left, middle, right? middle is temp? How exactly do you decide which is the temp for each layer?
I mean, I was solving it:
>n->temp;
>n-1->dest; n->dest;
>n-2->temp; n->src; n-1->temp; n->temp;
>n-3->dest; n->dest; n-1->src; n->src; n-2->dest; n->temp; n-1->dest; n->dest;

Is this the same relationship?
I can't really mentally go beyond 4 or 5 disks, so I'll leave it here, like this
>>
anyone have experience with image processing? I'm using c++ and my image gets ghosting when i apply a 3x3 image kernel that isn't
0,0,0
0,1,0
0,0,0
>>
>>53742299
https://graphsketch.com/?eqn1_color=1&eqn1_eqn=x^x&eqn2_color=2&eqn2_eqn=x^2&eqn3_color=3&eqn3_eqn=x&eqn4_color=4&eqn4_eqn=1&eqn5_color=5&eqn5_eqn=log%28x%29&eqn6_color=6&eqn6_eqn=x%20*%20log%28x%29&x_min=0&x_max=34&y_min=0&y_max=21&x_tick=1&y_tick=1&x_label_freq=5&y_label_freq=5&do_grid=0&do_grid=1&bold_labeled_lines=0&bold_labeled_lines=1&line_width=4&image_w=850&image_h=525

This graph should help you understand, x is the size of the input, y would be the time taken by an algorithm that is that time complexity.
>>
>>53742964
osgtp knows everything about processing
i think he uses c# for ittho
>>
>>53742923

Even Pike says he prefers simple, easy to understand (and typically ""slower"") algorithms over fancy ones.
>>
>>53742981
pike prefers go as well
nice appeal to authority
>>
>>53742979
i think it shouldn't matter

>>53742981
plz help
why ghosting 3:
>>
>>53743014
>pike prefers go as well

Things weren't always bad. Once upon a time, there was Limbo.
>>
>>53741324
Its fun and its a decent profession, but I'd rather like to have 2M$ and live a rentier lifestyle. Do not want to be a pro programmer for the rest of my life.

Early retirement is my dream..
>>
File: CirnoNUMBERS.png (288 KB, 500x500) Image search: [Google]
CirnoNUMBERS.png
288 KB, 500x500
>>53742795
No, no I mean: I don't get what numeric relationship this is between items and time.

for each item -> add()
time (what?)

log* n means time goes up in what interval?

>>53742826
oooo ok, that helps a decent amount. I couldn't figure out that difference. That was one part. so, log2n is (log n) * (log n), and log(log n) is the log of the log of n?
K.

Now I just gotta figure out what this log* n actually means to compare it to log(log n)

What type of algorithm would do log(log n), though?
If log n is when you split it in half repeatedly, how else can you split it do make it log again?
>>
>>53742954
but it's annoying when the book you're reading explains a process with an example that utilizes currying / patrol application when you've never seen the function()() syntax before and you're left going "i don't remember this where did he explain this" except he never did and you spend an hour going through the book trying to figure it out and then you give up and go on rebbit and they explain it in one paragraph and two minutes of brain power

if I can have a mutually beneficial relationship with some anon where he gets dollars and I get knowledge then thats preferable to the neuroticism-inducing gaps of knowledge even the best JS books possess
>>
>>53743063
>log2n is (log n) * (log n)
meant log^2n
>>
>>53743088
>>read a book instead
>this one book i read i didnt like
lol
>>
>>53743018
>why ghosting 3:

Is the application of the kernel using already processed pixels? That is -- are the results of the convolution being written on the original bitmap?
>>
>>53743088
>you put your email in the field

WAT
>>
File: 3v3convfucked.png (607 KB, 774x437) Image search: [Google]
3v3convfucked.png
607 KB, 774x437
Here's what it looks like when you apply a convolution to the same image you're getting pixels from.
>>
>>53743113
>>53743144

no, I am creating a new vector of vectors to put in a new image file. would it help if i posted the image?
>>53743128
newest fag pls go
>>
>>53743153
>would it help if i posted the image?

Sure, m9. Go ahead.
>>
>>53743166
oh right it's a fucking shitty .pgm file cause im a fucking student

thx anyways
>>
>>53743206
take a screeny
?
>>
File: CirnoShock.jpg (89 KB, 400x400) Image search: [Google]
CirnoShock.jpg
89 KB, 400x400
>>53742972
Yes, this does help. Thanks, I'll bookmark it.

Now if only I can figure out what this log* n means...
If only they extended the graph a bit more...
ok, if it's:
n -----> log* n
2 -----> 1
4 -----> 2
16 -----> 3
65536 -> 4
2^65536 -> 5

Is it increasing by 2^(the last value)?
2^1
2^2 = 4
2^4 = 16
2^16 = 65536
2^65536

So the next would be 2^(2^65536)
and then
2^(2^(65536))?

I think that's it. Does that seem right?
>>
>>53743105
It was just an example of a situation where I'd benefit from a mentor, fampai.
>>
>>53743227
learn something that isnt dominated by complete idiots
?
>>
>>53743220
>and then
2^(2^(2^(65536)))?
>>
File: temp.png (189 KB, 640x480) Image search: [Google]
temp.png
189 KB, 640x480
>>53743166
>>53743218
>>
>>53743243
tried to use a sharpen filter

0, -1, 0
-1, 5, -1
0, -1, 0
>>
>>53743234
that's why I'm here. everyone knows there are no idiots on /g/.
>>
>>53743243
>>53743254

What does your convolution function look like?
>>
>>53743267
no one here knows js and isn't stupid
>>
File: 1454200570766.jpg (377 KB, 1280x2205) Image search: [Google]
1454200570766.jpg
377 KB, 1280x2205
Is this portable?
Because it works perfectly as is.

/* embedding GLSL in a C program */
#define TO_STRING(str) #str
#define GLSL_INLINE(code) TO_STRING(code)
#define GLSL_MACRO(macro) macro\n

int main(int argc, char **argv)
{
const char *vertex_shader = GLSL_INLINE
(
GLSL_MACRO(#version 120)
GLSL_MACRO(#define SOME_CONSTANT 3.14159)
attribute vec2 position;
int main(void)
{
/* Transforming The Vertex */
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;

/* Passing The Texture Coordinate Of Texture Unit 0 To The Fragment Shader */
texture_coordinate = vec2(gl_MultiTexCoord0);
}
);
printf("%s\n", vertex_shader);
}
>>
>>53743267
>>53743279
What do you need to know about JS?
>>
>>53743272
it's a bunch of disgusting if statements to catch if i am iterating through a corner or edge

then creating a new pixel value depending on the if statement, then throwing it into a vector of x values, then that vector into another vector (y value)
>>
File: 1384914960497.jpg (223 KB, 1600x1200) Image search: [Google]
1384914960497.jpg
223 KB, 1600x1200
>>53741285
Backing up a crap ton of files and lurking /g/ to kill time
>>
>in high diamond in ranked
>team has literally 4 support players, 1 point holder, and i'm the only damage
>i ask the support guys to switch classes
>no response except for "its ok c:"
>halfway through the match people are saying "we have no damage"
>we lose by over 200 points
is there an algorithm i can make to not log on during the same times people like this log on?
>>
>>53743220
to be honest, I wouldn't bother bookmarking it, you can generate the graph with whatever program you want, I just grabbed the first google result for "graph multiple functions"

you should be able to extend the graph as far or as high as you want with the controls at the bottom.

in my experience, log with no stated base is log10

number of elements -> time

10 -> 1
100 -> 2
1000 -> 3

etc

log2(n) would be what you stated, though
>>
>>53743325

Frankly, the ghosting & white dots make me think that there is a fairly serious error in your function, but without seeing it, there's no way for me to check.
>>
>>53743355
hmmmm, ok
>>
>>53743303
It's probably fine.
>>
>>53743348
>algorithm
wat
you'd need to do a study
just take a month a daily sample for a month and work with that
>>
>>53743314
Well the last question I came across was partial analysis / currying, and I sufficiently understand that now but anything more "complicated" than that and I'm probably at a loss. I'm trying to learn JS as fast as possible and that's so much easier if you can ask someone questions. Topics like
>Immediately Invoked Function Expression, Asynchronous execution, timers, Design Patterns, Object Creation Patterns, and Code Reuse Patterns, Code Minification and Compression, Dependency Management
I will probably be asking. But I want to start learning from a project-driven basis, so I'd probably ask questions related to making simple apps
>>
>>53743348
That's a statistics question, not a programming question.
>>
>>53743303
this is really neat cool as heck
not that I know what glsl is
wow
nice
>>
>>53743430
>not that I know what glsl is
It's the language that OpenGL shaders are written in.
>>
>>53743381
why not
shield your eyes

void Image::convolve(Image& i, vector<vector<long>> mask, long w, long h, long div, long whiten)
{ vector<vector<long>> ret_vec; //new image's vector of vectors
for (int i = 0; i < v_.size(); i++){
vector<long> vec;
int counter = 0;
for (int j = 0; j < v_[i].size(); j++){ // v_[i][j] is 'current pixel'
long new_pix; //no clue how to parse neighbor pixels efficiently...there must be better ways.
//also this doesn't work correctly
if (i==0 && j==0){//a 3 x 3 mask is hardcoded
new_pix = v_[i][j]*mask[1][1]+v_[i][j+1]*mask[1][2]
+v_[i+1][j]*mask[2][1]+v_[i+1][j+1]*mask[2][2];
new_pix += whiten;
new_pix = (long)new_pix/div;
if(new_pix > max_val_){new_pix = max_val_;}
if(new_pix<0){new_pix=0;}
vec.push_back(new_pix);
//cout <<"top left corner" << endl;
continue;
}

7 more if statements for edges & corners..
then
            else{//
new_pix = v_[i-1][j-1]*mask[0][0] + v_[i-1][j]*mask[0][1]+v_[i-1][j+1]*mask[0][2]
+v_[i][j-1]*mask[1][0]+v_[i][j]*mask[1][1]+v_[i][j+1]*mask[1][2] + v_[i+1][j-1]*mask[2][0]
+v_[i+1][j]*mask[2][1]+v_[i+1][j+1]*mask[2][2];
new_pix += whiten;
new_pix = (long)new_pix/div;
if(new_pix > max_val_){new_pix = max_val_;}
if(new_pix<0){new_pix=0;}
vec.push_back(new_pix);
//cout << "v_[i].size(): " << v_[i].size() << endl;
//cout << "v_[i][j]: " << v_[i][j] << endl;
//cout << "v_[i][j-1]: " << v_[i][j-1] << endl;
}
>>
>>53743396
a fun, useful, and quick way to remember it is

logb(n) = x

x is approximately equivalent to the number of 0's you'd need to represent that number in base b.

so log2(n) has

10 = 1
100 = 2
1000 = 3

where 10 is 4, 100 is 8, and 1000 is 16

log3n would be 9,27, and whatever 3^4 is

note that the reasoning for this is because log is an inverse for exponents.
>>
made a web app to let me and my roommates bet on what we think the rotten tomatoes score will be for new movies..built it all to the point where I need to calculate the bet's outcomes, and I find out the rotten tomatoes API costs 60K a year to use..

how hard would it be to use python to scrape rotten tomatoes scores?
>>
File: vampire_kiss_19.jpg (444 KB, 2000x1730) Image search: [Google]
vampire_kiss_19.jpg
444 KB, 2000x1730
Guys, how do I design resource management for a vidya gayum?

Right now i just use singletons
struct GUIFont
{
friend struct GUIFontManager;

private:
struct GUIFontObject
{
atomic<uint> m_instances = 0;
};

public:
GUIFont(const char *name, uint size);
~GUIFont()
{ --m_obj->m_instances; }
GUIFont(const GUIFont& other)
: m_obj(other.m_obj)
{ ++m_obj->m_instances; }

private:
GUIFontObject *m_obj;
};

struct GUIFontManager
{
static GUIFontManager& Get();

GUIFontObject* GetFont(const char *name, uint size) const;

private:
void DeleteFont(GUIFontObject *obj);
unordered_map<string, unique_ptr<GUIFontObject>> m_fonts;

CDEFAULT_CONSTRUCTION(GUIFontManager)
CDISABLE_COPY(GUIFontManager)
};


And same goes basically for textures, shaders, meshes, etc. I can request object by handle(as resources will often have a handle- a name of model/texture/shader/whatever), and if needed store it in a container that basically does the same thing as shared_ptr.

Now, i could fuse all of this into a single class that is explicitly initialized in main(), but that would just create more mess and wouldn't really be any different, as i do not have any problems with initialization order anyway.

I could throw this whole thing out and store shit in shared_ptrs all over the place but that would rob me of ability to profile my resources and add overhead and code spaghetti.

I am at a loss here.
>>
>>53743474
easy
check out beautifulsoup, requests
>>
>>53743303
Why not just read the GLSL from a file?
>>
>>53743504
Not him, but I just statically link GLSL files into my program and then use pointers to it.
Doing shit inline/statically linked means you don't have to fuck around with file I/O.
>>
im a dummy and want to be sure about some things

are header files for declarations?
and are cpp files for initializations?

can header files have initializations too?
>>
>>53743503

never heard of beautifulsoup, but it looks perfect for what i need, thanks man
>>
>>53743539
Sure but "fucking around with file I/O" isn't exactly time consuming, just write a function once to read a file and return a pointer, then use everywhere.

char *vertex_shader = glsl_load("resources/file.glsl");
char *whatever = glsl_load("...");

// free


Wouldn't need a rebuild everytime you change that GLSL code.
>>
>>53743585
header files are for classes, structures
cpp files are for functions
idk wtf you mean by initializations
>>
>>53741285
working on an 4chan image downloader in haskell
I'm just wondering if the official JSON packages such as Data.Aeson or Text.JSON ever worked for anyone that tried doing the same as I.
I say this because neither of their' decode functions even work for me
i tried a homemade solution but im having a hard time coming up with anything concise that isn't boilterplate
pls halp
>>
>>53743466

Lord have marcy. Shouldn't the new pixel just be the convolution of old pixels and then a 0/max_val clamp? I know fuck all about PGM, so I can't say.

Also, what does Image& i do for you? It doesn't seem like you're using it.
>>
>>53743590
no problem my dude
>>
File: collision01.webm (451 KB, 608x624) Image search: [Google]
collision01.webm
451 KB, 608x624
>>53743234
>idiots
Come back when you will be able to write a physics simulator in a meme language of your choice, anon (^:

Until then you're an idiot, I'm a javascript programmer
>>
>>53743420
Whoa... um... I know how to use JavaScript to like.. make AJAX for my websites and validate input. I can also use some jQuery.

I mean, Asynchronous Execution sounds like AJAX related, and I assume an Immediately Invoked Function Expression is something... that runs as soon as the page loads?
The patterns probably are just a way to implement efficient code, reuse is probably modularization, and minification is probably efficient functions and removal of comments and white space for a launched version of the code, like the jquery[***].min.js as opposed to the much more easily readable full version. Saves bandwidth

Dependency Management? Um... Maybe... checking that certain scripts exist before trying to use them, and throwing errors if it fails to load?

I'm just guessing, though. I use it to make sites look good and run faster. I've never even heard of these concepts. I'm extrapolating.
>>
>>53743608
i left out where i change i's vector<vector<long>> member variable to the 2d vector i just created.

it is essentially just that. man my code sucks. used if statements... someone else added 0's all around the edges of the image file and then just had what i did in the else statement. guess i have an hour to figure that shit out lol
>>
>>53743585
no, you are completely and utterly wrong.

cpp file is a file which compiles into program object- like a sub-program inside your program.

h file is a text file that preprocessor can copypaste into cpp files when your program is being built.

>>53743485
guys halp
>>
>>53743600
I have an SSD, and frankly, my projects haven't gotten to the point where they take 20 minutes to build after running make.
Also, not running make after making an edit would fuck up my workflow because i'm so used to typing make after every edit
>>
>>53743467
Ok, thanks. That should help a big.

Since we're at it, are there any really basic ways to get good at sigma notation and a simple way to understand how to differentiate between best, worst, average, and amortized case running time scenarios?
>>
>>53743652
кaк тaм дopвeи, мм?
>>
>>53743722
For instance, if:
I=1 to n, sigma I = (n(n+1))/2 (some kind of rounded E thing) O(n^2)

What is that rounded E thing called, also, and what does it mean?

How would I solve I = 0 to t - 1 sum((n-1)/2 ^ i) for its running time?

(I'm actually going back in a few chapters since I'm here anyway)
>>
>>53743267
dude your email is right there. You're the idiot
>>
>>53743778
My honest recommendation is to go through a calc book, that's where a lot of these sorts of things come from.
>>
>>53741285
good introductory self-taught discrete mathematics books any anon would like to recommend?
>>
>>53741697
Fair enough. If you can do it without classes, do it without classes. Classes are a tool, not a necessity. Python is a general purpose language, it can be used functionally or object oriented.
>>
>>53743778
lowercase epsilon? ε
>>
File: muhpgm.png (321 KB, 713x517) Image search: [Google]
muhpgm.png
321 KB, 713x517
oh wow, muh pgm reader works. yee haw.
>>
>>53743728
O.K.
>>
>>53743830
*clap*

C#?
>>
>>53743825
ε:
>>
>>53743678
>someone else added 0's all around the edges of the image file

Pro-tip: start at 1,1 and end at wid-1,hei-1. Then you don't have to fuck around with edge cases.

Also, quadruple check that the correct pixels are using the correct cell in the kernel.
>>
>>53743825
>>53743850
ε===D
>>
>>53743847

Yes. The code is hot garbage, though. Turns out that Binary Reader isn't ever pretty.
>>
>>53743851
hell yeah :)
>>
Superior Java Master Race
>>
File: 92a (1).jpg (48 KB, 480x801) Image search: [Google]
92a (1).jpg
48 KB, 480x801
>>53743088
>a mutually beneficial relationship
s-sounds l-lewd...
>>
>>53743952
Why?
>>
>>53743935

It really is a good technique, since nobody will ever notice the edge pixels haven't been filtered.

Also, anybody have a 16 bit PGM file so I can test my PGM reader?
>>
>>53741450
It'll be more work than you think. Most big stores' pages are not scrapable too easily, and they change their page structure regularly (maybe to defeat things like this, maybe just 'cause they can).
>>
File: TheEThingInMiddle.png (806 B, 127x21) Image search: [Google]
TheEThingInMiddle.png
806 B, 127x21
>>53743810
Alright, I'll have to check one of my books, I guess.
I hated Calc so much...

>>53743825
Um... I don't think so. The thing in the middle of this picture.
>>
>>53743420
These are not complex things, every one of them is googleable.
>>
>>53741480
yes. now pass the bong
>>
So I'm working with C shit, but for some reason I'm getting a really strange value in my integers.
I'll declare it, initialize it to 0, then print it and its printing out as -1073744296
I have code afterwards, but considering I just initialized it I don't understand why its getting strange values.
>>
>>53743952
Yeah the superior master race on par with the Jonestown cult
>>
>>53744068
But Anon we are a cult The /dpt/ cult we all dress in black robes at night time and gather deep in the forest and program underneth a giant oak tree on our laptops
>>
>>53742266
>fuck unit testing

your future colleagues already hate you
>>
>>53744064
-2^30 is very close to your number

Post the snippet of what you're doing
>>
>>53744091
>black robes
>not schoolgirl outfits

get out
>>
>>53744046
https://en.wikipedia.org/wiki/Element_%28mathematics%29#Notation_and_terminology
>>
>>53744046
I don't know what the symbol is called, but it's also used for "is an element of" in set theory.

In your case it just means that f(x) has complexity O(g(x)).
>>
>>53744117
well the main thing confusing me is it happens wherever I put them. doing a lot of low level reading and writing though
int main(argc argv){
int testval=0;
printf("%d\n",&testval); //returns low val here

//lowlevel io stuff

printf("%d\n",&testval); //returns low here as well


int newval=0;
printf("%d\n",&newval); //returns a similar low value

//finish up code
}

I mean if it was someone where values might be overflowing and rewriting them I could understand it, its happening immediately after declaration though.
}
>>
>>53741636
>Do I have a parent class for the bot itself and then a class for each file downloader source, like one which pulls files from irc, one for a website via http, etc., each of which inherits from some main file getter class? That's the best that I can think of right now

That sounds excessive. I would make one class for the bot and different methods for each download source.

>Also, where do I put functions that don't need to belong to an object, like a function that unzips a file?

If several functions fit into a common theme you should put them together into one module. If you have a couple of miscellaneous functions, you can just put them somewhere in your main module, or in a "utils.py" or "misc.py" module.
>>
>>53744169
You're printing the decimal converted address of the initialized variable. That's why you're getting weird values.
>>
>>53744224
son of a bitch, I thought that was how variables were supposed to be input in C.
Been too long since I worked with it.
Now I just feel like a giant dumbass.
Thanks man.
>>
>>53744064
how are you initializing it?
>>
>>53744258
No problem man. It might be valuable to read this http://www.c4learn.com/c-programming/c-pointer-address-operator/
>>
>>53744144
>>53744149
Thanks

That helps.
>>
>>53743485
GUUUUUUUYS
>>
>>53744291
Na its coming back to me, its just been years since I worked in C and I just recalled something along the lines of using & when doing scans and prints so for some reason I associated it with perl's $ variables and kept throwing it in there.
>>
>>53741500
that's what you get for using Microsoft products
>>
>>53744131
You really want to see a bunch of grown ass Neckbeards in schoolgirl outfits? I am sure black robes are more fitting
>>
>>53741285
>What are you working on, /g/?
Fix the first ever bug report that I received.
>>
>>53744342
>You really want to see a bunch of grown ass Neckbeards in schoolgirl outfits?

I'm not against the idea, tbqh fampai.
>>
>>53743590
I use bs to scrape SEC filings, really useful tool. Gl anon
>>
>>53744380
disgustinggg
>>
>>53743830
>windows-flavor c#
Does your image resize when you resize the window? Every Windows-only .NET program I know suffers from the pixel-perfect-placement meme.
>>
Total newbie here trying to learn c++ from a book.

So, I'm trying to do input validation using chars but im being a total mong right now.
I wrote this code to practice, but my the loop executes even if I input F or C. What am I doing wrong?
I can do input validation with numbers without a problem, but for some reason i'm having difficulty with chars.

char test;
cin >> test;

while (test != 'F' || test != 'C')
{
cout << "Try again" << endl;
cin >> test;
}

so, yeah I would really appreciate some clarification here.
>>
>>53744428
>C++ not Java

It's like you don't even want to be a programmer

LaughingSystems.exe
>>
File: iv.png (1 MB, 605x872) Image search: [Google]
iv.png
1 MB, 605x872
>>53744416

My image viewer appropriately resizes (things are docked and paneled like they should be). This thing was just a test to see if I could knock out a quick PGM reader for shits.
>>
>>53744428
>Logical OR
That's going to be true for every input.
Change the || to a &&.
>>
>>53744448
Noice. Does your reader handle 16bit per channel png?
>>
File: 1458955646369.jpg (143 KB, 646x1024) Image search: [Google]
1458955646369.jpg
143 KB, 646x1024
>>53744428
use the debugger to set a breakpoint and inspect the value of test after the cin.

you must learn how to use a debugger.
>>
>>53744448
nice dog, jon.
>>
>>53744468
Yup, that worked!
Thanks, anon.
>>
>>53744474

It's actually the [spoiler][spoiler][spoiler]M$ image reader[/spoiler][/spoiler][/spoiler]. I've been meaning to implement some custom file-type reading but I never got around to it. Since I mainly use it for thumbing through porn pics, they're all jpeg anyway.

inb4
>porn
>photographs
>year of jesus, our lord and savior, 2017
>>
>>53744498

I don't get it.
>>
>>53744351
Awesome I guess

What anime?
>>
>>53742217
shit thanks man. apparently M$ doesnt know wtf they are doing?
>>
>>53744506
>uses microsoft shit
>calls microsoft "M$"
wat
>>
>>53744570

It's some type of Stockholm syndrome.
>>
>>53744205
>That sounds excessive. I would make one class for the bot and different methods for each download source.
won't each bot object then unnecessarily contain (redundantly) every single download method even when it's not necessary?
>>
File: buttcreed.png (2 MB, 1382x806) Image search: [Google]
buttcreed.png
2 MB, 1382x806
Also, I hate to admit it, but pic related keeps me on Winders.

Muh video games is a legitimate complaint.
>>
>>53744722
>Muh video games is a legitimate complaint.

How old are you?
>>
>>53744722
Use this famalam
https://github.com/cmdrkotori/qemu-scripts
>>
>>53744751

21, fambly.
>>
>>53744722
>Also, I hate to admit it, but pic related keeps me on Winders.
aren't you a C# fag? what about VS, then?

btw, anyone got a good guide on how to program (and learn too, if possible) C# stuff on linux?
>>
File: hongkong-neon-last-superJumbo.jpg (367 KB, 2048x1365) Image search: [Google]
hongkong-neon-last-superJumbo.jpg
367 KB, 2048x1365
>>53744775
>tripfagging
>twenty-one and still playing gaymes
>Not installing Linux because of a childish hobby
>>
>>53744804

I have a bunch of linux (and even a BSD) virtual machines, my main man. If gayme developers had targeted it in its infancy, I'd be using Linux exclusively.

>>53744792

I use MonoDevelop on Lingus.
>>
>>53744722
Dual boot senpai

Just kidding, whoever argues about OS has too much time on their hands.
>>
Java question here, what is the difference between a JTextField and a TextField? For some reason, only TextField works for me whereas JTextField fucks everything up (makes everything invinsible, including itself)

thanks
>>
>>53744922

TextField is AWT and JTextField is Swing.
>>
>>53745109
Then why do I get this issue of making everything insinsible?
>>
>>53745154
You probably go to the Catholic church.
>>
>>53745179
God damn it
>>
>>53743014
shots status:
[_] not fired
[x] fired
>>
File: 1423314646452.png (155 KB, 300x468) Image search: [Google]
1423314646452.png
155 KB, 300x468
>go to code something in notepad
>realise how much auto-complete has ruined me
FUCK
>>
hi i'm autistic

how do i pipe the results of

 cut -d' ' -f1 *filename* 
into mkdir one at a time?

i have a file with 100 words, i want to make a directory for each of them
>>
>>53745622
Don't go openly admitting that, lel
>>
>>53745622
how the shit do you even use autocomplete? It pisses me off so much whenever I try that I switch it off after thirty seconds
>go to type foo
>press space
>suddenly a box opens up and foo gets replaced with fooBarBaz.GoSuckADick()
>>
>>53745622
congrats, you never learned to program, you just learned your IDE

you're useless
>>
>>53745663
this.
so much this.someMethodNobodyHasEverUsed()
>>
>>53745635
for i in $(cat file.txt); do mkdir $i; done
???
you can trim as you need with cut in place of cat file.txt
>>
>>53741484
You don't learn from not writing code. If you wanna write it, write it.
Instead of exporting to a spreadsheet, why not try a SQL table?
It sounds like a large project, but it's something you could turn into a resume booster.
>>
>>53741450
>>53741484
>>53745783
personally, I would export to a json so that I could update my webpage easily.

scrape with python -> export to deals.json
read deals.json with javascript -> consolidate information on my website
>>
>>53742756
You wrote this?
>>
>>53741295
240th for SDL > SFML
>>
>>53745635
while read line; do mkdir "$line"; done < filename.txt


>>53745734
>for i in $(cat file.txt); do mkdir $i; done
this is wrong
>>
>>53745858
wrong how? you are wrong. he said by word not by line
>>
>>53745880
ah, shit, I misread...

>>53745858
>>53745734 is correct.
>>
If I try to install the clang environment and compiler on wangblows will I have a hard time?
>>
>>53745829
Good idea!

I said save to SQL because then you can have a JS function in an Android WebView make an AJAX request to a PHP script that pulls the values from a SQL table.
Probably overthinking.
>>
>>53745911

Yes.
>>
Anyone else feel like they're too autistic for webdev languages? Everything just feels like a mess. How do people learn that crap.

C and C++ for lyfe
>>
>>53745994
Bruh, you can't write iOS apps in C or C++. All about that Java.
>>
>>53746003
Why would anyone want to write ios programs if that's the case?
>>
>>53745956
I'm more familiar with working with jsons in python and javascript, so that's the direction I would go with it.

I think I've made a grand total of 1 php script and have minimal experience with sql as well. So a php/sql solution wouldn't have even occurred to me
>>
>>53746019
I'm not knocking your idea at all. It's a good way to look at things.
>>
>>53746003
>Cant write iOS apps in C or C++
I could have sworn you could.

>Java
>iOS
u wot
>>
>>53746036
I didn't mean to imply that you were, I was just saying out how I came to my solution. There's probably a dozen other ways to this that are just as good if someone is more experienced with something else.

also
>rewrite my comment four times to avoid sounding like I'm knocking your idea or being too defensive about mine
>it still gets taken the wrong way

I wish I were better at communicating.
>>
I'm the guy with the ruby websockets game that kept shitting itself every couple of seconds. It turns out that it wasn't the GC after all, because it was working fine on localhost. It's because packets get dropped all the time and the retransmission time for the ACK is way too long for a real-time application

Gonna have to look into some bullshit webrtc stuff now. Webdev is hard.
>>
>>53743063
fizzbuzz with variable input would be O(n)

fizzbuzz to 10 million would take around 10 times as long as fizzbuzz to 1 million

if it were O(n^2) it would take around 100 times as long
>>
>>53746142
Don't worry about it.
Well remember to challenge yourself!
Thread replies: 255
Thread images: 34

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.