[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: jealous.jpg (372 KB, 1280x720) Image search: [Google]
jealous.jpg
372 KB, 1280x720
old thread: >>53741285

What are you working on, /g/?
>>
>creating threads before the bump limit
Delete this shit, and kill yourself.
>>
Why do people write templates when void * pointers and C preprocessor macros exist?
Genericity in C is completely straightforward.
>>
>>53748407
from the other thread: what are some good resources to learn spring ?
>>
Hey /dpt/, retard who didn't pay attention in high school here.
I'm trying to write a recommendations system for my porn site and I can't figure out how to not suck dick.
The sites a booru/chan scraper with an sql db full of tags and filenames and the like, each image has a set of booru tags with it and an md5 and a "potential" column (explained later). There's about a million images in the DB (actual images in fs, meta in db) and my computer's a toaster so I kinda like my solutions not too intensive.
Oh and the front end is a page where I can search and scroll through images, upboating and favouriting images.
I don't want to subject anyone to my horrid self taught code so the basic logic is as follows:
>go through all images "explode()"ing the tags string and storing a count how many times each tag has shown up
e.g. the tag "1girl" is in 400K images and skirt's in like 300K so that's their values
>go through all of the images I've favorited and or upboated and generate a value for each image (1 point for an upboat and 5 for a favorite) so a favorited picture upboated 5 times is worth 10 points
>assign every tag associated with that image points equal to the value of the image so each tag has a value
>go through each tag editing its value to reflect its percentage of the population so less popular tags are still worth something which ends up being (1-(amount_of_images_in/amount_of_images))*value_from_tags
or
function compute_weighted_value()
{
global $images_to_check;
$this->weighted_value = (1-($this->seen/$images_to_check))*$this->value;
}

>go through every image in the db calculating a "potential" by adding up the values of each tag

Which works OK but I get the issue of images with a lot of tags coming out on top because they can gather the most points and when I divide the final "potential" by amount of tags I get images with fuck all tags. So what do?
>>
>>53748598
I also tried only counting a tag as something to divide by when it's above the average value for non-zero tags but that's only marginally better. So do I keep trying to find a threshold for counting a tag as divide worthy? This is confusing the shit out of me.
>>
>>53748407
me on the left
>>
>>53748407
Any Pajeets need SQL help?

I'm feeling the data boner.
>>
How to avoid shadowing variables from outer scope in Python? Is it a good idea to pack the stuff I write outside of functions into a main() function which I then call?
>>
>>53748407
>programming thread
>op picture is some stupid anime shit

Fucking pedos goddamn
>>
https://www.youtube.com/watch?v=hB6eY73sLV0

Do you even hack?
>>
>>53748700
Holy shit, that was an impressive way to waste your time
>>
>>53748668
Yeah, >>53748598
here, I've got ~1M images in a table and I need to check if three fields contain any text and if they do, I need to print a random 100 of those images.
At the moment I'm just loading however many thousand images that match the query, shuffling the array in php and then printing the first 100.
Is there a better way to do this with SQL?
I'm English bloodline in Australia BTW, do I still get help?
>>
>>53748839
You have direct access to the database? Or API access only?

What's the table structure? All in one table or relational across a few tables?
>>
>>53748407
Retard here. Partway through a business degree here. Really wanted to start a small online startup business venture and being naive as fuck I think I have some pretty golden ideas. Anyways to keep it short I have two working PCs and a laptop with decent hardware, I'm passing university with my eyes closed and have 30 free hours a week to commit to independent study of web design. I've started with HTML for beginners and its very easily digestible. Does anyone have a simple outline of how I should go about learning from the ground up? Where to start? Cheers in advance.
>>
>>53748863
Yeah the DB's on my machine, MariaDB and all in the one table
MariaDB [dandyl]> show columns in image_meta;

| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+--------------------+-------+
| md5 | char(32) | NO | PRI | | |
| ext | varchar(8) | YES | | NULL | |
| boards_seen_on | text | YES | | NULL | |
| times_seen_at | longtext | YES | | NULL | |
| filenames_seen | longtext | YES | | NULL | |
| rating | char(1) | YES | | NULL | |
| artist | text | YES | | NULL | |
| characters | text | YES | | NULL | |
| score | int(11) | YES | | NULL | |
| downloaded | tinyint(1) | YES | | NULL | |
| fav | tinyint(1) | YES | | NULL | |
| tags | text | YES | | NULL | |
| source | text | YES | | NULL | |
| copyright | text | YES | | NULL | |
| queries_matched | text | YES | | NULL | |
| boat | int(11) | NO | | 0 | |
| dir | varchar(512) | YES | | /wang8/Dandyl MK8/ | |
| potential | int(11) | YES | | NULL | |

Typical search be like
SELECT * FROM image_meta WHERE downloaded = 1 AND (UPPER(queries_matched) LIKE UPPER('%loli%') OR UPPER(tags) LIKE UPPER('%loli%') OR UPPER(filenames_seen) LIKE UPPER('%loli%'))
>>
Is it bad if I use camelCase for variables within functions? PEP8 tells me to make them all lowercase but I think that's harder to read.
>>
>>53748839
>>53748892

Oh, I just re-read your post.

First of all, it sounds like you're storing a comma-delimited value for the tags. This is a huge no-go.

You really need to split this out into multiple tables.

IMO, don't use the md5 as the primary key. It likely will work fine, but you'd be better off using a sequential key.

You want a 3 table structure as far as the tags are concerned:
>images
All the stuff you have here, minus the tags field.

>tags
All the available tags with a primary key for each one.

Let's say 'loli' is #10 and 'ahegao' is #69.

>image_tags
Literally a list of primary keys from the images and tags table.

For example, image #101 has 'loli' and 'ahegao'. You have two rows here:
>101 | 10
>101 | 69

Data is retrieved with joins.


Also...

Apply indexes on often-used columns, like the date an image is created.

Example tables incoming.
>>
>>53748946
camelCase for memel angs and literally wherever you can
best_seperators for everything else
>>
File: pajeet.png (16 KB, 423x438) Image search: [Google]
pajeet.png
16 KB, 423x438
>>53748892
> use a relational database
> who needs relations, normalize nothing
>>
Is it possible to have a portable php server on windows?
>>
>>53748956
Shit that makes a lot of sense

I picked md5 as a primary key because I don't wanna have to deal with duplicate checking when I'm running inserts
What's a fast way to deal with that?

Little confused about how to run searches but I'm guessing it'd be a trawl through image_tags
Would it make sense to just have a list of matching images for each tag?

Looking forward to the examples.
And thanks BTW.


>>53749033
I'm self taught (well, teaching)
>>
noob here.

How can i initialize and print the sizeof() of a variable's data type which i specified in a string before? (C)

no bully pls
>>
>>53748407
That's not a girl!
>>
File: dXlOA60.png (38 KB, 725x1032) Image search: [Google]
dXlOA60.png
38 KB, 725x1032
>>53749080
See image.

Let me know if this helps or if you're not clear on anything here.

The 4th query and result set is how you would retrieve all the data from the three tables, image name and its tags.

The last is a search for any image that has a tag with loli or loli+any characters.

I'm not sure about MariaDB, but in SQL Server, you can set an identity column to auto-increment. This guarantees unique values and you don't have to manually assign the primary key when inserting data.
>>
>>53748520
Can you restrict the void pointer to integral types only for example?
>>
File: output.webm (1 MB, 800x600) Image search: [Google]
output.webm
1 MB, 800x600
since googlel calculator is open sores, it's ok to rip off their interface r-right g-guys???

also r8
>>
>>53749245
Depends on the license.
>>
>>53749245
>calculadora
es muy bien cabron!! quiero te comprar una cerveza porque es tan bien!!
ocho/ocho
>>
>>53749274
Not spanish lad, portuguese.
>>
>>53749319
What's the difference?
>>
>>53749198
Wow thank you so much for that
It's getting late where I am and I'm not in the best state of mind but I get where you're coming from with this
I'll give it another read over in the morning but to search for more than the one tag would you just add
AND t.Tag_Description LIKE 'ahegao'
?

And sorry for being a massive fucking retard but what are the advantages for this, like how will this make my queries faster and or allow for better analysis?

Thanks a bunch!
>>
>>53749339
BR speak is Frenchier
>>
>>53749355
Oh fuck nevermind with the multiple search example, I'm really tired sorry.
>>
so does using llvm mean my executables can run on any platform?

and by any I don't mean a motorola 68k or some shit, I mean platforms that people actually use
>>
>>53749358
But French is gay. Why would anyone speak Portuguese?
>>
Java is such a great language I can't stop programming in Java
>>
>>53749355
>AND

WHERE t.Tag_Description LIKE 'loli%' 
OR t.Tag_Description LIKE 'ahegao%'
>>
>>53749394
I bet you can't stop sucking dicks either.
>>
>>53749372
> not being born in a third world country
you don't know what real fun is lad
>>
What programming projects did you show off during placement interviews?
>>
>>53749407
Yeah right that makes a lot more sense.
Thanks again and good night, I've got a busy day tomorrow.
Sweet dreams if it's anywhere close to night time where you are.
>>
>>53749355
>like how will this make my queries faster and or allow for better analysis?
Because, in the short term for you, you can easily retrieve counts of tags based on numeric primary keys.

This greatly improves performance, rather than trying to do a million rows of text parsing.

Eventually, you may want to relate other things to tags, such as Groups or Communities. Say you have this thing where people can create groups: they can also assign the tag 'loli' to their group so now that is searchable for people with like interests.

Look up third normal form. It's pretty much the standard for most databases, as it's not crazy abstract, but normalized enough to be extensible.
>>
>>53749410
That's not true I only like traps

>>53749420
My entire portfolio of many different projects and my website of different website projects of many different projects in different languages
>>
>>53749430
Texas, just woke up.

Nighty-night, anon-kun.
>>
>>53749420
I didn't really show it off, but I had the starts of an OS on my Github, and the person interviewing me noticed that and we talked about it for a bit.
Same thing with a couple other small embedded things I did.
>>
So I have to learn some Java theory. What website or book can you recommend ?
I've downloaded and started reading Thinking in Java, 3rd Edition. Should that suffice ?
>>
>>53749480
The best Java book is Introduction to Java By Daniel Y Liang Comprehensive version
>>
>>53749493
kek
>>
File: 1458526188153.jpg (83 KB, 1000x667) Image search: [Google]
1458526188153.jpg
83 KB, 1000x667
>>53748891
Please send help. Ass is the closest thing to a universal 4chan currency so bumping.
>>
>>53749501
?
>>
>>53749370
lads

specifically if I did some graphics shit with opengl
would it still work on wangblows?
>>
>>53749520
yes as long as the context creation library is cross platform and as long as the drivers and gpu support your requested ogl version
>>
File: index.jpg (14 KB, 199x254) Image search: [Google]
index.jpg
14 KB, 199x254
>>53749501
No seriously it's a really good book check it out. I read the entire thing and did all the practice problems
>>
>>53749537
I don't know what the fuck a context creation library is but I'm happy with that answer
>>
>>53749504
html5, css3, php, javascript, get online hosting/domain registration->profit.
>>
>>53749545
looks like the cover of a book on the island java featuring some local aboriginal stone art
>>
>>53749186
No, faggot, it's a drawing.
>>
>>53748407
This is beyond noob-level but still I can't figure out why it's not working.
It's supposed to read an array of 10 elements and sort it, while still retaining the element's initial index.
Pls halp.

typedef struct idx{
char data;
int index;
}IDX;


int main()
{

int i, j;
IDX array[10];


/*read-in*/
for(i=0; i<10; i++){
printf("a[%d]=", i+1);
scanf("%c", &array[i].data);
array[i].index=i+1;

}

/*bubblesort*/
for(i=0; i<10; i++){
for(j=0; j<10-1; j++){
if(array[j].data>array[j+1].data){
IDX temp = array[j+1];
array[j+1] = array[j];
array[j] = temp;
}
}
}

/* post-sorting print-out */
printf("\nSorted array is:\n");
for(i=0; i<10; i++)
printf("a[%d]=%c\n", array[i].index, array[i].data);


return 0;
}
>>
>>53750030
What do you mean by 'not working'?
>>
File: Capture.png (2 KB, 109x71) Image search: [Google]
Capture.png
2 KB, 109x71
>>53750060
it shits the bed on read-in.
>>
>>53750093
>it shits the bed

kop tet
>>
>>53750093
Hello fellow Brit
>>
>>53750030
Use memesort.
>>
Reminder that Java is deprecated and you should migrate to Scala.

Would have posted sooner but I was in a tunnel at Welwyn.
>>
>>53750030
"j" must start from "i + 1", and the comparison must be "array[i].data>array[j].data". Also, you must swap array[i] with array[j].
>>
>>53748520
>Why do people write templates when void * pointers and C preprocessor macros exist?

Because the C preprocessor clearly isn't strong enough.
>>
Should I learn ANSI C (K&R) or learn a more modern dialect?
>>
>>53748700
>bunch of ppl did actual work but I'm the first human to do this
>>
>>53750642
Learn K&R, if you already have some programming experience then the book will tell you everything you need to know.

If you're completely new then you might need some simpler examples to get your head around the basics first.
>>
>>53750476
Yet still my little program doesnt even pass the read-in phase... That's where my main concern is.
>>
>>53750502
"strong" enough
>>
>>53750734

Precisely. It's hardly more than a garbage find-and-replace.
>>
>>53749562
Thankyou
>>
>>53750742
Find and replace is all you need though.
If you want generic, use void pointer.
>>
File: out.webm (408 KB, 1240x1024) Image search: [Google]
out.webm
408 KB, 1240x1024
Made it in C.
>>
>>53750838
What library are you using for graphics?
>>
>>53750870
allegro5
>>
>>53750721
Try with:

scanf("%d", &(array[i].data));
>>
>>53748520

>void * pointers
Because determining type at runtime costs cycles and determining type at compile time using templates costs fuck all.

>C preprocessor macros
Because templates blow macros out of the water in terms of actual power. C++ templates are turing complete. C macros... I have yet to see any decent proof that could back up claims to such abilities.
>>
does anyone know how to extract the video from the youtube player ? has anyone here done this ?
>>
>>53750925
Ayy lmao it worked but the reason I opted for %c in the first place was in order to read alphanumerical values.
>>
>>53749245

It's a calculator. There's not really that much room for innovation in the interface.
>>
>>53751038
Look at youtube-dl
>>
>>53749339
jajajajajaja
>>
>>53750709
This desu
People will still hail him as a genius or something though.
>>
>>53751081
The difference is in the ampersand operator.

It wasn't storing the read character in the right location...
>>
>>53751081
You can use %c, it's seems that the parentheses were the real fix.
>>
>>53748407
kill yourself

you are seriously fucked in the head and incredibly obsessive, seflish and immature
>>
>>53749339
AHUEHEUEHEUEHEUEHEUEHEUHUE
>>
File: 1453307171580.jpg (27 KB, 259x259) Image search: [Google]
1453307171580.jpg
27 KB, 259x259
New to Java: Can someone help me figure out why my code isn't compiling?


import java.util.*;

public class Testing {
public static void main(String[] args){
Testing game = new Testing();
String[] player = {"apple", "apple", "orange", "strawberry"};
String[] dictionary = {"strawberry", "orange", "grapefruit", "watermelon"};

int points = game.count(player,dictionary);
System.out.print(points);
}

public int count(String[] player, String[] dictionary) {
HashSet<String> hset = new HashSet<String>();
for(int i = 0; i<player.length; i++){
String player_word = player[i];
hset.add(player_word);

int counter = 0;

Iterator<String> it = hset.iterator();

while(it.hasNext()) {
for(String s:dictionary){
if(s.equals(player_word)){
counter +=player_word.length()*player_word.length();


}

}
}


}
return counter;


}
}

>>
Redpill me on OpenCV lads. Which book/resourcr about it is the best?
>>
>>53751740
>redpill me
fuck off back to >>reddit
>>
>Tfw Programming is too hard and you need an entire team to build a really good application

What's the point anymore?
>>
>>53751960
why even live?
>>
I'm going to write something similar to sshchan, but I don't know one thing. How to prevent an user from stopping the program?
>>
>>53751717
Read the errors in your IDE.
>>
>>53751717
use an IDE it will tell you in real-time what you're doing wrong

>>53751990
this
>>
>>53751960
then join a team if you're decent enough, look for a job

also it's possible to make decent applications by yourself but it's not for everyone
>>
>>53751717
counter is out of scope
suggest you use an IDE for java
>>
>>53751990
>length is not a method senpai
>this
never mind player_word is a string not an array
>>
File: Binary.png (5 KB, 243x68) Image search: [Google]
Binary.png
5 KB, 243x68
Does anyone know how to get these pic related fractional binary objects in python (2.7)?

I know how to do XOR operations with integer binary numbers for example
>>> 0b10 ^ 0b11    
1
>>>bin(0b10 ^ 0b11 )
'0b1'

etc. But the bin() function only accepts an integer input and in general Python doesn't seem to like none integer binary representations, for example if I try to call it directly:

>>> 0b0.101
File "<stdin>", line 1
0b0.101
^
SyntaxError: invalid syntax



Any ideas?
>>
>tfw it takes an hour and a half to get a good programming flow going, and then after 4 hours you're mentally checked out for the day
>>
Do you think I should learn C# or Java next. I am already familiar with visual studio so am leaning towards C#. thoughts?
>>
File: coders world.png (137 KB, 704x768) Image search: [Google]
coders world.png
137 KB, 704x768
>>53751717
>>53752035
This.

Move the declaration to immediately after the HashSet one at the beginning of the method.
>>
>>53752094
>visual studio
Kanker
>>
>>53752070
depends on if you are learning or implementing something you want to.
You could always force feed yourself coffee.
>>
>>53752106
>You could always force feed yourself coffee.
this Tbh
>>
>>53751717
Your return counter is out of scope

Your it Iterator it.hasNext is caught in a very long loop of checking over and over again hmmmm I wonder why
>>
>>53752094
do you have a particular purpose in mind? what do you know already? anyway i'd suggest java
>>
>>53752106
>depends on if you are learning or implementing something you want to
It's a bit of both.
I can still program stuff, but I become spacey and any larger design stuff I need to do becomes hard to think about.
It doesn't help that I'm also retarded.
>>
>>53752132
>>53752103
>>53751999

Thanks

This is my new code

import java.util.*;

public class Testing {
public static void main(String[] args){
Testing game = new Testing();
String[] player = {"apple", "apple", "orange", "strawberry"};
String[] dictionary = {"strawberry", "orange", "grapefruit", "watermelon"};

int points = game.count(player,dictionary);
System.out.print(points);
}

public int count(String[] player, String[] dictionary) {
int counter = 0;
HashSet<String> hset = new HashSet<String>();
for(int i = 0; i<player.length; i++){
String player_word = player[i];
hset.add(player_word);


Iterator<String> it = hset.iterator();

while(it.hasNext()) {
for(String s:dictionary){
if(s.equals(player_word)){
counter +=player_word.length()*player_word.length();


}

}
}
return counter;

}



}
}


I receive the following errors from the IDE

Exception in thread "main" java.lang.Error: Unresolved compilation problem: 
This method must return a result of type int

at Testing.count(Testing.java:13)
at Testing.main(Testing.java:9)



>at Testing.count(Testing.java:13)

Points me to public int count(String[] player, String[] dictionary) {

Saying method must return type int

and

>at Testing.main(Testing.java:9)

Points me to int points = game.count(player,dictionary);

I don't understand what's going on. I'm getting confused by the brackets so not sure how to tell if it's in scope of not
>>
>>53752189
put return counter at the end of the method, outside the for loop

also use eclipse
>>
>>53749099
>Initialized data type in a string
What do you mean

Usually you do sizeof (variable)/sizeof (type)
>>
File: SO8388z.png (3 KB, 254x291) Image search: [Google]
SO8388z.png
3 KB, 254x291
>>53752189
Use Allman style if that bracket style confuses you.

I prefer Allman style anyway.
>>
>>53752103
Change the caption to
>Pajeet's World
>>
>>53752189
http://www.tutorialspoint.com/java/java_using_iterator.htm

http://beginnersbook.com/2013/12/hashset-class-in-java-with-example/
>>
>>53751717
>isn't compiling
does it give you an error?
>>
>>53752361
You've never in your life written code that work, and you can't immediately discern why?

You've never in your entire life written code that is broken that is not an immediate fix, and required a bit of research?

Fuck off, retard. You're watering down the concept of 'Pajeet' and PIL programmers in general.

Unless you actually are Indian and this is your way of combating the meme: by spamming it until it's meaningless.
>>
File: anonPls.gif (3 MB, 356x200) Image search: [Google]
anonPls.gif
3 MB, 356x200
>>53752180
lets be retarded together.
>>
>>53752392
i fucked up looked like end my bad
>>
>>53752395
wew lad
Your autism is showing
>>
File: 1458787492954.jpg (16 KB, 604x453) Image search: [Google]
1458787492954.jpg
16 KB, 604x453
>>53750769

Anon, I'm confused. You say that you're in school at the moment, so why don't you take some classes that will actually teach you how to program properly?

I mean hell, if you're finding business too easy, why not get a computer science minor?
>>
>>53752067
Allright so I figured out this little "trick" to use integer binaries and then just devide the denomenator fraction.

>>> A = 0b11100 
>>> B = 0b01010
>>> C = 0b00111

>>> nom = A ^ B ^ C
>>> den = 2 ** (len(bin(A)) - 2)
>>> nom
17
>>> den
32
>>> float(nom/den)
0.0
>>> float(nom)/float(den)
0.53125
>>>



Now I want to write a general function that will take an arbitrary amount of binary input strings, something like:

def fracbin_xor(*A):
nom = A[0] ^ A[1] ^ A[2] ... ^ A[len(A)]
den = 2 ** (len(bin(A[0])) - 2)


Where A is a tuple/list of binary strings. Does anyone know how to write
 nom = A[0] ^ A[1] ^ A[2] ... ^ A[len(A)] 
without resorting to exec statements?
>>
File: 1450329518338.jpg (23 KB, 300x300) Image search: [Google]
1450329518338.jpg
23 KB, 300x300
>>53752345
Thanks. I'll do that.

>>53752261
Okay, using ecplise now. I believe I put the return counter at the end of the method. Now there are no errors during compile time, but whenever I run the program nothing happens.

What's going on there?

import java.util.*;

public class Testing {
public static void main(String[] args){
Testing game = new Testing();
String[] player = {"apple", "apple", "orange", "strawberry"};
String[] dictionary = {"strawberry", "orange", "grapefruit", "watermelon"};

int points = game.count(player,dictionary);
System.out.print(points);
}

public int count(String[] player, String[] dictionary) {
int counter = 0;
HashSet<String> hset = new HashSet<String>();
for(int i = 0; i<player.length; i++){
String player_word = player[i];
hset.add(player_word);


Iterator<String> it = hset.iterator();

while(it.hasNext()) {
for(String s:dictionary){
if(s.equals(player_word)){
counter +=player_word.length()*player_word.length();


}

}
}

}
return counter;
}

}
>>
>>53752554
What about

list(itertools.accumulate(A, operator.xor))[-1]
>>
File: 1458750734787.png (336 KB, 1440x2560) Image search: [Google]
1458750734787.png
336 KB, 1440x2560
Any RegEx wizards here?

Trying to match 'ayylmao' and then 'foobar' from the following:
Critical Alert _ ayylmao _  foobar _ TNA - Unresponsive Servers


Two expressions would be best, one for each.

Can't seem to get the capture groups right.
>>
how can I and and existing repo as a submodule to my repo on github?
>>
>>53752395
>You've never in your life written code that work, and you can't immediately discern why?
what

you don't write random bullshit and have it randomly work, you write code carefully and deliberately, unless you're using some kind of toy language and doing some amateur bullcrap
>>
I'm working on some code that helps me visualize 3d translations/rotations as well as things like normals to better understand opengl and shaders. I'm the same guy that's been working on the webgl game. Hopefully have some screenies before the days up.
>>
>>53752762
well it should print a number to the console no matter what. have you set the run configuration to run Testing.java?
>>
>>53752920
Also making some of my other classes more generic.
>>
>>53752837
\_\s{1,2}\w+

This also captures TNA though.
>>
>>53753006
Thanks, I should have mentioned that it could also be 'ayy-lmao', so it stops at the hyphen in that case.
>>
>>53753023
\_\s{1,2}[a-zA-Z0-9\-]+

Is more flexible.
>>
>>53752927
Yeah, I believe so and it's not outputting anything to the console. I tried using other .java programs I created and ran them and they outputted something. For some reason this one outputs nothing.
>>
>>53752837
_ (.*?) _  (.*?) _
>>
What's a good tutorial for lambdas in C++?
>>
>>53753076
Hawt, thanks.
>>
>>53752837
Fuck it, going full Rajesh on this shit:

SUBSTRING(Summary, CHARINDEX('_', Summary, 1) + 1, CHARINDEX('_', Summary, CHARINDEX('_', Summary, 1) + 1) - CHARINDEX('_', Summary, 1) - 1)
>>
>>53752395
panjeet my son
>>
It is CRUEL and UNUSUAL and INHUMANE to make programmers prototype their own UI before getting the graphical designer to do a pass.

That is all.
>>
>>53753293
Even worse when it turns out they have no designer at all, and you tell them that wasn't the deal, and they find a designer, but all he does is a PS mockup that you have to program into UI, this is when you quit the contract and tell them to fuck off. I've canceled 8k EUR deal because of that once, fuck working with incompetent people.
>>
>>53753293
UI is fun though. JavaFX makes it easy.
>>
>>53753326
>UI is fun
Are you mad?
>>
>>53748407
I'm alright at programming (java, python, javascript as long as it's used for algorithms and shit), but i completey suck at GUI development and web development (html, css, jquery, and all that jazz).
Now for GUIs, there are useful IDEs like Netbeans has a GUI Builder,
but how do i learn web development?
>>
Recommend me some books on C, C++, books that actually teach you shit and is not a follow this and that. I'm planning on starting a fun little project, game engine development using id Tech 3 as base.
>>
File: 3s2RtqD.png (10 KB, 396x248) Image search: [Google]
3s2RtqD.png
10 KB, 396x248
I AM BECOME PAJEET

DESTROYER OF DATABASE PERFORMANCE
>>
>>53753524
I'll shoot on sight if I ever see that in production.
>>
>>53753524
Please, for the love of god, I would kill myself, if I had to work with that.
>>
>>53751013
C macros are not supposed to be turing complete.
>>
>>53752796
Thank you based Anon.
>>
ayyy
https://github.com/yjhuoh/is-not-array
>>
File: 01TWsRH.png (22 KB, 481x446) Image search: [Google]
01TWsRH.png
22 KB, 481x446
>>53753524
>>53753533
>>53753550
HA HA

I'M GOING TO JOIN ON THE TEXT RESULT OF THE SECOND THING

AND I WILL TUCK THIS INTO AN OBSCURELY NAMED VIEW AND NO ONE WILL EVER KNOW
>>
File: sql.png (133 KB, 1076x1300) Image search: [Google]
sql.png
133 KB, 1076x1300
>>53753524
sql is the nice language
>>
>>53753640
Why don't you use:
>>53753076
That regexp is perfect.
>>
>>53753666
Because SQL can't into pulling text from a field based on a RegEx match.

You can return rows if they CONTAIN/ARE a match, but not the match itself.
>>
>>53753631
>
'use strict';
var isArray = require('isarray')

module.exports = function(obj) {
return !isArray(obj)
}
>>
if(tweeter = gamergater){
cout>>"block">>
else if (tweet = negative){
cout>>"block">>
>>
>>53753490
Seriously, no one can recommend some excellent books, on C, C++, that actually teach instead of make you do exercises? I want to understand all of the theory.
>>
>>53753712
dont forget to use it in your next project
>>
>>53753777
C is simple to learn but hard to master
you're better off looking at books on optimizing for <name> system and look up good code examples from opensoares projects n shiet nigga
>>
File: if.jpg (41 KB, 550x512) Image search: [Google]
if.jpg
41 KB, 550x512
>>53753326
>>
>>53753490
Anything by Scott Myers for C++ will do.
>>
>>53753763
genius
>>
>>53753524
Don't know a lick of DB. What's so memey about this?
>>
>>53753568

Right, and C++ templates are Turing complete, and they can do more than what macros could ever hope to accomplish.
>>
>>53753928
neither do i but that can be condensed to 1-2 lines of regex for the variables client adn machine
>>
>>53753524
Highly inefficient because every query does string manipulation to extract data, instead of processing the data in the backend and inserting values into appropriate table fields.
>>
>>53753840
>>53753869
Thanks, anons, will look into both of what you recommend.
>>
Is there the equivalent of Python's payload in C++?
>>
File: pysoccer.webm (940 KB, 1920x1080) Image search: [Google]
pysoccer.webm
940 KB, 1920x1080
Still working on my python turn based soccer game.
>>
>>53754011
What do you exactly mean by payload?
>>
did you ever write (working) code that you didnt understand yourself
>>
>>53754042
no
>>
>>53754032
payload = {'action': 'login',
'login': login,
'auto_login' : '1',
'password': password}
>>
>>53754042
Careful, anon.

Everyone is going to call you Pajeet and Rajeesh, because surely they've never done this.
>>
print "Hello world!"


amidoinitrite?
>>
>>53754061
So a map holding a struct union?
>>
>>53754066
explain yourself idiot

do you copy and paste code for a living and that's why you don't understand what you "write"? then you're a tip top codemonkey/pajeet, faggot
>>
>>53754026
Ever seen Tecmo Cup?
>>
>>53754066
I don't really care about the autism of non-coders, so they can call me whatever they like.
>>
>>53754079
Sure, whatever that means.

I'm that anon that's trying to re-write a python script into C++
>>
>>53754061
>>53754079
Actually you're passing in just strings so a map<string, string>.

>>53754110
I first thought you'd want a flexible type that can index various value types by a key but in that case all you need is what I said above.

What script are you trying to rewrite? I've not been following.
>>
>>53754100
HOW can you write something that works without understanding it, unless you're literally copying and pasting or mindlessly writing down something your memorized like a literal PAJEET
>>
>writing some random bullshit without understanding it and magically it works
WHO THE FUCK DOES THAT

SERIOUSLY

WHO THE FUCK DOES THAT
>>
>>53754088
No.
>>
>>53754134
Honestly, when learning a new library, language, or framework, the easiest way to learn is to
>copy/paste an example segment
>test it with some data to see what it does
>learn how it works
>modify it to suit your purposes

After that, you start to put together concepts within a framework or language and you just end up writing without having to research.

If you claim that you've never copied code from a book or a website to try it out and see what it does, then you're simply lying.

inb4okaypajeet
>>
>>53754214
then you didn't actually write it, idiot

and the non-pajeet way to learn something is to RTFM
>>
>>53754134
>write complex code
>return to it after days/weeks
>???
that obviously never happens when you only write fizzbuzz on g
>>
>>53754240
fucking idiot, if it's well written you can easily 'decipher' it, fucking smug dunning-kruger newfag
>>
>>53754261
as you say, fizzbuzzer
>>
>>53754275
ok delusional RETARD
>>
File: 1418682201739.png (250 KB, 649x616) Image search: [Google]
1418682201739.png
250 KB, 649x616
>>53754285
you seem tense. do you want to talk about it?
>>
>>53754300
your'e mom
>>
>>53750838
Nice OS anon.
>>
Does understanding assembly help to become a better programmer?
>>
when i run


#!/bin/bash
while read line; do
if [ -f $line ]; then
echo $line
fi
done < "${1:-/dev/stdin}"



it says


line 3: [: classes: binary operator expected


and i dont understand why? pls halp
>>
>>53754467
Replace that with:
[[ -f $line ]]
>>
>>53754457

There are a bunch of different assembly languages, most, if not all of which, you will likely never program in. Nonetheless, it may help to learn assembly to gain a better perspective.
>>
File: out.webm (784 KB, 1240x1024) Image search: [Google]
out.webm
784 KB, 1240x1024
Fucking libgd.
>>
>>53754467
Word splitting, your ${line} must contain a space. Quote "${line}" or use [[.
>>
>>53754538
>>53754501
thanks this fixed it :]
>>
>>53754467
[ -f $file]
is most likely right I checked. Maybe it's because $file is empty, owing to the fact that you don't write anything on the prompt and press enter? Try calling [ ] at the shell prompt to experiment.
>>
>>53754573
>>53754538
Nevermind, you're more correct
>>
>>53752796
reduce(operator.xor, A)
>>
>>53754518
>it may help to learn assembly to gain a better perspective.

Yeah, that is what I'm aiming to do.
Not necessarily to use as a programming language itself but to get a better grasp on programming itself.
>>
Been beating my head against the wall for a while over this.

I don't get an int or a compile error. I get nothing when I execute this. Any ideas what is going on?


import java.util.*;

public class Testing {
public static void main(String[] args){
Testing game = new Testing();
String[] player = {"apple", "apple", "orange", "strawberry"};
String[] dictionary = {"strawberry", "orange", "grapefruit", "watermelon"};

int points = game.count(player,dictionary);
System.out.print(points);
}

public int count(String[] player, String[] dictionary) {
int counter = 0;
HashSet<String> hset = new HashSet<String>();
for(int i = 0; i<player.length; i++){
String player_word = player[i];
hset.add(player_word);


Iterator<String> it = hset.iterator();

while(it.hasNext()) {
for(String s:dictionary){
if(s.equals(player_word)){
counter +=player_word.length()*player_word.length();


}

}
}

}
return counter;
}

}

>>
File: heapsort.gif (130 KB, 560x432) Image search: [Google]
heapsort.gif
130 KB, 560x432
>>53748407
heapsort.c
>>
File: wrong.jpg (63 KB, 800x227) Image search: [Google]
wrong.jpg
63 KB, 800x227
starting up in java again after years of embedded c programming experience (irrelevant fact I know)

I need to know if there's a best practices that says you shouldn't do something like the following:

taking a linked list as a constructor argument then adding the object to the linked list within the constructor

example code:
public class SomeFaggyGameObject {

float testicle1;
float testicle2;

public SomeFaggyGameObject (LinkedList<SomeFaggyGameObject> circleJerkList) {
testicle1 = 0.0f;
testicle2 = 0.0f;

circleJerkList.add(this);
}
}


only reason I might do it like that is to try to match the convention used with some other library that I probably don't fully understand
>>
>>53754687
I don't use Java but are you sure modifying the list inside constructor even changes the original reference?.
>>
What's the proper way to handle exceptions in C? I'm talking mostly about user input, i.e entering a character instead of a number. Obviously you could loop until something acceptable is entered, but what about situations where nothing else can be done, and so the program needs to end?

Something like
int main()
{
//do stuff
if (condition1 == met)
{
//do stuff
if (condition2 == met)
{
//do stuff
if (condition3 == met)
{
//rest of program
return EXIT_SUCCESS;
}
}
}
return EXIT_FAILURE;
}

doesn't seem right.

Something like:
int main()
{
//do stuff
if (condition != met)
goto end;
//rest of code

end:
//deactivate memory
return 0;
}

Seems to go against the idea of structured programming.

And something like:
int main()
{
//do stuff
if (condition1 != met)
return error(1);

//more stuff
if (condition2 != met)
return error(2);

//more stuff
if (condition3 != met)
return error(3);

//rest of program
return EXIT_SUCCESS;
}

int error(int e)
{
printf("Error #%u\n", e);
//deactivate memory
return EXIT_FAILURE;
}

seems like it would work, but it still doesn't seem right.
>>
>>53754643
Use breakpoints.

Step through your code one line at a time.
>>
>>53754732
honestly I haven't even tested it yet. There's a lot of junk I'm trying to clean up and encapsulate and I want to be sure I do it right before I go all in
>>
>>53753053
I think your game.count(player,dictionary) call is getting stuck in its while loop.
>>
>>53754687
A constructor should only initialize the instance for further use and nothing else. You don't necessarily expect it to modify your parameters, so what you're doing seems like a bad idea.
>>
>>53754744
What do you mean by break points? I'm new to programming... so not obvious to me where they should be.

I don't understand why it's not working. The return statement is outside of the for loop and still inside the method.


public int count(String[] player, String[] dictionary) {
int counter = 0;
HashSet<String> hset = new HashSet<String>();
for(int i = 0; i<player.length; i++){
String player_word = player[i];
hset.add(player_word);


Iterator<String> it = hset.iterator();

while(it.hasNext()) {
for(String s:dictionary){
if(s.equals(player_word)){
counter +=player_word.length()*player_word.length();


}

}
}

}
return counter;
}

>>
>>53754757
but that got me thinking, thanks

I was thinking of it being like a pointer

though if it is a reference wouldn't it modify the original object if passed in as an argument?
>>
>>53754808
You're checking if(it.hasNext()), but you never call it.next() to actually advance the iterator. it.hasNext() will always return true.
>>
>>53754660
That's beautiful.
The .gif is only 130KB, wow.
I love your font, what's it called?
Nice choice for background, btw. ;)
>>
>>53754808
why are you looping thrpugh the array AND through the hashset?
>>
I asked on the another thread but here we go:
Is needed know anything of maths for programming? I'm reading a book for python and all the challenges are like """calculate""" the vectorial point of shit
?????
any real challenges for real jobs? i don't want calculate things i don't know and just copy/paste random code from internet
>>
>>53754888
Font is ProFont I think: http://www.tobias-jung.de/seekingprofont/
>>
>>53754849
How do I fix that? First time I ever used it.hasNext()
>>
>>53754899
Ladies and gentleman, an ACTUAL Pajeet has graced us with his presence.
>>
>>53754899
>just copy/paste random code from internet
There's no way you'll be able to do this and make big projects
>>
>>53754899
Depends on the field you're working in. Desktop/mobile """app""" development requires a minimal amount of math. Proper game development requires trigonometry. DSP requires specific knowledge on algorithms like FFT. Though math does help you in solving problems.
>>
>>53754849
Why will
while(it.hasNext())


Always be true? I thought it was a boolean that checks to see if there is a next iteration, so why need to call it.next() explicitly? I never used iterators so I don't know lol.
>>
File: superfappable!.png (1018 KB, 640x941) Image search: [Google]
superfappable!.png
1018 KB, 640x941
What the fug? I'm getting the following error:
no such table: file

This is my update statement:
UPDATE files SET status=? WHERE id=?

This is my create table statement:
CREATE TABLE IF NOT EXISTS files(
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
status INTEGER NOT NULL
)

Am I fucking retarded or what?
>>
>>53755056
reserved word?
>>
>>53754042
Write or copy?
Because I feel like the latter is more plausible.
>>
>>53755056
Change your UPDATE statement to this
UPDATE `files` SET 'status'=? WHERE 'id'=?
>>
>>53754917
go back to simpler stuff until you learn how linked lists, iterators, and other software structures work. what are you trying to do exactly? you can't be that far along if you don't even know how to use a debugger.
>>
>>53754899
sounds like web development is perfect for you
>>
>>53755027
the hasNext() is a check people use before calling next(), which returns the current object and moves your iterator to the next one in the list. They do this to avoid an exception
>>
>>53755176
>UPDATE `files` SET 'status'=? WHERE 'id'=?
>WHERE 'id'=?
>'id'=?
>'id'
>'
>>
>>53755228
Thought you were querying it indirectly, don't use ''
Just make the files part in between ``
>>
>>53755135
I've looked into https://www.sqlite.org/lang_keywords.html, but the name of the table and columns are unique.
>>53755176
It's still not working for some fucking retarded reason. It does work when I use the sqlite3 CLI tool though. Fucking CIA niggers.
>>
>>53754131
http://pastebin.com/SebiDJPj
I'm not the original author. I'm re-writing this for ease of access. The python script currently requires installing Python 2.7, alongside the requests module. My idea is to re-write this into C++ so you can just double-click an .exe and have the app be more lightweight.

The script's aim is to visit profiles on a site called Interpals (don't ask why) and to log all usernames visited in a text file. The script takes breaks in order to avoid detection. Any usernames logged will not be visited again, and will be skipped. The script can also set parameters for the age gap of users, the gender and its respective countries.
>>
>>53754899
but if you're serious, in general, if you want to be a solid software developer:

discrete math, bare-minimum of calculus, solid algebra skills, and definitely some trigonometry

you need discrete math and algebra to understand a lot of algorithms and design techniques and be able to perform analysis


if you want to be an actual computer scientist, you should probably learn even more math than that.
>>
>>53755313
Should have stated in your first post, you were working with sqlite.

Changing the update statemnt does shit, but the sqlite3 CLI tool works? That's strange and just wtf. Been a while since I fucked with sqlite
>>
>>53755375
My bad. It's a Go binding for SQLite. I pulled in the latest sources from master, but still no success.
If I run the query in 'sqlite3', it works like a charm.
>>
>>53755430
Hmm, what are you developing, if I may ask?
>>
>>53754741
I think the goto method would be the cleanest, as long as it doesn't get more complicated than your example, just a single label for cleanup.
>>
>>53755459
have you listened to your self?!
>>
>>53755348
>>53754899

Bare minimum a course in intro proofs, a separate course in logic, discrete mathematics, data structures and algorithms should serve you well.
>>
File: javarepl.png (20 KB, 525x309) Image search: [Google]
javarepl.png
20 KB, 525x309
Hey /g/, experienced Scheme Alchemist here.
I've been programming in Java (yuck!) with someone who was doing it because of their degree and who had had no programming experience before, and I've noted how confusing and limiting java can be sometimes. Since I like flaming discussions on /dpt/, I'll share a bit of my remarks:

1 - Java has no REPL, Java isn't designed to have a REPL, Java is designed not to have a REPL. Seriously, pic related is my attempt at an online self-proclaimed Java REPL and I'm categorical: ceci n'est pas une REPL. This is surprising to me because most of the times, a REPL is the best tool for quickly testing things out with a short “feedback circle” if you want to get buzzwordy, while being sure that syntax errors are detected right away and logic errors quickly after. It really feels like a real conversation with a computer that understands you, and I remember beginning to program at a REPL, although it was in Python. Otherwise, it's like teaching three years old who can speak how to write a good essay, it's nonsense. And even the best adult writers still have enriching conversations.

2 - Java is a domain-specific language, or at least, enginereed to be so, albeit not voluntarily. Java assigns all of its syntax to a few things, mainly a narrow set of “operators” on “primtive” data, and classes and methods, nothing more. Everything else is treated as some dirty, discriminated-against downtown: try a Java bignum lib for example. It is not extensible, yet it still manages to hit a high-score in terms of verbosity. Java can't call itself a general-purpose programming language, because it's not. It's a bloated number, string, array, and object processor.

So, Javanons, defend your cult.
>>
What Maths does vidya development require, and to what level?

Britfag here, I've studied Maths to a GCSE level, and computing to A-Level. What Maths skills are required, other than trigonometry? I'm willing to self-teach, assuming my current knowledge is insufficient
>>
>>53755492
I don't like java. If it were up to me I'd program in Python and Haskell. I'm forced to follow the java cult due to university requirements. I have a friend that hates java and he complains every time I talk about it, but he's not forced to it like I am due to him being out of the classroom.
>>
>>53755441
https://gitgud.io/0xBA5/matcha
It's a HTTP file server to manage my files downloaded through bittorrent.
I'm currently able to list all the downloaded files from bittorrent. Eventually I want to add RSS feeds.
>>
>>53755517
linear algebra, logic and discrete math, possibly calculus.
>>
>>53755531
Really, giving in to OOP nonsense is more about asserting your competence rather than really having some. It's all social engineering, since most things are half-truths and brainwashing. Good luck resisting all of this.
>>
I need a book on systems and writing OSes for a person who knows nothing about the matter.

But I need it to be difficult, filled with exercises and challenging.

THere has to be such a book out there.
>>
>>53755517
I think for game development, one should have solid calculus and also linear algebra skills.
>>
>>53755561
secretly resisting I mean. You still have to look like you agree. But then, good programmers can break the rules(tm) when it makes more sense, and admit that OOP is not the Next Big Thing it claims to be since long ago.
For those interested: http://www.smashcompany.com/technology/object-oriented-programming-is-an-expensive-disaster-which-must-end
A complicated ideology requires a complicated takedown, sorry about that.
>>
>>53755608
Linux Programming Interface?

http://man7.org/tlpi/

It's unix / linux tho.
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.