/dpt/ - Daily Programming Thread

Previous thread: What are you working on, Sup Forums?

Other urls found in this thread:

docs.oracle.com/javase/tutorial/
math.ucsd.edu/programs/undergraduate/bs_math_comp_science.php
cse.ucsd.edu/node/239
boards.Sup
cs.cmu.edu/afs/cs/academic/class/15213-s15/www/schedule.html
scs.hosted.panopto.com/Panopto/Pages/Sessions/List.aspx#folderID="2bfb939e-6ed8-4220-a877-c4f96a126b48"&folderQuery="15-213"&page=1
en.wikipedia.org/wiki/List_of_HDL_simulators
ece.cmu.edu/~ece447/s15/doku.php?id=schedule
anyforums.com/
twitter.com/SFWRedditVideos

gf ai so i'm no longer lonely.

O
SHIT
WADDUP

WHO DAT BOI?

Can someone tell me what is wrong with this? I get a segfault.

## HEYNOW.S ##################################################################


.section .data
# system call numbers
.equ SYS_OPEN, 5
.equ SYS_WRITE, 4
.equ SYS_READ, 3
.equ SYS_CLOSE, 6
.equ SYS_EXIT, 1

# system call interrupt
.equ LINUX_SYSCALL, 0x80

# options for open
.equ O_CREATE_WRONLY_TRUNC, 03101


# strings
outfile_name:
.ascii "./heynow.txt\0"
heynow:
.ascii "Hey diddle diddle!\n\0"
.equ SIZEOF_HEYNOW, 20


.section .bss
.lcomm OUTFILE_FD, 4


.section .text
.global _start
_start:
# open OUTFILE
movl $SYS_OPEN, %eax
movl $outfile_name, %ebx
movl $O_CREATE_WRONLY_TRUNC, %ecx
movl $0666, %edx
int $LINUX_SYSCALL
# save the file descriptor
movl %eax, OUTFILE_FD

# write to OUTFILE
movl $SYS_WRITE, %eax
movl $OUTFILE_FD, %ebx
movl $heynow, %ecx
movl $SIZEOF_HEYNOW, %edx

# close OUTFILE
movl $SYS_CLOSE, %eax
movl $OUTFILE_FD, %ebx
int $LINUX_SYSCALL

# exit
movl $0, %eax
movl $SYS_EXIT, %ebx
int $LINUX_SYSCALL

I've never done any programming in my life. How could I unfuck my shit and become an employed programmer?

docs.oracle.com/javase/tutorial/

start programming.

(OP)
Stop with these horrible memes.

I love that DAT BOI meme >u<

It's so spontaneous. O SHIT WADDUP!

Sorry to bother you guys, i've never programmed in my life (does rainmeter editing count? How about editing registry stuff on win 10?) Anyways anyone have more DAT BOI?

Sup Forums, I supposedly wanted to apply for Computer Science in UC San Diego, but it seems that I applied for Mathematics - Computer Science instead
I got accepted to UC Irvine for Computer Science and UC Davis for CS as well.

I wanted pure computer science though, and I'm worried employers might take it back for Math-CS instead of just pure CS.

Thoughts/Advices?
I have ~9 days to accept my offer
math-cs math.ucsd.edu/programs/undergraduate/bs_math_comp_science.php
regular cs
cse.ucsd.edu/node/239

How much do employers care?

become pajeet my friend. I have a CS degree and I can't get employed as a programmer.

please just use Option types instead of exceptions

Exceptions are the next goto, considered harmful for most usages. It has its use, when an exceptional state is reached.

>I have a CS degree and I can't get employed as a programmer
Have you ever considered that you're shit?

for error handling*

You could always just change your major, it not like you are stuck with it.

Why not Either types?

I am not shit

I don't know. It sounds like you're pretty shit.

300k starting

sure

>tfw no degree
Being completely hopeless fucking sucks.

...

How does your editor look Sup Forums?

I've been coding like this for about a year. Makes me chuckle.

I am pretty sure you are the shit one my man.
Either types are probably better than option types when you want to return an error message
better than having a degree and still can't get a job

lol how does someone even prove their not shit at coding lol your just typing words, making shit work lol like stop taking urself so seriously lol

I really think you should leave.

>lol
>lol
>lol
>lol
yeah, sounds like you're literally shit

lol

anyone else get drive through then eat it in the parking lot

No, I cook my own food.

Nine times out of ten, if you can buy it drive-through, it's not worth ingesting.

i live in a dorm and my kitchen isn't operable
apartment in August though with my pals so I can cook then
but you're right

thanks for reading my blog, please follow

good book?

Yes

...

>DPT loves a Tumblr meme
Wow. Nice. I didn't know Sup Forums stooped to a new level.

nigga it got a fukin dragon and whitenite on it

course it is

learn to slay that pussy

>le tumblr boogeyman

Half loves, half hates
same as every other meme

Haha thanks! Here is a pepe Sup Forums likes!

still downloading shit off NOAA's ftp slow as FUCK

WADDUP!

x86 asm is a horrible turd

It seems that it's pretty much impossible to transfer to CS internally in San Diego

I really wanted to go there though, should I just give up the school and go to Davis/Irvine for CS?

This is probably my life's worst fuck up ever.

oh right, I forgot some schools have limits.

Probably. You can't go wrong with either school.

Thinking about using Qt as the framework for my app. Any C++ frameworks i should be looking into instead? Mainly planning on circumventing browser connection through a native client.

Ah fuck it

I'm doing Math-CS, I honestly don't really care if it's more math focused. It still has many core CS courses.
I'll just hope employers/internships won't take it against me.

Thanks. I'm keeping UCSD.

I don't think employers will care which computer science major you took rather than your programming skills/problem solving

Rate my solution.

open System

let cross n =
Seq.init n (fun i ->
Seq.init n (fun j->
if i = j || (i + j + 1) = n then "*" else " "
) |> Seq.reduce (+)
) |> String.concat "\n"

let rec ask msg error =
printfn "%s: " msg
match stdin.ReadLine() |> Int32.TryParse with
|(true, n) -> n
|_ ->
eprintfn "%s" error
ask msg error

let rec main() =
match ask "Enter a positive number or 0 to exit" "Invalid number" with
|0 -> ()
|n ->
if n printf "%s"
main()

main()

...

damn F# is ugly shit

Designated with extra curry

how do you fags control yourselves?
I seriously am practically all day long sitting in my computer... and even then, I just can't concentrate on doing something useful. I keep trying to distract myself. this is insane.

I have a shitload of ideas, and little to show, plus little motivation to do any of them ;_;

same fambly
it's so easy to just sit and do nothing

>Exceptions are the next goto
Useful in certain situations?

>It has its use, when an exceptional state is reached.
No shit you fucking retard, what were you using them for? flow control?
I have actually seen a Python script that uses exceptions for flow control, that's Python programmers for ya.

>using namespace std;

I have not done a single productive thing in 7 months. Send help.

I just made a random string generator that gets n chars from /dev/urandom concatenate to a string then prints to standard out.

Have you seen C#, C++, and Java programs? Exceptions are overused and not used for exceptional purposes

use When guards

I want to experiment with assembly language and verilog. How do I get started with this? Is there any special steps to using a such low level languages? I imagine I might have to use an emulator or something as to avoid running shit code on my actual processor.

It would make me use the recursive main() call in both paths, once for negative numbers and one for positive ones.

It's like, I like Java, but the fact that it's used by poos and all of the HackerRank challenges are created by poos makes me sad and not want to use it.

did it take you longer to write that program or to write that post?

printf or cout?

cout

That pic is university-level CS programs in a nutshell. Just fucking great.

Also, printf. But never scanf.

>AT&T
kill yourself nigger

is this not the same?
let rec main() =
match ask "Enter a positive number or 0 to exit" "Invalid number" with
| 0 -> ()
| n when n < 0 -> eprintfn "It must be positive"
main()
| n -> cross n |> printf "%s"
main()

>he supports israel

It is. I changed it because both paths have the call to main(), so I made the 'if' so I can branch only what needed and have only one call. Just style, I guess. I would guess that the performance is the same, as it has a check and a binding in both styles.

> using bloated Sup Forums addons
plebs

// ==UserScript==
// @name Sup Forums_expand_imgs
// @version 0.1
// @description Expand images
// @match boards.Sup Forums.org/*/thread/*
// @grant none
// ==/UserScript==
/* jshint esnext: true */
(function(){
"use strict";

let button = document.createElement("div");
button.textContent = 'Expand Images';
button.style.position = 'fixed';
button.style.top = '2%';
button.style.right = '2%';
button.style.borderStyle = 'solid';
button.style.borderWidth = '1px';
button.style.padding = '4px';
document.body.appendChild(button);

function expandImages() {
document.querySelectorAll(".fileThumb > img:first-child").forEach(el => el.click());
button.removeEventListener('click', expandImages);
button.addEventListener('click', collapseImages);
button.textContent = 'Collapse Images';
}
function collapseImages() {
document.querySelectorAll(".fileThumb img[alt='Image']").forEach(el => el.click());
button.removeEventListener('click', collapseImages);
button.addEventListener('click', expandImages);
button.textContent = 'Expand Images';
}
button.addEventListener('click', expandImages);
})();

a little rusty on C++ here,
i made a program which declares the array iArr1,
i want to make a function that sets the value of all elements to 0 in a custom header, can i use a void function and just call the variable (iArr1) or do i need to use pointer shenanigans?

you probably want to pass the size of the array fambly

the code is something like this:
void CleanMatrix(){
for(int i=0; i>8;i++){
for(int i2=0; i>8;i++){
iArr1[i][i2]=0;
}
}
}

if i were to call the array from the secondary file would it work?

what the fuck
pass the array to the function

honestly start over, start your C++ book from the beginning, better yet, start a different book

How do I into Haskell?

I know some bash and python and I've messed around with java

Learn you a Haskell for Great Good, free online.

learnyouahaskell nigga

but research monads at the same time, because being creative in your own way with haskell takes a backseat when you go through a book that's just rules & principles

Please for the love of god, actually learn to program. You're language hopping too much.

I've heard mixed things about LYAH, but great things about Thinking Functionally with Haskell.

>You're language hopping too much
That's all these threads are about, people learning how to do fizzbuzz in some language, thinking they have mastered it and then ask what they should "learn" next.

what would be the proper way to make an SQL table that checks that only one row of a certain group can be true?

For instance:
ChatID, user, ownerYN
01, 15, Y
01, 27, Y

kinda this, language hopping is fun but you won't get gud until you stick with something. first few years of programming for me was trying a whole bunch of languages and hating most of them but it took me like 3 years before I sucked it up and sat down to write "real program" on my own. after I did that a lot of it started to come naturally and it made it easier to transition between languages

You will need to master various languages in the real world, or even in your larger personal projects, even outside webdev

Sure, but most people around here read some book on a language and think they have mastered it, I'd bet that anyone here who "know" 10 different languages are not able to write any sort of non-trivial program in any of those languages.

restructure your table so that it has a foreign key or a 1to1 relationship with an owner, and non-owners have a foreign key or a m2m relationship with chats

if you're asking about the SQL query to verify a chat has only 1 id, you'd have to group by chat, counting Y's, then equate it to 1

>>>>>>>>>>>>>>master
exactly
Language mastery doesn't come in a week or two.

>but most people around here
You don't know most people around here

True, but mastering 1 at a time is not a valuable life skill either

yes, but you dont need to master a language to write non-trivial programs in it. you can learn enough to be able to productively write code without necessarily being an expert on the language

gotta get the ball rolling m8, just fucking start doing it RIGHT FUCKING NOW and you'll keep doing it.

Here you go
cs.cmu.edu/afs/cs/academic/class/15213-s15/www/schedule.html

There's lectures too but the notes cover everything just as well scs.hosted.panopto.com/Panopto/Pages/Sessions/List.aspx#folderID="2bfb939e-6ed8-4220-a877-c4f96a126b48"&folderQuery="15-213"&page=1

Yes you would want an emulator en.wikipedia.org/wiki/List_of_HDL_simulators

>if you're asking about the SQL query to verify a chat has only 1 id, you'd have to group by chat, counting Y's, then equate it to 1

I'm a bit confused. I'm not sure how you'd go about this other than including a select count query inside of a check constraint.

Could you explain?

That's how you master them my man.

This course covers verilog
ece.cmu.edu/~ece447/s15/doku.php?id=schedule

The other is asm

HELL-0 FROG-0

To verify 1 ChatID:
SELECT SUM(CASE WHEN ownerYN='Y' THEN 1 ELSE 0 END)=1
FROM yourTable
WHERE ChatID=

UCSD CS major here (got in before it was impacted). Just take the Math-CS major. You could try petitioning into CS, but that will require a 4.0 in most under-div courses (CSE 11, 12, 20, etc). Even then, its not guaranteed. The shitty part about CS now is that all the classes are full as fuck so better hope you have a lot of transfer credits if you don't like waitlists

for multiple ChatIDs (you should use the AS for my previous query as well):
SELECT ChatID, SUM(CASE WHEN ownerYN='Y' THEN 1 ELSE 0 END)=1 AS 'Only 1 owner?'
FROM yourTable
GROUP BY ChatID

open("./heynow.txt", O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, 0666) = 3
close(134517024) = -1 EBADF (Bad file descriptor)


from strace