/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Old thread:

Other urls found in this thread:

pastebin.com/HCh3sShD
pastebin.com/J4RkmKVV
css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/
code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800
twitter.com/NSFWRedditVideo

Does this make sense??
pastebin.com/HCh3sShD

(vi) Carmack intentionally destroyed data on his computer after he got notice of this litigation and right after he researched on Google how to wipe a hard drive—and data on other Oculus computers and USB storage devices were similarly deleted (as determined by a court-appointed, independent expert in computer forensics);

(vii) when he quit id Software, Carmack admitted he secretly downloaded and stole over 10,000 documents from ZeniMax on a USB storage device, as well as the entire source code to RAGE and the id tech® 5 engine —which Carmack uploaded to his Oculus computer;

Do you back up the code you write at work to a personal location so you can reference it later?

Is this unethical?

The best coders in the world today learned Python as their first language

Now I can use monads properly in Haskell. This is, as monoids in the category of endofunctors of Hask

type Monad cat = Monoid (EndFunCat cat) (EndFunComp cat)

data HaskEndoFunc :: (Type -> Type) -> (Type ~> Type)

instance Prelude.Functor f => Functor (HaskEndoFunc f) where
type Dom (HaskEndoFunc f) = Hask
type Cod (HaskEndoFunc f) = Hask
type Map (HaskEndoFunc f) a = f a

wellDefinedFunctor _ _ = Sub Dict
fmap _ = Prelude.fmap

instance Prelude.Monad m => Monoid (EndFunCat Hask) (EndFunComp Hask) (HaskEndoFunc m) where
mempty _ = Nat (\_ -> Control.Monad.return)
mappend _ = Nat (\_-> Control.Monad.join)

-- proof that IO is a monad
io_monad :: Dict (Monad Hask (HaskEndoFunc IO))
io_monad = Dict -- YES!

That's literally impossible since the best """coders"""" in the world today programmed long before Python was ever conceived.

>Python
>best coders
choose one

implement java.util.Queue interface, and pass queue to something that expects a queue and see if it works.

If Turing knew Python he would have ended the war in a week and not gone to prison

>Go is a like Plan 9 (the movie, not the OS). So hilariously bad it's good.
What the fuck, I just watched The Chinese Restaurant last night.

if turing knew python he wouldn't have an interpreter to run it

turing was puting python into his ass because he was a faggot

lets say we write a program that can improve itself by 0.0001% each time.

wouldnt this program take over the world in a week thanks to exponential growth?

Considering the speed of computers of that time, Hitler would bomb the world twice while the code was running

Define improve.

Depends how long "each time" takes.

Also

Nico is such a brat

why is this desirable

} catch (FileNotFoundException e) {
e.printStackTrace();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}

}

}

Smells like curry

When I dequeue something, I just doesn't work.


Queue branchQ = new Queue();

for(int i=0; i=1)
{
name = input.nextLine();
}
System.out.println("ENTER another things: ");
int dept = input.nextInt();
System.out.println("ENTER LOCATION: ");
String loc = input.nextLine();


OppoBranches oppo = new OppoBranches (name,dept,loc);//already defined
branchQ.enqueue(oppo);// the queue things


}

OppoBranches oppo1 = null;
while(!branchQ.isEmpty())
{
oppo1 = (OppoBranches) branchQ.dequeue();
System.out.println(oppo1.toString());
}

catch (FileNotFoundException e) // handle case where file doesn't exist
{
e.printStackTrace();
}
finally // dispose of resources whether code runs as expected or not to avoid orphaned resources
{
if (br != null) // if 'br' (some sort of reader?) still exists...
{
try
{
br.close(); // close the reader handle
}
catch (IOException e)
{
e.printStackTrace();
}
}
}

Not so sure about the additional try/catch within the finally, but why did you post it in a mangled format? Doesn't even fit K&R, if that's what you were going for.

best_coders = "alive today"

(best_coders == "alive today" and print("python =",True) )
[/code}

can I have some lamb with my curry?

That would be 550 yen sir.

I wrote a short script that adds "expand" button to Sup Forums catalog so you can expand the post.
The syntax at the beggining is for tampermonkey. You would probably have to adjust it for greasemonkey.
pastebin.com/J4RkmKVV

>best coders
>fuck up markup

Yeah, memes on memes meme memes out.

Learning assembly at uni. Don't think it's too bad right off the bat. Does it get easier or harder?

Does a 1 page CV look lazy? I'm a recent CS grad so I don't have a huge amount of relevant shit to put on it, but I really like how concise and neat it looks.

Any cool name for a 4-person C project team? I can't come up with anything better than "Shadilay MAGA" (and MAGA is taken by another team).

>memes on memes meme memes out.
underrated statement

The C-ucks

The C-Section

Top 5 Meme Languages for meme programmers:
1. Python
2. Haskell
3. Rust
4. Go
5. Swift

A 1-page CV is a résumé, and no, it doesn't look lazy, it looks like you've summarised your most relevant experience.

Easier the more you do it, but you forget it very quick if you don't keep doing it.

change swift with lisp and you have a perfect list

>tfw you thought you were studying CS at MIT but you were actually just learning memes at MIT

That depends on how far you are. If you get all t he concepts like how instructions can affect flags and how you need to know to push some things on the caller end of functions and others on the calling end, then it doesn't really get harder, just more tedious. If you're not at that point, then it'll get a little harder. Assembly is mostly just tedious, knowing stupid tricks, and testing a lot of things to see what is fastest or how small you can get something (also tedious)

at least Python is fun

yeah ive figured out the tedious part for myself already. honestly i dont really mind it, it is something i can get used to, i already spent most of this morning trying to get an assignment as perfect as I could get it so i hope it gets easier from here on out. thanks for your input

and useful
and actually allows you to get a job

>Meme Institute of Technology

If I ever get a boat, was thinking of calling

The sea dagger dagger

Can you guys help me with an assignment? You're given an user entered string, and when entered, you're supposed to change A and a to 01, B and b to 02, the rest can either be one or two chars (C and c can be either 3 or 03), and then write it out to the user.
This is the easy part, but how would you decode it?

Also, you're not supposed to use arrays.

This is in most cases illegal, depending on what your employer had you sign when you started working. Unethical? Nah. Could get you in a lot of trouble though

what language?
also decoding is pretty easy, just think about why a and b need the zero

>calling programmers coders
>implying fortran and C didn't produce the best programmers

x86 ASM
yes, i know it's because of the number of letters in the alphabet

C#.
I know the logic behind it, but it's a new language so I'm writting pajeet code. So far I have 26 instances of the stringName.Replace and I don't know how exactly to use it in a for sentence correctly. I'm thinking to make the counter go from a to z, increment by one, but I don't know if the syntax will be correct.

someString = someString.Replace("A", "01");
.
.
.
someString = someString.Replace("Z", "26");


This would be the current code.

Are you allowed to use either the C library or syscalls?

is this how you use code? sorry new here
.

well I'm not familiar with ASM. by no arrays do they mean just go through your input one char at a time?

Should I use Atom

I'm doing exercise 6 of Learn Python the Hard Way. Something I don't understand
x = "There are %d types of people." % 10
binary = "binary"
do_not = "don't"
y = "Those who know %s and those who %s." % (binary, do_not)

print x
print y

print "I said: %r." % x
print "I also said: '%s'." % y

hilarious = False
joke_evaluation = "Isn't that joke so funny?! %r"

print joke_evaluation % hilarious

w = "This is the left side of..."
e = "a string with a right side."

print w + e
How is the %r variable linked to hilarious = False?

I can understand how %r is linked to "I said: %r." because x is assigned as a variable to that string. But I don't understand the %r variable linking to the hilarious variable being False.

how do you get better at design/architecture for anything but small projects
most of the time my projects tend to drown in refactoring work because the original design didn't cover some unforeseen use case

So I just started learning programming 3 weeks ago and I'm using C programming for the Absolute begginer by Michael Vine
Can this thread help me with the books challenges? If not where should I go?

Literally not me.

No.

I'd suggest going through the (toLower'd) string char by char, C# probably has for-each loops, and then you could probably just do print(toString(c-'a')), just take special care for a and b

or (c-'a')+1, c being the current character

What problems are you having specifically, cuteposter?

No use sublime instead since you can build directly in sublime

Current loop looks like this:

for(char numb = 'a'; numb

#include

void encode(const char* input)
{
while (*input != '\0')
{
int c = *input - 'A' + 1;
if (c < 3)
{
printf("0");
}
printf("%d ", c);
}
printf("\n");
}

int main()
{
encode("POO IN LOO");
}

The challenge is to write a program that displays this mathematical problem: a=5, b=1, x=10, y=5. f =(a-b)(x-y) using a single printf()
The compiler I'm using says I can't use mixed declarations and code and i think its because i have several lines that start with int

Take a look
#include

main(){
int a, b, x, y;
a=5;
b=1;
x=10;
y=5;

int fOperation;
fOperation = a - b;

int jOperation;
jOperation = x - y;

int Result;
Result = fOperation + jOperation;

printf("\nThe vale of a minus b is d%", &fOperation "the value of x minus y is d%", &jOperation "Together they make d%", &Result);
}

first, learn python3
second, %r is not a variable, it's a printf format thingie or something, it only tell the print statement that whatever follows the string after the % sign should be turned into a string (via repr()) and inserted there. so first you tell it to print "I said (whatever x is)" (%r got replaced by repr(x)) and after you print "isnt this funny? False", because %r in this string got replaced by repr(hilarious)

>fOperation + jOperation


int f(int a, int b, int x, int y)
{
return (a - b) * (x - y);
}

int main()
{
int a = 5, b = 1, x = 10, y = 5;
printf("%d\n", f(a, b, x, y));
return 0;
}

replace 0 with (numb

I use to have this problem in a major way. What I do now may or may not be the "right" way to do it, but it works for me.

First, I plan out what features I know it must have. Say for example I know my package manager must install, remove, update, and track packages. Install and removing packages are higher priority, so I start with them.

I hack away at a project first. Just to outline the basic functionality. It's often monolithic in nature, and may not be optimized or memory efficient. So in the context of my package manager, it now can install and remove software.

Then, I completely rewrite it with the goal being to modularize. Now that I have a fairly solid idea on how I need to implement certain baseline functionality, I begin to think of expansion, and program with possible future functionality in mind. Once I have the original monolithic hacked program broken down and neatly optimized, I begin to implement the next level of functionality.

So in the context of our example, instead of a program that only installs and removes software, it now is a program that accepts a command; though the only commands it has right now are install and remove. I then begin to implement the next level of functionality, IE add an update command and package tracking.

After the second level of functionality has been implemented, if a rewrite needs to occur (due to any unforeseen use case) it happens now. And the development cycle continues.

Okay thanks

I see my mistake now, I will try fitting all the integers into a single line next time.

you got the format specifier the wrong way round, it's %d not d%, also &fOperation is the address of fOperation, but you need the value here, so just fOperation is enough
also printf wants one string and the rest is stuff to be put in the string, so your printf should be something like
printf("this=%d, that=&d, all=%d",fOp,jOp,R);

Your program would've worked had you fully understood the printf function.

Though it would have worked, it is a poor solution. Not a bad attempt since you're just starting out. The biggest part of learning to program is learning to think in ways you may not normally think.

Something like this is really how it should be done.

Thanks. The book I'm using teaches python2. I figure I can learn python3 quickly after I learn python 2.

Same output.

No. Just learn python3. Then be aware of the python2 differences so if you absolutely have to use 2.7 for some strange legacy package then you can do it.

Complain about java....still use code style like in java 6.....read some new shit men use try properly
String sourceFile = "files/myFile.txt";
try (
FileReader fileReader = new FileReader(sourceFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
) {
// Your shit here
} catch (Exception e) {
e.printStackTrace();
}

what's stev? (in your for statement)

Give me an app idea I can program in android. I'm bored. No anime.

Oh, yeah, that's numb, I just changed names.

tfw too dumb for machine learning

So the issue isn't the way I typed the integers but the printf() function misreading the rest of the program?

css-tricks.com/tales-of-a-non-unicorn-a-story-about-the-trouble-with-job-titles-and-descriptions/

here's something worth a read, /dpt/


>I mean – I would be suspicious of someone who could solve fizzbuzz off the >cuff. They are likely to:
>1. have too much time on their hands
>2. had too many interviews asking that question
>3. be unsufferably arrogant
>4. or all of the above.

What do you recommend for learning python3?

This is old AF user. But he is correct though, I do have too much time on my hands. Rate my fizzbuzz.

## Functions ###
range = $(if $(filter $1,$(lastword $3)),$3,$(call range,$1,$2,$3 $(words $3)))
make_range = $(foreach i,$(call range,$1),$(call range,$2))
equal = $(if $(filter-out $1,$2),,$1)


### Variables ###
limit := 101
numbers := $(wordlist 2,$(limit),$(call range,$(limit)))

threes := $(wordlist 2,$(limit),$(call make_range,$(limit),2))
fives := $(wordlist 2,$(limit),$(call make_range,$(limit),4))

fizzbuzz := $(foreach v,$(numbers),\
$(if $(and $(call equal,0,$(word $(v),$(threes))),$(call equal,0,$(word $(v),$(fives)))),FizzBuzz,\
$(if $(call equal,0,$(word $(v),$(threes))),Fizz,\
$(if $(call equal,0,$(word $(v),$(fives))),Buzz,$(v)))))


### Target ###
.PHONY: all
all: ; $(info $(fizzbuzz))

You can learn python3 from your book in python2. The biggest difference that will impact your learning is the print statement syntax is different and uses parenthesis instead of a space.

Basically in your book if you get errors in python 3 interpreter then you know there is a change and just look it up and start doing it that way. Your book explains programming concepts, it doesn't require python2

Okay, with this code, I get pic related output. How do I edit it, so that it doesn't change 01 to 1 and 02 to 2.
The rest seem to be working fine.

i = 0;
for(char numb = 'A'; numb= 10)
someString= someString.Replace(Convert.ToString(0)+i, Convert.ToString(i));
Console.WriteLine(someString);
}

>illegal
Regardless of what you signed, it wouldn't be "illegal".

forgot code


print "python2 is old"

print("use python3 instead, it's 2017")

Oh. I see. Thanks for telling me that. I didn't think of it. I have both python2 and python3.

it's looking for 010, and that's right at the start there, so I think
i = 0;
for(char numb = 'A'; numb=10)
someString= someString.ToUpper().Replace(Convert.ToString(numb), (Convert.ToString(i)));
else
someString= someString.ToUpper().Replace(Convert.ToString(numb), (0+Convert.ToString(i)));


}

should work better

user...

var input = "the quick brown fox jumps over the lazy dog";

var output = string.Join("", input.Select(x => x == ' ' ? " " : (x - 96).ToString().PadLeft(2, '0')));

Took an internship and have to learn PHP and MySQL.

Made my own login system with cookies and a simple message board.

Trying to figure out everything as the boss gives me tasks to do while doing tutorials and reading up on official documentation.


What can I do to make him more likely to hire me at the end of the internship?

stop browsing here and stop looking at anime while at work user

good luck

suck his cock every day

its 7 pm I'm at home already

then why arent you sucking his cock after work hours

More study less talk

Just to verify, pic related.

200805 1721090311 0218152314 061524 1021131619 15220518 200805 12012625 041507
t h e q u i c k b r o w n f o x j u m p s o v e r t h e l a z y d o g

Was reading this meanwhile code.tutsplus.com/tutorials/scheduling-tasks-with-cron-jobs--net-8800

you got any good php go-to sites that are not php.net or stackoverflow?

I don't know all the syntax yet, C# is new to me.

How do I decode it though? This is the one that's giving me trouble. If I just invert the if clause, it doesn't give me the correct output.