[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Click for more| Home]

Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 351
Thread images: 24

File: tornado.png (692KB, 560x700px) Image search: [iqdb] [SauceNao] [Google]
tornado.png
692KB, 560x700px
Tornado edition.

What are you working on?

Previous thread: >>47013506
>>
Working on the unit testing for my project.I was using google test, but I want to move into something original
>>
>>47023099
>https://gist.github.com/DEElekgolo/cf0ac817b6659f413e6b

holy hell how do you even come up with this kind of algorithm
>>
File: ahhHHHHHHHH.gif (1010KB, 450x402px) Image search: [iqdb] [SauceNao] [Google]
ahhHHHHHHHH.gif
1010KB, 450x402px
>>47023162
>Grid[x += dx[dir]][y += dy[dir]] = j + 1 == js ? "\xC0\xDA\xBF\xd9"[dir] : "\xC4\xB3"[dir & 1];
>>
I'm trying to figure out something to do. I don't think I've ever written more than ~100-200 lines of code, and I've never written anything particularly useful on my own. I'm thinking of making a web browser in Python, but that's going to take a lot of research.

Also, code looks awesome in the Tomorrow theme.

def faggot():
op_is_fag = True
if op_is_fag:
print("OP is a fag.")
else:
print("OP is still a fag.")
>>
>>47023148
Finished up a script for my police scanner app
It displays the current channel and radio transmitting on a 2x20 LCD mounted to a 5.25" drive bay on my 4U rackmount server that runs the scanner software.
>>
>>47023191
>python

gross
>>
>>47023199
...you're calling that an 'app'?
what has the world come to.
>>
>>47023191
Python

you tried
>>
As someone was saying in a previous thread, I can join a server and now my bot will stay in the server until a 30 second ping timeout. How do I keep sending pings back every 29 seconds? (C++, Irc.)

#include <iostream>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>

using namespace std;

bool sendRawPacket(char *msg, int sockfd){
int len = strlen(msg);
int sentbytes = send(sockfd,msg,len,0);
if(sentbytes == 0){
return false;
}else{
return true;
}
}


int main(int argc, const char* argv[]) {
struct sockaddr_in sock;
char buffer[256];
int sockfd = socket(PF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
perror("socket");
return 1;
}

sock.sin_family = AF_INET;
sock.sin_port = htons(6667);
sock.sin_addr.s_addr = inet_addr("54.164.27.70");

int k = connect(sockfd, (struct sockaddr*)&sock, sizeof sock);
if (k < 0) {
perror("connect");
return 1;
}
sendRawPacket("USER gay gay.balls lol :gay\r\n", sockfd);
sendRawPacket("NICK rarbot\r\n", sockfd);
sendRawPacket("JOIN #channelname\r\n", sockfd);
// close(sockfd);

//we need a loop here to look for pings and process messages/commands

while(recv(sockfd, buffer, 255, 0) > 0) {
// ??????? lets try it
}


cout << "Program terminated. Goodbye!\n";
return 0;
}
//make ur screen bigger, that way i can have more space to edit in
//expand putty pls
//wtf, for some reason its still too small lol
>>
>>47023254
reading comprehension

It's not an app
It's (a module) for an app.
>>
>>47023264
As I said, you need to find the PING's and respond with a PONG. It'll have a string which comes with it, which you need to send back. Use a regular expression.
>>
>>47023213
>>47023255
>Bashing Python
>2015
>>
>>47023148
>Making a file transfer protocol akin to ftp

just the difference being i will only use it for transfering games from my home server to my phone, all are actually emulator roms.

The application will have a nice graphical frontend on my phone so that i can browse games in comfort (and brag about it to colleagues hehe). It will also support cover image for every games so that i dont have to read the filename to identify the games...

>A visual novel game
I am fluent in C, what should i use to make my game, if i want it to be cross platform? Anyone?
>>
>>47023279
>use a regular expression
You should be parsing all IRC commands into arguments. You don't use regex for that.
>>47023264
>The PING command is used to test the presence of an active client or server at the other end of the connection.
>When a PING message is received, the appropriate PONG message MUST be sent
i.e., you cannot rely on a server sending you a PING, so not only must you listen for one, you should be sending one yourself.
if you can make your main loop not block (recv), and check the time every so often, you can make sure to send a heartbeat at predefined intervals.
>>
>>47023336
Regex was a suggestion, makes dealing with IRC easy as fuck. You can't just "send one yourself". Not all servers accept a plain ping. Some send a string which you need to send back.
>>
>>47023372
>Not all servers accept a plain ping.
uh, what?
>When a PING message is received, the appropriate PONG message MUST be sent
what don't you understand about MUST?
>>
>>47023388
That's what I'm saying, it (the accompanied string) MUST be sent back.
Just sending "PING" wont work.
Apparently I misunderstood you. When you said
>i.e., you cannot rely on a server sending you a PING, so not only must you listen for one, you should be sending one yourself.
I thought you meant just sending "PING" and nothing more.
>>
File: dran0026.jpg (484KB, 1664x1280px) Image search: [iqdb] [SauceNao] [Google]
dran0026.jpg
484KB, 1664x1280px
>>47023148
Reverse enginnering files from a game, Pool of Radiance. Putting together a Python script to extract the maps.

The game was kind of shit but it did have some nice art. Pic related.
>>
>>47023420
ah, ok
'a PING command' might've been better wording
>>
>>47023431
I wrote a huge IRC MUD a couple years back in perl. It was massive. I lost interest since it got so messy. It was my tutorial to perl, so everything I learned I would add in. As you can imagine, older code was very poor. I've been thinking about redoing it in C just for the practice, as I've switched to C.

Shit had everything though.
PVP, random encounters, raids, global weather, spells which affected monsters and players, quests, my god everything I could think of. Worked on it for a good two years.
>>
Big time pleb here

I just want to make a small question about UML diagrams, I'm supposed to design a class and this popped up in the diagram
>+ char getSize( ) const

Is the "const" part supposed to be going along with the return type of the function?
Like const char getSize()?
>>
>>47023426
Before reading your message, I thought this was some sort of Icewind Dale II high-res graphics.
>>
>>47023457
>huge IRC MUD
>perl

May god have mercy on your soul.
>>
>>47023597
Why? Perl is fantastic for working with IRC. I had a blast making it.
>>
a website

its mainly going to be used for porn
>>
>>47023611
that reminds me, I was starting to mirror exhentai to git repositories using github
>>
>>47023191
>Le meme
>>
>>47023611

That reminds me, I need to get back to working on my wobsite.
>>
The IRC fag here. i want to only read upto \0 (end of file), so basically just that packet and cout ONLY that packet (until a new packet comes, of course) but its putting shit at the end from the last packets.

#include <iostream>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>

using namespace std;

bool sendRawPacket(char *msg, int sockfd){
int len = strlen(msg);
int sentbytes = send(sockfd,msg,len,0);
if(sentbytes == 0){
return false;
}else{
return true;
}
}


int main(int argc, const char* argv[]) {
struct sockaddr_in sock;
int sockfd = socket(PF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
perror("socket");
return 1;
}

sock.sin_family = AF_INET;
sock.sin_port = htons(6667);
sock.sin_addr.s_addr = inet_addr("54.164.27.70");

int k = connect(sockfd, (struct sockaddr*)&sock, sizeof sock);
if (k < 0) {
perror("connect");
return 1;
}
sendRawPacket("USER gay gay.balls lol :gay\r\n", sockfd);
sendRawPacket("NICK rarbot\r\n", sockfd);
sendRawPacket("JOIN #niggersack\r\n", sockfd);
sendRawPacket("PRIVMSG #niggersack :sup niggers?\r\n", sockfd);

int rc;
int MAXSIZE = 1024;
char buf[MAXSIZE];
while(1){
rc = recv(sockfd, buf, sizeof(buf), 0);
if(rc > 0) {

}
}

cout << "sHIT FUCK DICK BALLS!\n"; //hope we never see this message lol
return 0;
}


help
>>
>>47023582
Close. The game rules the D&D ruleset like Icewind Dales does.
>>
>try to finish project
>oh fuck, this shit is so hard
>tab to /g/
>end up having nothing of value for github
>never get job
>starve
>>
>>47023802
are you saying projects on github equate to job opportunities?
>>
I'm putting together registration / login scripts for a web service.

If I want a per user unique salt is it enough to use some application constant random number concatenated with the username and maybe the domain name? or is the username not really helpful?
>>
>>47023817
drop what you're doing, and use bcrypt.
here's some from my user file.
var Promise = require('bluebird')
, bcrypt = Promise.promisifyAll(require('bcrypt'))
, SALT_WORK_FACTOR = 10

//plaintext -> hash, using bcrypt
function hashPassword(password, _, next) {
return bcrypt.genSaltAsync(SALT_WORK_FACTOR).then(function(salt) {
// hash the password along with our new salt
return bcrypt.hashAsync(password, salt);
});
}
>>
>>47023808
no but I hear it helps
>>
>>47023264
Your send function should loop until the entire packet has been sent. TCP is a streaming protocol.
>>
>>47023846
there's no need for the '_' and 'next' parameters here, I just copied my code wrong

>>47023852
>until the entire packet has been sent
until a CRLF pair has been sent*
>>
>>47023858
Well yeah, in case of IRC the packet should end with \r\n but the statement is valid nonetheless.
>>
>>47023870
valid? how
TCP is a streaming protocol, as you say
you cannot be certain whether you are reading two packets, one packet, a half a packet, etc
I assume most TCP servers will buffer things up too, so you're going to get more than one line per packet, too.
>>
>>47023881
Sending a "packet".
bool sendRawPacket(const char *msg, size_t size, int fd)
{
int sent = 0;
while(sent < size)
{
int current = send(fd, msg, size - sent, 0);
if(current == 0)
return false;

sent += current;
}

return true;
}
>>
>>47023886

bool sendRawPacket(char *msg, int sockfd){
int len = strlen(msg);
int sentbytes = send(sockfd,msg,len,0);

if(sentbytes == 0){
return false;
}else{
return true;
}
}
>>
>>47023892

Also, receive

void Receive(char* buffer, int sockfd){
int n = 0;
while((n = ::recv(sockfd, buffer, strlen(buffer), 0)) 0){
buffer[n] = 0;
}
}


kek

 int rc;
int MAXSIZE = 1024;
char buf[MAXSIZE];
string strmsg = "";
while(1){
Receive(buf, sockfd);
cout << buf << endl;

}
>>
>>47023886
oh, sending
sorry my bad, thought you were talking about receiving.
>>
>>47023148
couple of us over at #/g/technology are working on a chat bot in C++. the goal is to keep it protocol agnostic (we've only implemented IRC, though)

https://github.com/GreenBagels/greenbot
>>
>>47023846
I have the scrypt module installed, it works similarly.
generating a random salt is the default behavior if one isnt provided, but that wouldnt give me predictable behavior for verification....

or is there something I'm missing.

I do need to store the random salt somewhere If I do create one dont I?
>>
>>47023808
Literally don't fucking listen to anyone.

Having projects to put on your resume, even if they suck shit, can help. Most of the time they won't even look at your shit, but they will see that you can actually do something.

I've only done one interview where the guy was actually sitting there looking at my repos while talking to me. It's a scary yet great feeling.
>>
>>47023923
nah, bcrypt hashes actually _contain_ the salt (so you save the entire thing into db and you're good to go)
So my script generates the salt, then creates the hash using it.
to validate it, I have a simple function:
comparePassword: function(candidatePassword) {
return bcrypt.compareAsync(candidatePassword, this.getDataValue('password'));
}
>>
>>47023963
Okay, I guess I missed
>bytes 16-47: 32 [bytes] of random salt

but what is the point the salt being stored in plaintext along with the hmac?

isnt the whole point to disrupt offline password cracking of compromised databases?
>>
>>47024010
nvm, I guess if there is a unique salt, even if its stored in plaintext with the hmac, each password would need to be cracked independently...
>>
>>47024010
The whole point of the salt is to stop creating rainbow tables, and then using that to crack offline.
Having a per-user salt (like you were going to do) means that offline cracking is still possible, but there are no similarities between other users, making it even more of a useless task
>>47024031
ninja'd
>>
>>47023148
>no catalog-friendly /dpt/
>made me make a new one because I didnt find
>>
>>47024038
it's the tornado meme my friend, you must accept it
>>
>>47024054
although yes, I could've included '/dpt/' in the subject. Please forgive.
>>
File: 1426387961893.jpg (32KB, 373x346px) Image search: [iqdb] [SauceNao] [Google]
1426387961893.jpg
32KB, 373x346px
Alright, /dtp/. I am so fucking pissed with this shit. I just really need some help.

#include <iostream>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <cstdlib>
#include <cstdio>

using namespace std;

bool sendRawPacket(char *msg, int sockfd){
int len = strlen(msg);
int sentbytes = send(sockfd,msg,len,0);
if(sentbytes == 0){
return false;
}else{
return true;
}
}


int main(int argc, const char* argv[]) {
struct sockaddr_in sock;
int sockfd = socket(PF_INET, SOCK_STREAM, 0);
if (sockfd < 0) {
perror("socket");
return 1;
}

sock.sin_family = AF_INET;
sock.sin_port = htons(6667);
sock.sin_addr.s_addr = inet_addr("54.164.27.70");

int k = connect(sockfd, (struct sockaddr*)&sock, sizeof sock);
if (k < 0) {
perror("connect");
return 1;
}
sendRawPacket("USER gay gay.balls lol :gay\r\n", sockfd);
sendRawPacket("NICK rarbot\r\n", sockfd);
sendRawPacket("JOIN #niggersack\r\n", sockfd);
sendRawPacket("PRIVMSG #niggersack :sup niggers?\r\n", sockfd);

int rc;
int MAXSIZE = 65535;
char buf[MAXSIZE];

while(1){
rc = recv(sockfd, buf, sizeof(buf), 0);
if(rc > 0){
char *array;
array = new char[rc]; // doubt it. try it anyway mah nigga
array = buf;
cout << array << endl;
cout << flush;
// delete [] buf;
}
}

cout << "sHIT FUCK DICK BALLS!\n"; //hope we never see this message lol
return 0;
}


Literally, ALL I want returned is the packet and nothing else. WHAT THE FUCK AM ID OING GOD DAMN WRONG AND HOW DO IF IX IT
>>
>>47024116
>using namespace std;
kill you\'re self
>>
>>47024116
i think you're just plain retarded, give it up
>>
>>47024151

guess how many shits i give?
>>
>>47024116
You should send USER and NICK, then wait for PING, send PONG, wait for MOTD, then SEND JOIN and PRIVMSG. Also use >>47023886. Also fix your receive loop. Also https://tools.ietf.org/html/rfc2812.
>>
>>47024116
check out how it is done in >>47023915
>>
>>47024223
>You should send USER and NICK, then wait for PING
no, that's not what you should do
USER, NICK, then wait for RPL_WELCOME/001 (which implicitly comes after the MOTD)
>>
>>47024151
I implicitly define all of my js variables in the global namespace
>>
Babby level here. What do I need to be studying/learning to make graphical programs. I need dat gooey.
>>
>>47024401
search: "<your language>" "gui framework"
>>
Would it be possible to make a graphics library similar to that used in phones but for computer programs? I wouldn't mind making more GUI styled programs but the libraries available kinda suck.
>>
>>47024486
What language? [spoiler]Maybe its YOU who sucks[/spoiler]
>>
>>47024486
i'm sure it already exists.

it may not be explicit, do.this.like.android.does.this();

but I can imagine how I would build a swipe / click app in a couple languages.
>>
>>47024510
>>47024526
pure C, only one I know is GTK+ which looks kinda boring and generic
>>
>>47024528

see

>>47024441

select first 4 from wikipedia when lang == C
>agar
>xaw / athena
>clutter
>elementary

if you cant bother to read, you're already fucked

you can go back to /v/ now
>>
>>47024555
He was specifically asking for an android like framework.
>>
>>47024570
no, what he's asking for is an IDE to make the design easier, he just doesnt know it yet because he doesnt know how to use the google
>>
>>47024555
I sure do like my program looking like its from windows xp!

>>47024595
No, I want a more custom interface when making GUIs. With something like android or IOS you can use the default IDE or can customize it programmatically.

I want a library that can be used to make shitty XP clones or material-esque programs.
>>
>>47024441
>not searching "<your language> qt"
>>
File: 1286150929023.png (146KB, 521x818px) Image search: [iqdb] [SauceNao] [Google]
1286150929023.png
146KB, 521x818px
>>47007906
>>47008246
on snapdragon 800:
>branching, worst time (ns): 15740989
>polymorphism, worst time (ns): 4344479
i only measured the most significant "one-off" event, which is likely to be incorrectly branch predicted. the perceived improvement was obviously not placebo and these measurements (in addition to my hands-on experience) shows that simply having two extraneous branches can introduce game-ruining stuttering. the one with branching often took much more time than the worst time with polymorphism. brb taking 16 ms for one little thing in a 60-120 fps game. these findings definitely motivates me to further remove branching. the critical method i measured should be able to be improved significantly with polymorphism and i'm looking forward to implementing it. btw this method only takes up to tens of microseconds on a 3 GHz core 2 duo so it taking up to several milliseconds on an ARM processor doesn't necessarily mean it's terribly unoptimized.
>>
>>47024672
>60-120 fps game
with v-sync btw. aiming for a rock-solid vsynced frame rate, haven't even checked the non-vsynced frame rate.
>>
typedef std::string string;

or
using std::string;
?
>>
>>47023578
It means that the function doesn't change the state of the object.
>>
>>47023171
I was writing this kinda shit in my first year of C. Ain't hard niqqa.
>>
>>47024854
What did you use to learn C?
>>
>>47024801
nothing of them, just use std::string all time in your code
>>
>>47024994
>just use std::string all time in your code
Gross.
>>
>>47025015
Don't pollute.
>>
>>47025027
What? I've got all my data type changes secluded to a single file so none of the code is really "polluted".
>>
>>47024672
well i found the main cause of the performance disparity between ARM/android and wintel. apparently it takes multiple milliseconds to start playing one tiny sound. i presumed only low-end devices would be helped by turning the sound off. crikey m8

#thanksbasedgoogle
>>
>>47023578
>>47024807
>specifying that accessors don't change state
aaaaand this is why people don't like UML
>>
File: screen.jpg (180KB, 2805x759px) Image search: [iqdb] [SauceNao] [Google]
screen.jpg
180KB, 2805x759px
Sort of a stupid question. How do I make the buttons go beneath each other?
>Pic related is my CSS or is this HTML based?
>>
>>47023168
Looks like I have inspired a fellow autist :^)
>>
File: 1376505409276.jpg (48KB, 524x480px) Image search: [iqdb] [SauceNao] [Google]
1376505409276.jpg
48KB, 524x480px
>Programming assignment
>Write a server and client for a subset of TFTP
>Connections use UDP
>Get the client sending packets to the server
>Finish for the day, save my work and close everything
>Continue the next day
>Can't seem to get the client and server to communicate; the server never unblocks from recvfrom()
>I have no fucking idea if it's the client or the server that is broken
FUCKING UDP
>>
>>47025140
udp is fine fuck off.
>>47025128
inspired with what, tornado or the C# thread stuff
>>
>>47025161
UDP is not fine, it's unreliable. Only good for VoIP
>>
>>47025190

>only good for VOIP
>not good for all the video games that use it

get better internet
>>
>>47025161
New thread shit
>>
>>47025190
'unreliable'
technically yes, it's unreliable.
in practical use, packet loss doesn't happen, unless you actually have a bad connection

>>47025205
;_;
I was the first to come up with the 'tornado' word, and I wrote the code to create the OP image
oh well
I do like to thread stuff, I wonder if it can be adapted to other languages
>>
File: rekt.jpg (77KB, 687x361px) Image search: [iqdb] [SauceNao] [Google]
rekt.jpg
77KB, 687x361px
>>47025196
rekt
>>
>>47025211
Yeah I guess that's true
>>
>>47025211
>in practical use, packet loss doesn't happen
>Being this naive
>>
File: nav8u.png (218KB, 719x395px) Image search: [iqdb] [SauceNao] [Google]
nav8u.png
218KB, 719x395px
>>47025211
I do like the thread stuff*, I mean.

>>47025213
what the FUCK. 87MB/s down? 93MB/s up?
...how? NBN or some shit?
>>
>>47025140
Because you're too dumb to fire up wireshark. Blame an established protocol instead of yourself. Also your teacher told you to use UDP because you're obviously too dumb for TCP handshakes and he wanted to make it easy for you
>>
>>47025227
Well we've recently had fiber installed (not NBN I don't think), That and we live close to the exchange. Best thing ever.
>>
>>47025255
fuckin A man. lucky as fuck.
>>
>>47025190
>UDP is not fine, it's unreliable.
UDP is fine, it has a lot of advantages.

if you want to use UDP and maintain file integrity you would still probably be better off doing tcp over udp, or building in some sort of checksum integrity check like bittorrent (also uses udp).

another example would be sftp, which uses ftp(tcp) over ssh(which is udp).

tl;dr - the problem is you
>>
>>47025253
>Blame an established protocol instead of yourself
I was more blaming the nature of unreliable transfer.
I've figured out that is has something to do with getaddrinfo() acting weird when giving it "localhost", but it works when "127.0.0.1" is provided.
>you're obviously too dumb for TCP handshakes and he wanted to make it easy for you
>Implying that TCP handshakes aren't done by the OS.
>>
>>47025277
>over ssh(which is udp).
?
SSH is port 22 TCP
>>
>>47025269
Yeah it's pretty sweet, the place I live in has a file server running FreeNAS and they have currently put it in my room. I'm the techy guy and just incase they audit the place they can't search students rooms.
So I've got this baby connected to a switch and I've got my desktop connected to the switch and I'm pulling movies off at 11mbs while everyone else is about 1 - 2 mbps
>>
>>47025277
>UDP is fine, it has a lot of advantages.
Yes. Speed and simpler implementation.

>tcp over udp
So all of the disadvantages of tcp AND udp.
Idiot.

>building in some sort of checksum integrity check like bittorrent
I have to follow the spec. You send an ACK packet for every file chunk they send.

>sftp, which uses ftp(tcp) over ssh
Fucking wrong. SFTP has nothing to do with FTP. It is its own protocol.
You're probably thinking of FTPS (FTP over SSL).

>over ssh(which is udp).
SSH is TCP.

I don't think you could have been any more wrong in your post.
>>
>>47025213

if UDP is proving unreliable for you, i suggest your connection is still a pile of shit
>>
File: rust.png (44KB, 1000x1000px) Image search: [iqdb] [SauceNao] [Google]
rust.png
44KB, 1000x1000px
>no GC
>no memory management
>no buffer overflows
>no dangling pointers
>no null pointer
>option type
>immutable by default
>blocks are expressions and have return values
>all the advantages of functional programming without the clunky autism
Why aren't you using this perfect language?
>>
>>47025310
I have no problem with UDP, just how it's implemented I don't like it.
>>
>>47025211
>I do like to thread stuff, I wonder if it can be adapted to other languages
Undoubtedly you can come up with something for any language
>>
>>47023148
Have you done your daily tornado, /dpt/?
let tornado input =
let len = Seq.length input

let rec tailTornado shift list =
match shift with
| x when x = len -> list |> List.rev
| x -> let next = [ x .. x + len - 1 ]
|> Seq.map (fun i -> Seq.nth (i % len) input)
|> Seq.toArray
|> fun chars -> new string(chars)
tailTornado (shift + 1) (next::list)

tailTornado 0 []
>>
>>47025313
I've learned Rust and I have a personal program that I've been working on written in it.
It's a bit of a weird language though, at least coming from C.
>>
>>47025313
I'm waiting for it to stabilize. Right now it's in "we'll-change-things-every-day" phase. I don't have time to relearn the same language ten times in a year.
>>
>>47025126
bump
>>
>>47025313
because it has autism syntax
>>
>>47025126
display: inline or inline-block or inline-flex or inline-table
>>
>>47023148
>tornado.png
top fucking kek
>>
>>47025313
>no null pointer
I'm confused, why are you listing this like it's a good thing?
>>
>>47025430
https://www.linkedin.com/pulse/20141126171912-7082046-tony-hoare-invention-of-the-null-reference-a-billion-dollar-mistake
>>
>>47025430
As a true systems language, Rust actually does have null pointers, but only in unsafe blocks.
>>
File: uxwzo.png (45KB, 763x537px) Image search: [iqdb] [SauceNao] [Google]
uxwzo.png
45KB, 763x537px
>>47025427
i made this
>>
>>47025434
This is why you should use C++11 and the glorious nullptr.
>>
>>47025467
what programming language is this?
>>
>>47025430
imo, null /pointers/ are bad (i.e. integer w/ value of 0)
a defined null /type/ on the other hand, is OK
>>
>>47025478
just c#
>>
>>47025487
Looks beatiful, what a shame it's useless on GNU/Linux
>>
>>47025498
someone said ages ago that c# has compilers for other OSs now
>>
>>47025467
>2 space indents
>cursive
>the declaration of Main is in 5 colors, yet Console.WriteLine in 1
:/
>>
>>47025507
They talked about that, but there is still no native C# compiler available at the moment - or at least I'm too stupid to find it.
>>
File: tornado.png (82KB, 800x800px) Image search: [iqdb] [SauceNao] [Google]
tornado.png
82KB, 800x800px
>>47025498

>>47025509
ok, so
I use Visual Studio to write all my code
I use 1 tab for indenting (Visual Studio uses smart tabs though, so they're actually 4 spaces)
but since the fucking IDE is so bloated...I chose to take the preview image in sublime, and converted the indentation to 2.
Why I did this I do not know.
>>
>>47025498
>>47025507
>>47025527
nubs, mono has been out for ages for linux and mac, and now since microsoft is releasing (nearly) the whole of .NET/C# as open-source, they'll be even stronger
>>
i have a java question

say i have an array of jlabels each with mouse listeners, i know i can do e.getSource to get the clicked jlabel but is there any way to get the jlabel's index in the array?

i know i can loop through the array and compare the objects but that feels like a really tacky way of doing it
>>
>>47025538
>but since the fucking IDE is so bloated
That's the price for such comfiness. I don't mind it one bit, tbh.
>>
File: bloat.png (53KB, 1069x683px) Image search: [iqdb] [SauceNao] [Google]
bloat.png
53KB, 1069x683px
>>47025509
see, here
you happy?
(Visual Studio is so fucking nice though)
>>
What are the c++ conventions for project structure?
(Inc)
\-String.h
\-...
(Src)
\-String.cpp
\-...

I was thinking about this but it seems like it would be kind of unmanageable if I have 50+ source files in the same directory.

(Src)
\-(String)
\-String.h
\-String.cpp

Maybe this?
Anything I should look out for when deciding on the project structure?
>>
>>47025551
doesn't mono compile to an .exe which requires wine to execute?
>>
>>47025588
mono (or more precisely, mcs, the compiler) compiles to a .NET exe, which mono itself runs.
You can compile .NET exes on windows too, and they'll work on mono.
I'm not 100% sure, but I think wine interfaces with mono to provide .NET support too (but using mono directly is better.)
>>
>>47025602
so there is no way to compile your code into one binary containing the complete dependencies/.NET or whatever it needs so you can just ./program without needing mono?
>>
>>47025570
>That's the price for such comfiness.
Exactly. I tried to go back to other languages and IDEs, and man, it is impossible.
No intellisense? no productivity. Visual Studio reigns over all.
>>
>>47025573
Shit, mate, you even added newlines at almost all the right places. I'd put one below segments and remove the one between source and dest Rects.

>>47025618
Don't forget Resharper.
>>
>>47025616
actually, mono has a utility called 'mkbundle' which does just that
it bundles everything, including mono, into a native executable.
>>
>>47025625
>put one below segments
true
>remove the one between source and dest Rects
noooo
they're separate for a reason
>>
>>47025577
Look at big projects on GitHub for style inspiration. They usually look like the bottom one.
>>
>>47025430
Because they are one of the biggest causes of memory errors and crashes. Using the Option type like Rust does is a far better way to handle the concept of null values that doesn't encourage unsafe code.
>>
>>47025632
thank you very much for the information anon.
>>
>>47025641
That makes sense, thanks for the tip anon.
>>
>>47025640
Well, guess you're right. C# format gestapo approves. On a related note, the trailing newline at the end of files makes me twitch. The first thing I do when creating a new file is deleting that pesky newline :D. Am I autistic?
>>
>>47025313
Because functional programming is highly overrated. Default immutable data structures are extremely, and I mean extremely fucking insanely overrated.
>>
>>47025421
Tried that, didn't move
>>
>>47025691
all I know is that github shows an ugly icon if you don't put the bloody newline, so I put it there :/
>>
>>47025707
whats your html?
if they're divs, they should flow on a new line
>>
>>47025707
If something doesn't flow correctly if it should then it's generally the style of the parent element denying it.
>>
File: question cat 1.jpg (48KB, 365x444px) Image search: [iqdb] [SauceNao] [Google]
question cat 1.jpg
48KB, 365x444px
/dpt/ what do I need to know in order to create a project that can be worked on by a team of people (myself included)? I figure UML may be a requirement but I'm completely in the dark, me and the rest of the people already know source control and the programming language were working with but not how to map a project out.

I figure that I'll need to read some book on proper design so that I can devise some kind of roadmap and project skeleton but I've never done this before, I've only ever written my own software and it's usually done without structure ahead of time (implement first, refactor later).

Any suggestions or advice for this?
>>
>>47025702
Rust isn't Haskell. It has functional programming features but never at the cost of practicality. Typing "mut" when you need it is very easy, and it both catches errors and makes things easier for the optimizer.
>>
hmmm
by my count, e621.net has approximately 665GB of images.
I wonder how hard it would be to download them all
>>
What's everyone's favourite Java/C++ IDE?
>>
>>47025928
I use Code::Blocks. I might switch to Lime Text or Qt Creator though because they both look pretty cool.
>>
>>47025928
IDEA
eclipse has its perks (it can do literally everything with a gui), but its ridiculous how complex it gets. and forget upgrading / migrating, you might as well ship your entire eclipse install as a dependency.
>>
>>47025805
this cat has some highlevel quest for me, I'm 27, anyone knows when I can turn it in?
>>
File: gentoo-tornado.png (181KB, 1146x1200px) Image search: [iqdb] [SauceNao] [Google]
gentoo-tornado.png
181KB, 1146x1200px
>>47025498
Here's your native multiplatform attempt, pic related is output of
./tornadoimage gentoo.png gentoo-tornado.png
:
program TornadoImage;

{$mode objfpc}{$H+}

uses
Classes, SysUtils,
fpImage, fpReadJPEG, fpWriteJPEG, fpReadPNG, fpWritePNG;

const
DefaultDivisions = 20;

var
SrcImage, OutImage: TFPMemoryImage;
i, DivHeight, DivWidth, x, y, x2, Divisions: Integer;
begin
if ParamCount < 2 then
begin
Writeln('USAGE: tornadoimage src out [divisions]');
Writeln(' src Source image file (jpeg, png)');
Writeln(' out Output image file (jpeg, png)');
Writeln(' divisions Number of vertical divisions to make');
Halt(1)
end;

SrcImage := TFPMemoryImage.Create(1, 1);
SrcImage.LoadFromFile(ParamStr(1));

OutImage := TFPMemoryImage.Create(SrcImage.Width, SrcImage.Height);

if ParamCount < 3 then
Divisions := DefaultDivisions
else
Divisions := StrToInt(ParamStr(3));

DivWidth := SrcImage.Width div Divisions;
DivHeight := SrcImage.Height div Divisions;

for i := 0 to Divisions - 1 do
begin
x2 := 0;

for x := DivWidth * i to SrcImage.Width - 1 do
begin
for y := i * DivHeight to (i + 1) * DivHeight - 1 do
OutImage[x2, y] := SrcImage[x, y];
Inc(x2)
end;
for x := 0 to DivWidth * i - 1 do
begin
for y := i * DivHeight to (i + 1) * DivHeight - 1 do
OutImage[x2, y] := SrcImage[x, y];
Inc(x2)
end
end;

OutImage.SaveToFile(ParamStr(2));

SrcImage.Free;
OutImage.Free
end.
>>
>>47025805
Yeah document the functions and structure out on a whiteboard before you start, add more later. Every project ever at work turns to a clusterfuck because no one knows how the other parts work.
>>
>>47026200
disgusting
>>
>>47026200
what language is this?
>>
>>47026250
Free Pascal
>>
even: math
odd: python notebooks for scikit-learn
>>
>>47025313
Those are the reasons why i DON'T use Rust, except for the first one.
>>
I'm working on some integer arithmetics in java. I have to multiply an integer by an another digit. But the integer is not an integer, it's an array where the position [0] stores the units, [1] the tens, [2] the hundreds, etc.
For example, 533 would be number[0]=3 number[1]=3 number[2]=5.

I cant seem to find why my code isn't working, tho. I get an ArrayIndexOutOfBoundsException error.

public int[] multByDigit(int[] number, int digit) {
if (number.length==1 && number[0]==0 || digit == 0 ){
int[]result = new int [0];
result [0] = 0;
return result;
}
else{
int[]result = new int [number.length +1];
int carry = 0;
for (int i = 0; i< result.length; i++){
int multi = number[i]*digit;

if (multi>9 && i<number.length){
String temp = Integer.toString(multi);
int[]tempmulti = new int [2];
tempmulti = fromString(temp);
result[i] = tempmulti[0] + carry;
carry = tempmulti[1];
}
else if (multi>9 && i==number.length) {
String temp = Integer.toString(multi);
int[]tempmulti = new int [2];
tempmulti = fromString(temp);

for(int j=0; j<tempmulti.length; j++){
result[i]= tempmulti[j];
i++;
}
}
else if (multi<10){
result[i] = multi;
}
}
return result;
}

}
>>
>>47023148
Trying to implement a binary tree in Go.

func (n *Node) insert(value int) {
if n == nil {
n = &Node{value, nil, nil}
...


Why is the node data lost after the program returns from the insert function even though the parent node holds the pointer to it?
>>
I understand the difference between an interpreted language and a compiled language, but what are the different use-cases for each? As in, why would you use a compiled language over an interpreted one for a certain program, or vice versa?
>>
>>47026397
Compiled: Performance
Interpreted: Neat tricks
>>
>>47026397
Compiled languages are usually faster.
>>
>>47026377
>integer multiplication
>code sprinkled with integer to string conversions and string splitting

This isn't how you multiply arbitrarily long numbers.

Also, learn to use debuggers. I'm 100% sure a good debugger will reveal the source of your problem in less than five minutes.
>>
>>47026377
didn't go step throught your algorithm completely, but the i++; inside the second
else if
looks like the most likely culprit. After that loop i = i + tempmulti.length, even if that's bigger than number.length.
>>
>>47026412
>>47026422
I guessed as much, is that pretty much the only reason?
>>
>>47026377
Change

int[] result = new int[0]

to

int[] result = new int[1]
>>
>>47026454
With a compiled language, some programming errors can be caught during compile time rather than only at runtime.
>>
>>47026454
today there's not much difference
you could say javascript is an interpreted language, but it really is just compiled on the fly (known as JIT compilation)
in general, compiled languages should be faster, as the compiler can analyse the entire program, as opposed to the limited view an interpreter gets.
>>
>>47026454
There are lots of little reasons, but performance is the biggest reason to use a compiled language.
E.g:
Less memory consumption (especially without GC)
Has an actual ABI that other languages are able to use

but there isn't actually a huge amount that is inherently different between compiled and interpreted.
>>
Thank you for using an anime image.
>>
>>47026439
Yeah i think i'm doing it wrong. Care to elaborate a little how i should properly do it?

>>47026458
Oh yes, i didn't see that one. But the program doesn't crash there, it says it crashes in
int multi = number[i]*digit;
>>
>>47026385
Are you sure n is nil in your test? Can you post the full program?
>>
>>47026544
(albeit bastardised)
>>
/dpt/ please, I'm a total noob. When I load a program in Win32dasm I can search for and find a certain string used by the program. But when I load the program in IDA pro and search for the string in the subview I get no results. What could be the cause?
>>
>>47026568
Yes. Root is nil and a new node is created, but after the function returns root is nil again.

package tree

type node struct {
Value int
Left *node
Right *node
}

type Tree struct {
Root *node
}

func NewTree() *Tree {
return &Tree{}
}

func (t *Tree) Insert(value int) {
t.Root.insert(value)
}

func (n *node) insert(value int) {
if n == nil {
n = &node{value, nil, nil}
} else {
if value == n.Value {
return
}
if value < n.Value {
n.Left.insert(value)
} else {
n.Right.insert(value)
}
}
}
>>
>>47026544
why would you thank someone for that?
>>
>>47026716
He's trying to get a reaction out of someone, a person typically says "thanks for using the X image" or "thanks for not using the X image" in these threads because there are a few images that are standard and a lot of people like or dislike at least 1 of them, by making these comments they're almost guaranteed to annoy someone.

/autism
>>
>>47026375
You just like making your own life difficult?
>>
File: here.jpg (59KB, 526x433px) Image search: [iqdb] [SauceNao] [Google]
here.jpg
59KB, 526x433px
>>47025740
Here is my HTML
>>
>>47026831
No, i like manual memory management.
Fuck your babby shit. go back to Python.
>>
>>47026637
You surprised me with the fact that you can actually call methods on nil as long as the type is right and the method does not use any type.
I think I found your problem:
http://play.golang.org/p/Ed2leUZnXJ
>>
>>47026926
*Does not use any values of the type
>>
>>47026903
Rust has manual memory management if you wish to use it you moron. You don't even know about the language you're attacking
>>
>>47025336
Doing it one line with python.
string = input('Word?\n')
for subMatrix in [[string[i+j-len(string)].upper() for j in range(len(string))] for i in range(len(string))] : print('{0}'.format(''.join(subMatrix)))


INSTALL GENTOO
NSTALL GENTOOI
STALL GENTOOIN
TALL GENTOOINS
ALL GENTOOINST
LL GENTOOINSTA
L GENTOOINSTAL
GENTOOINSTALL
GENTOOINSTALL
ENTOOINSTALL G
NTOOINSTALL GE
TOOINSTALL GEN
OOINSTALL GENT
OINSTALL GENTO
>>
>>47026637
I might be wrong here but your Tree is pointing to a nil pointer, when you add an actual node in it's place the Tree does not update this.

That is the best I can guess from playing around with it a bit. Can you try changing it in to a
type Tree struct {
Root node
}


Kind of structure?
>>
>>47025702
You know what's even more overrated? Default mutable data structures.
>>
Is tornado text the mostest epickest newest memest on /dpt/?
>>
>>47027031
>one line
>is actually two lines
Step up nigga.
(defn tornado [s] (clojure.string/join "\n" (for [i (range (inc (count s)))] (->> s cycle (drop i) (take (count s)) (apply str)))))
>>
>>47026926
You're right. I guess the node is destroyed at the end of the function. Fortunately one can return a newly allocated struct:

return &node{value, int, int}


I have to change my function so it returns a node pointer and assign it somewhere else. Thanks for the help.
>>
>>47027183
*that should be nil not int
>>
>>47027155
Don't forget images, have a web:
http://massive.faggotry.org/tornado/
>>
>>47023310
>Not bashing Python
>2015
>>
I've opened in window using Xlib, now i need efficient read/write access to the window's framebuffer.
How do i do that?
>>
Using C#/xna, trying to get a simple save/load system. Seems I can use some built in stuff with xna, but it uses

using Microsoft.Xna.Framework.Storage;


When I try it, nothing found. I've made sure I'm using xna 4.0, my .csproj file contains 4.0 rather than prior version references, and if I type in

using Microsoft.Xna.Framework.


I get the auto complete options for audio, content, design, gamerservices, graphics, input and media. But no storage.
>>
>>47023310
Python is a terrible joke, it's more complex than C while being orders of magnitude slower.
>>
>>47027564
Storage for what?
>>
>>47024151
I'm new to C++, what's wrong with that?
Why use
using std::cout;
instead of
using namespace std;
?
>>
>>47026903
hahahaha. you clearly have no idea what rust does or how it gets rid of those issues. you spend just as much time thinking about memory, since you seem to be a masochist; the only difference is that rust implements certain compile-time checks to make sure you're not using memory in a way that could potentially be unsafe. go back to your babby c shit, enjoy your built-in security issues causing 99% of huge security meltdowns
>>
>>47027619
Personal preference on coding styles, it shows intent better if you include namespaces.
>>
>>47027611
I can't find it in the using statement.
>>
File: Untitled.png (124KB, 1542x840px) Image search: [iqdb] [SauceNao] [Google]
Untitled.png
124KB, 1542x840px
>>47026631
Anyone got any suggestions with this?
This is what both windows show.
I can't find the string in Ollydbg either. I don't get why other decompilers can't decode these strings.
>>
>>47024801
Use "using" instead of a typedef.
>>
I have a noob question about SQL databases. I wanna build a flash card app. My model is simply that there are chapters which have a list of questions. A question also can be learned(boolean value) and has other values(not relevant for the question)
In my SQLite database, I've created two tables: one for the chapters and and one for the questions. In the question table, every question has a reference to the id/ primary key of it's chapter.
My question: I wanna know if a chapter has still unlearned questions left (boolean value, would be false if question in the sqlite database with the id of the chapter is learned)
What is the most efficient way to do that? My first guess and the most straight forward way was to do a query on the questions table asking for questions with a certain chapter id and unleared =0, and check if the returned cursor has at least one row. But a whole query for a single boolean value might seem a bit overkill. Would it be better to store the boolean value (wether there are still unlearned questions left) in the chapters table and update it whenever questions get learned/ unlearned?
Thanks for the help
>>
>>47027174
I can't do it one line. I tried to add the input into the for loop, but it doesn't work.
But again, I wonder how much lines the apply function have :3

Your language is neat. Is that LISP?
>>
>>47025573
>using var in a language with static typing
Disgusting.
>>
>tfw no one forks your repo
it hurts
>>
File: BeWfQJF.png (158KB, 1178x1062px) Image search: [iqdb] [SauceNao] [Google]
BeWfQJF.png
158KB, 1178x1062px
Just having fun with the latest thing

Also fuck you >>47027746
>>
>>47027746
I'll bite. So you'd rather type:
Bitmap image = new Bitmap(..)
Dictionary<string, Rectangle> dict = new Dictionary<string, Rectangle>()

than
var image = new Bitmap(...)
var dict = new Dictionary<string, Rectangle>()
>>
>>47027805
I love type inference.

typealias InnerFunction = ([Int]) -> Int
let doSomething3 = {n in {$0.reduce(n) {$0 + $1}} as InnerFunction}

let cur = doSomething3(10)
cur([1, 3, 4]) // 18
>>
>>47027805
Yes, because those dynamic variables can cause unexpected behavior.

I'm not against duck typing, but I don't think it should be used that extensively in C#. Only for creating very simple data structures like:

var student = {name: 'studentName', age: 24} ;
>>
>>47027786
Is this some kinda disgusting swift shit?
>>
>>47027936
Yes.
>>47027872
Is also Swift.
>>
>>47027872
>as InnerFunction
:^)

Yes, it's great. >>47025336 is only a tiny method, but you can also write much larger piece of code in F# without every specifying a single type. And when you need to do so, it can enough to use type annotation on a variable in one location only and it will automatically propagate. Magic.

>>47027905
>what is type inference
There's nothing dynamic about using var... Even in your case (creating an anonymous class), the compiler takes care of everything. No runtime penalty at all.
>>
>>47027715

IDA Pro's auto analysis probably didn't find it, maybe due to lack of it being referenced in a context where IDA could tell it's a string.

If you know what address it should load at (through another tool, manually, or searching for it in IDA as a series of bytes), then you can go to that address and mark it as a string yourself.
>>
>>47027745
It's Clojure. 99% Lisp.
>>
Are lambda expressions in java just a fancy name for a local method within a method?
>>
>>47027957
If you want to really want to test Swift type inference you can do.

let doSomething3 = {n in {($0 as [Int]).reduce(n) {$0 + $1}}}
let cur2 = doSomething3(10)
cur2([1, 3, 4])


From [Int] it can infer the types of everything else.
>>
>>47027905
The var keyword doesn't mean the variable is dynamic. With the var keyword the compiler figures out the type for you. The variable behaves the same as if you specified the type explicitly. So this won't work:
var a = 3;
a = "hello";


If you want real dynamic types you must use the dynamic keyword:
dynamic a = 3;
a = "hello";
>>
>>47028039
What does the code do?
>>
>>47028073
Adds 10 + 1 + 3 + 4
>>
>>47023148
Okay /dpt/, let's see if I understand iteration and recursion.

class Factorial {
public int iterFact(int num) {
int fact = 1;
for(int i = 1; i <= num; i++) {
fact *= i;
}

return fact;
}

public int recurFact(int num) {
if(num == 1) {
return 1;
}
int fact = num * recurFact(num - 1);

return fact;
}
}

In the iterative function, the value is computed by simply increasing i by 1 until 1 > 5.

In the recursive function, the value is computed by the function calling itself with an argument 1 less of what it was called with last time until it is passed an argument of 1, at which point the return chain begins.

Say I passed a value of 5 into the recursive function. It goes like this:
fact = 5 * f(4)
fact = 4 * f(3)
fact = 3 * f(2)
fact = 2 * f(1)
The recursion now stops as the function has been passed a value of 1. The caller is returned 1 and the chain can now resolve:
fact = 2 * 1 (2)
fact = 3 * 2 (6)
fact = 4 * 6 (24)
fact = 5 * 24 (120)
120 is returned at the highest level.

Am I understanding this correctly?
>>
>>47027973

Also I just realized that your other tool is talking about resource IDs, those strings may be defined in a resource, which IDA doesn't load by default, and may not automatically resolve and determine to be a string even when it does.
>>
>>47027973
Thanks.
Kind of disappointed that neither IDA nor olly show the string, whereas a much older program like win32dasm does. Guess I'll keep using w32dasm along with IDA and olly to determine the string locations.
>>
>>47028116
yeah m8
>>
>>47028123
>those strings may be defined in a resource, which IDA doesn't load by default, and may not automatically resolve
Interesting. Is there a way to load them in IDA?
>>
>>47028080
>>47028039
let doSomething3 x list =
list
|> Seq.reduce (+)
|> (+) x

let cur2 = doSomething3 10

cur2 [1; 3; 4]

One less type annotation than your code :P
>>
>>47028116
basically, but understand you are recursing with the stack, if you recurse too deep (try recursive bucket fill e.g.) the computer will get upset
>>
>>47028148

Chances are, it's not a particularly important string to the code you're reversing, if IDA isn't finding it in auto analysis. Once you find it as a series of hex bytes, cross reference and/ot set a breakpoint on access and debug to see if it's ever used.

Your example string looks like a library error message that might not even be relevant in this program.
>>
>>47028164

Yeah, when you load up a file in IDA, there is a check box for loading resources.
>>
>>47025805
You can't possibly come up with good design upfront if you have never tackled anything like the problem before. You should have a lead programmer do what you did alone. After a good structure suggests itself from the prototype code you can start bringing over other programmers.
>>
>>47023310
Idunno anon i like python.
>>
Hi /dpt/ what is your opinion on sites like elance/topcoder. Have you made money on them?

Is it even worth your time, I'm a CS student who wants to gain some experience while making some money on the side doing programming related stuff.

I'm inexperienced and generally apprehensive about anything related to "making money online". Thanks in advance.
>>
>>47028199
>>47028213
Brilliant. Thanks anon.
>>
public static String tornado(String s) {
if (s == null) {
return null;
}
return Stream.iterate(s, cs -> cs.substring(1) + String.valueOf(cs.charAt(0)))
.limit(s.length())
.reduce((o, n) -> o + "\n" + n)
.orElse("");
}
>>
>>47028191
>basically, but understand you are recursing with the stack, if you recurse too deep (try recursive bucket fill e.g.) the computer will get upset
Is that because each time the function is called, memory is allocated for a new set of variables on the stack and only deallocated once the recursion stops?
>>
>>47023148
A* pathfinder that runs on a mesh of convex shapes, pretty ez
>>
>>47027732
>Would it be better to store the boolean value (wether there are still unlearned questions left) in the chapters table and update it whenever questions get learned/ unlearned?
No. It's a relational database; store the base information where it belongs and try to only store it there. In this case, whether there are questions left is a derived fact; with appropriate indices, it's computable cheaply from the things that you already have. Keeping derived information around just makes for trouble ensuring that the derived information is correct (a suitable trigger on the question table could do it, but it's unlikely to be a problem unless you've got a much larger DB than your example would justify).

And don't think in terms of having a query that returns a boolean, but rather a query that returns a collection of things which the boolean can be derived from. For example, you could return the list of chapters that still have unanswered questions, or return a list of chapters with the count of answered questions and the total number of questions for each chapter in the row data. All sorts of possibilities.
>>
>>47028329
Oh, and it's in Lua
>>
File: 1424479231624.jpg (24KB, 396x353px) Image search: [iqdb] [SauceNao] [Google]
1424479231624.jpg
24KB, 396x353px
All i want to do is open a window and write to it's framebuffer.
Why is Xlib making that so fucking hard for me?
I must be doing something terribly wrong here, how do i get efficient direct access to the window framebuffer?
>>
>>47028363
use sdl nerd
>>
>>47028289

I was just happy to run across someone on here doing some reverse engineering. Definitely pick up and read Practical Malware Analysis and The IDA Pro Book if you haven't already.
>>
>>47028373
>INSTALL ALL THIS FUCKING BLOATED SHIT TO MANIPULATE A FUCKING FRAMEBUFFER HURRRRRRR.
Why don't you fuck off, there's a reason I'm doing this with pure X, efficiency is most important here.
>>
Will there ever be a programming language where you don't have to fight against it to do anything beyond the basics?
>>
>>47028419
No.
>>
>>47028419
That would be too easy.
>>
>>47027786
This one is nice. The tornado text have a space at the end of the original string, so it's more aesthetic and the bottom line even have the full sentence.
FIZZ BUZZ
IZZ BUZZ F
ZZ BUZZ FI
Z BUZZ FIZ
BUZZ FIZZ
BUZZ FIZZ
UZZ FIZZ B
ZZ FIZZ BU
Z FIZZ BUZ
FIZZ BUZZ
>>
>>47028419
There is no programming language in which you're not a lazy dumbfuck faggot.
>>
>>47028395
>pure X
>efficiency
choose one.

If you want efficiency you should use drm and bypass X entirely.
>>
>>47028379
Yeah, I was planning to check out IDA Pro book. Will also check out Practical Malware Analysis.
>>
>>47028395
>"No! That small few-hundred kilobytes C library that comes with everything, that has been used in probably thousands of freeware/open source games and even in commercial games and AAA game engines under Linux is simply not efficient enough for my tic-tac-toe game!"

You should buy a computer that has been manufactured in the last 15 years if SDL is not efficient enough for you. If you're worrying about a few hundred kilobytes, then don't statically link.
>>
string word = Console.ReadLine();
if (word[word.Length - 1] != Convert.ToChar(" "))
word += " ";
for (int x = 1; x < word.Length; x++)
Console.WriteLine(word.Substring(x) + word.Substring(0, x));
>>
>>47028395
>hurr X is more efficient
yeah anon you don't actually have a reason to use xlib
>>
>>47028579
>Convert.ToChar(" ")
What the fuck
>>
>>47028596
I'm sure there's a better way to compare chars to strings but I don't know what it is.
>>
>>47028395
>average C user
It's like you guys are still stuck in the 20th century.
>>
>>47028650
that feel when it's something you can't control
>>
>>47028644
var num = int.Parse("5");
>>
>>47028579
nigga what are you doing
>>
>>47028339
Thanks for this answer, it helped me a lot.
I only needed a boolean value because I just needed to change some UI elements in a dialog when there are no questions left. (I already have a certain chapter selected by the suer in that dialog, so I just got a list of unanswered question and checked if it was not empty)
>>
>>47028644
Why not just
' '
>>
>>47028684
I probably could have figured that out from how string.split works, thanks.
>>
>>47028650
Modern way is to chew up the cycle budget with layers of indirection so the software becomes noticeably sluggish. Anything else is unacceptable.
>>
>>47028569
>that comes with everything
That's the huge problem, 99% of everything it comes with i don't fucking need or want.
>>
>>47028363
>be a fucking autist
>deal with the same problems for a few days because everything is too bloat for you
jesus just kill yourself
>>
>>47028964
Then don't use it, the only thing it costs is a few kb of disk space
99% of linux systems already have sdl installed anyways so it's a wash
>>
http://swiftwtf.tumblr.com/
>>
>>47028964
>99% of everything it comes with i don't fucking need or want.
tfw - this is how I feel when shopping for a laptop
>>
>>47028363
What's so hard?
Create window.
Create XImage (Use XShmCreateImage so you don't have to send the pixel data over the X protocol)
Write your pixels into ximage->data
X(Shm)PutImage.
Pump the event queue.

It's 100 lines or so.
>>
File: 1404536538147.png (10KB, 408x286px) Image search: [iqdb] [SauceNao] [Google]
1404536538147.png
10KB, 408x286px
I have a java noob question.

how do I use or create a class which I can access without creating and initializing an instance? you know like those java or other library classes.
>>
>>47029132
What do you mean? Something like Math.sqrt(number)?

You just create the class as normal and set those methods to static.
>>
>>47029132
public static in attributes and methods
>>
>>47029014
So it's like Apple's Javascript with emoji?
>>
>>47029161
Just reimplementing the abomination that applescript is.
>>
I need a new project. I have no idea what I want to do.
>>
>>47029151
>>47029153
ah, it works. thanks.
>>
>>47023321
SDL would be a good start for such a simple project. Manages windows, display, audio and events on more platforms than you'll probably want to compile to.
>>
>>47025434
>https://www.youtube.com/watch?v=ywWBy6J5gz8
lek
>>
Working with Golang today. I really like it, but I am pretty terrible at it still. Always reading the docs, and learning more and more about the language and best practices every day.
>>
>>47025336
mapM_ putStrLn $ take 20 $ iterate (liftM2 (++) tail ((:[]) . head)) $ "HASKELL IS STILL RELEVANT"
>>
>>47023321
>I am fluent in C, what should i use to make my game, if i want it to be cross platform? Anyone?
javascript, the future of computing.

jokes aside if you are able to write some code just find a decent library for your favourite language and you will quickly realise that writing a game is not hard but extremely time consuming. I for one like Java, so I use libgdx.
>>
>>47029212
Make a roguelike incorporating your most deprived fetishes.
>>
File: 77681.jpg (46KB, 500x724px) Image search: [iqdb] [SauceNao] [Google]
77681.jpg
46KB, 500x724px
Good book?
>>
>>47029212
write a no-fap calendar app.
>>
>>47029529
Well, I did have the idea of saving porn video links in a database with a fap-counter, complete with categories and whatnot. Maybe I'll do that.
>>
>>47027564
You need to reference microsoft.xna.framework.storage.dll
>>
dumb question
are alists just lists where every other value is a key, like (list :a 'a :b 'b) or do you wrap key/values into a pair like (list (cons :a 'a) (cons :b 'b))
>>
>>47029585
Fucking idiot
>>
File: 1358117725723.gif (480KB, 500x281px) Image search: [iqdb] [SauceNao] [Google]
1358117725723.gif
480KB, 500x281px
>>47024854
>writing shit code isn't hard
>>
>>47023171
for (i = 0; i < L; i++)
for (j = i; j < L; j++)
print(j)


Complexity is O(n^2)?
>>
Reactive Extensions and ReactiveUI are absolutely fucking fantastic.

The way it streamlines the whole INotifyPropertyChanged shebang is amazing.
>>
>>47029741
thanks for your input anon <3
>>
>People say your code is shit
>They don't tell you why its shit or tell you how you can improve it so you don't know what to look out for
>Not even an example to point to and compare with
>Half the time you'll find it later in one of those shitty cs grad memes

Just reminding you that you're all cancer
>>
I mdae a txet semrlabcr b/c fcuk you nsa
>>
>>47029585
>do you wrap key/values into a pair
At least in R list() objects are created in that way. Probably in other languages, too.

lst <- list(
a = "string",
b = "abc",
c = 123.4
)
>>
>>47030029
It doesn't matter Anon, you've already won, take comfort in knowing they're studying one of the least successful STEM subjects out there.
>>
just spent the morning reading/learning angular.js

>google dropped it, new version will release next year and is incompatible.

anyone know of a vanilla javascript way to do manipulate elements.

I can write javascript, and I know I could look through the dom api on MDN... but is there any more concise / procedural approach to learning dom hooks?

youtube would be great
blogs are fine
books are fine, but I dont want a printed version of the DOM api..
>>
>>47030227
There is literally nothing wrong with mdn
there's very little you need to know to actually do templating, pretty much just querySelector, creating nodes, appending/inserting/replacing nodes, etc
>>
>>47030227
Google haven't dropped AngularJS. They've recently recruited Microsoft and merged AtScript into Typescript.
>>
>>47030227
>>47030311

First time I am seeing angular bros here. Let's learn it together!

I imagine employers will want angular for a while. But I guess we should all be learning typescript too.
>>
>>47030390
>But I guess we should all be learning typescript too.
You don't really even need to learn typescript, It's just static typing + type annotations + JavaScript.
>>
>>47030311
they are dropping the current api, keeping the name and calling it 2.0

so maybe we have different ideas of what "dropping" is, but I'll cede the point.

>>47030297
no, dont get me wrong, I love mdn. but its not concise or explicit.

I actually used to use it a lot, but its seems like a lot of info that used to be there is missing. It looks like they went through a process of trying to make it more friendly, and it didnt work...
>>
>>47030432
>they are dropping the current api, keeping the name and calling it 2.0
That's because they didn't and don't develop AngularJS for anybody but themselves, pretty much all internal tooling at Google is written in AngularJS.

It isn't like AngularJS 1.0 isn't going to be maintained and developed for years to come anyway.
>>
>>47030486
I dont care why its happening, I respect google for making smart business decisions.

I'm just not gunna use it. I dont have the time or money google uses to maintain their services.
>>
>>47030486
>>47030537

They use it in a lot of businesses, so it looks like I might as well learn it. Software is kind off 3fast5me though. Maybe I should just drill C# and do backend all day.
>>
>>47029585
I believe your first example is called a plist in common lisp. An alist is a list of pairs, as in your second example.
>>
>>47030582
learning a language / framework / api is by far the easiest part...
but software works as a business model because we write it once and forget it, only the few super-wealthy companies can do a full rewrite of their codebase every few years.
>>
>>47030633

>.NET
>all the fucking addons
>angular + 100 different modifications for angular styles, unit tests, etc = easy

Not for me. Call me retarded if you want. It's hard to remember all this shit without working with it all the time.

eventsApp.directive('myDirective', function()
{
//this function needs to return a directive objective, so basically our "directive" is the directive name
//"myDirective" and the directive object which I will create and return inside this function
var directive = {}; /*this shit will hold the directive*/
directive.restrict = "A"; /*This restrict thingy affects whether the directive name works on elements ("E") or attributes ("A")*/
directive.template = "My first directive: {{textToInsert}}";
//the shit in the template replaces whatever element the directive is called on
return directive;
//this shit just returns our directive, so again, really all we have is:
//eventsApp.directive(DIRECTIVE_NAME, DIRECTIVE_OBJECT);
}
);
>>
>>47030663
right, but have you worked with any similar languages before?

that's just javascript with a few angular methods and an object with one member.

callbacks are really weird at first, but not "hard".
>>
pastebin.com/w8a0wMzt

Line 13 Returns: "Syntax error in the UPDATE instruction".

Why /g/, why!?
>>
Ask me questions about directives you fags.

So far, all I know is how to replace an html element with some shit in the "directive.template" field thing. Can't get it to work with attributes lololol.
>>
>>47030752

I am not even sure what a callback is, just a function returning something?

Apparently the thing above is a "factory function," which I might be overthinking. A factory function is just a function that returns objects of potentially different types?

>ib4 the comp sci majors tear me a new asshole
>>
>>47030762
Form1.ADOQuery1.SQL.Text:= 'update users set login="' + ComboBox1.Text + '", password="' + LabeledEdit2.Text + '" where login="' + ComboBox1.Text + '"';


No idea really, but have you tried adding a semicolon at the end of your SQL command?
>>
>>47030762
Don't build queries like that, jesus fuck.
>>
>>47025126
You could do it like this:
<div class="no_fun_allowed">
<ul>
<li>/*button*/</li>
<li>/*button*/</li>
<li>/*button*/</li>
<li>/*button*/</li>
<li>/*button*/</li>
</ul>
</div>
>>
>>47030762
SQL injection waiting to happen.
>>
>>47030907

<input type = "text" maxlength = superShort;>

Thwarted nigga! Also, C# and angular sanitize input anyway.
>>
Which way is better or more "pythonic" to break a while loop?

done = False
while not done:
do_something()

done = True


or

while True:
do_something()

break
>>
>>47029086
XShmCreateImage takes an "int format" as one of it's arguments.
What is that and where do i get it from?
>>
>>47030932
>angular sanitizes input
Anyone can send any request to your server. Nobody has to use a browser, plain curl is enough.
Just saying.
>>
>>47031013

True dat actually. I didn't even think of that. >Me.SaltyAsFuck = trueDat;
>>
>>47026716
Probably because he likes anime in the OP.
Close your mouth for once when someone mentions the topic please. It's always obvious it's you the same person starting this shit because you're basically the only person here who doesn't capitalize.
>>
>>47030965
I don't know which one the pythontards prefer, but why waste an extra byte saving a variable when you could just have a break?
>>
Alright, I already can't do basics:

eventsApp.directive('OPISAFAGGOT', function() {
var directive = {};
directive.restrict = 'A'; /* restrict this directive to elements */
directive.template = "My first directive: {{textToInsert}}";
return directive;
});


I bring your attention to:

directive.restrict = 'A';


>By setting restrict to A you specify that only HTML attributes named div should activate the directive.

However this does not work:

<div OPISAFAGGOT> </div>


Isn't "OPISAFAGGOT" a proper attribute? Why doesn't it work?
>>
>>47027619
My friend came into a problem that explains this well:
He was pretty new to C++ too, and he created a variable (a char[][] I think) called map. He was also
using namespace std;
 as well as including a bunch of libraries
So when he got an error in his code (since map is a type name) he had no idea what was going on and it took him forever to figure it out
>>
>>47030965
The second example.

The only instance I can think of using the first way is if you wanted to create a 'try again' construct.

done = False
while not done:
try:
# do something
done = True
except:
# perhaps sleep for time
>>
>>47031201
well I fucked up the formatting but you got the point
>>
>>47031201
Did you just put a code tag into another code tag?
>>
>>47030770
https://www.codeschool.com/courses/shaping-up-with-angular-js

I finished this in a leisurely 3.5 hours, while doing some reading about other libs / frameworks.

>>47030799
you really need to see how you write the whole function / method before it makes sense.


function coolThingsToDo(callback){
var i = 10;
callback(i, 1);
}

function doingThings(j, k){
var tempJMinusK = j - k
if (tempJMinusK > 0){
console.log(doingThings(tempJMinusK, k));
return(j);
}
}

coolThingsToDo(doingThings);


this isnt "corrrect", but it runs.

a callback is just passing a function as an argument and then calling that function with the arguments it needs when the arguments are ready for the function.
>>
>>47031245
maybe
>>
>>47031217
Forgot code block, I'll show myself the door.
done = False
while not done:
try:
# do something
done = True
except:
# perhaps sleep for some time
>>
>>47031247

My boss told me to do the fucking gem store. I guess I should. Iirc it's videos? I hate videos. Doing this:

http://tutorials.jenkov.com/angularjs/custom-directives.html

I guess I will do fucking gem store. Fuck.
>>
>>47031276
>>47031276
>>47031276

New thread.
>>
>>47031012
Same as XCreateImage, you want ZPixmap for your normal X bytes per pixel format.
>>
>>47031247
forgot to add the missed semicolon
function coolThingsToDo(callback){
var i = 10;
callback(i, 1);
}

function doingThings(j, k){
var tempJMinusK = j - k;
if (tempJMinusK > 0){
console.log(doingThings(tempJMinusK, k));
return(j);
} else {
return("Done");
}
}

coolThingsToDo(doingThings);

fixed the semicolon and always returns a value.

NOW it will run
>>
I'm thinking about becoming a programmer. Don't know too much about it, but I teach myself a little bit everyday. Soon I will be going to school for software engineering.

My only question is, is this a good field to get in to? Is the pay good, job security, flexible work schedule (as opposed to the standard 9-5), etc.? I know every position will be different, I'm just asking those who do work in this field what it's generally like. Sorry if this is the wrong thread to be asking in.
>>
>>47031282
ya, it was legitimately really easy.

I probably only watched 20 minutes of video.
>>
>>47031333

I am the guy learning angular. Yes, programming is a very good field to be in, at least right now. I didn't major in it and I am salty as fuck everyday.
>>
>>47031314
>Same as XCreateImage
Keep in mind i have never used Xlib, i have no idea what you're talking about.
What functions do i call to get format?
There's no fucking useful docs on the internet anywhere.
>>
>>47031367
>What functions do i call to get format?
Get what?
You're the one creating the image, specify ZPixmap and 24 bits per pixel and you get your typical true color image format.

As for docs, the best is to read the X protocol spec, that's what xlib is abstracting.
But for using xlib http://www.x.org/releases/X11R7.5/doc/ should get you up and running.
>>
>>47030965
second way
also look into:
>http://www.tutorialspoint.com/python/python_loop_control.htm
>>
>>47031468
Ok, so i got everything working, except even though i specified 24bit depth, it's still 32bit, why?
I need specifically 24.
>>
>>47023162
the algorithm is probably obvious, it's just that the code is illegible. i can decipher parts of it but holy hell would it hurt to put some comments in there?

also
>((SIZE << 1) - i) / 2
bit shifting to multiply by 2 but plain dividing by 2? what the fuck. not that the compiler couldn't handle it but at least stay consistent.
>>
>>47031828
>++i, dir = i & 3 )
and here it wouldn't hurt to put //i & 3 == i % 4

even if no one else would read the code (but then why put it on github) then it still wouldn't hurt to have a reminder in there so you wouldn't have to wonder if you have i & 3 for some other reason
Thread posts: 351
Thread images: 24


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]
Please support this website by donating Bitcoins to 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
If a post contains copyrighted or illegal content, please click on that post's [Report] button and fill out a post removal request
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.
This is a 4chan archive - all of the content originated from that site. This means that 4Archive shows an archive of their content. If you need information for a Poster - contact them.