/dpt/ - Daily Programming Thread

Old thread: What are you working on, Cred Forums?

Other urls found in this thread:

haskell.org/onlinereport/decls.html#nested
en.wikipedia.org/wiki/Sieve_of_Eratosthenes
ix.io/1qJ8
en.cppreference.com/w/cpp/algorithm/for_each
pastebin.com/JpaaxBAW
pastebin.com/MEAtHVcY
spacemacs.org/
electroons.com/8051/ebooks/expert C programming.pdf
youtu.be/j84pZM840eI?t=15m17s
blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.html
cs.ecu.edu/karl/cinnameg/8-2/lin/Misc/get.html
twitter.com/SFWRedditGifs

first for prolog

Need good resources on Windows Driver Framework.

Also, my VM is not working. I'll deal with that tomorrow maybe. Tonight, reading.

why the fuck does fclose(NULL) segfault
who the fuck thought that this was a sane idea
fuck you

Ok.... so I looked it over, and realized I've done everything it says at least several times.

Then I decided to fuck with the path.
It doesn't detect any folders deeper than the "/media/" folder.

Why not?

It might not have the proper permissions.

wait.... the path seems to be to the fucking root of my drive.... it does NOT seem to be to the site...

gimme a couple mins. I'm gonna try this....

An extra null check is one wasted instruction which in 1978 was a really big deal.

Because if you dereference a null pointer, you get a segfault. The standards developers could have said that fclose should simply return if passed a null pointer, but why would they do that? It would be faster to simply not check if the argument is null and assume that the programmer is smart enough to supply a valid argument. Why are you calling fclose(NULL) anyways?

I quickly read SO, and it's because fclose doesn't check for programming errors, but instead for exceptional conditions. Honestly, I don't think it should have to check for NULL, since you're supposed to check for it yourself, and you can do that where you please

that would make sense but then why does free(NULL) work fine?

just trying to reuse error stuff
i mean it's not that big of a deal i can just slap an if there, but it's still a pain

cleanup:
if (finput)
fclose(finput);
if (foutput)
fclose(foutput);
free(outputname);
exit(exit_code);

if you open a file and use it, you have to check it for being NULL anyways, so the following colde will NEVER pass NULL to fclose.
FILE *fp = fopen(name, "r+");
if (fp == NULL)
return;

... do something with fp here ...

fclose(fp);
So it would be a waste to have fclose check for NULL again!

Which is the most fun to learn:
>C
>C++
>Lisp
>Assembly

My python and SQL are good, and they've helped me a lot at work, but I'd like to learn something more low-level

but I can end up doing goto cleanup; after I fopen() finput but before I fopen() foutput. i guess i could add another early_cleanup label but i think more complexity than it's worth

I'm not actually sure then. Maybe it was different people who made free and fclose.

How formal does this have to be?
I would just argue from the form of the left-most derivations. This will have form of n S replacements giving a string of n T's then k1,k2, ...kn applications of T replacements corresponding to each of the n T's in turn starting from the left. So s[n]T1[k1]T2[k2]...Tn[kn].
It's kind of obvious it's unambiguous at this point. If you want to be more formal/fancy you could count the number of these derivations for n-length strengths and show it's equal to number of n-length strings in the language.

Why the fuck you use C and low level API in 2016
Fuck you

>C++
I don't know LISP and Assembly though.
But while more fun, C++ is also sometimes very annoying. C feels more natural. I can recommended C over C++

Since goto labels are fall-through cou can just clean your resource in the opposite order you opened/created them.

int
file_read(struct File *file, uint16_t *data, size_t pos, size_t size)
{
FILE *fp;
uint8_t *temp;
size_t read;

if (file == NULL || data == NULL)
return -1;

fp = fopen(file->name, "r");
if (fp == NULL)
return -1;

temp = malloc(size);
if (temp == NULL)
goto err_fclose;

fseek(fp, pos, SEEK_SET);
read = fread(temp, 1, size, fp);
if (read == 0)
{
goto err_free;
}

fclose(fp);

for (size_t i=0; i

Why the fuck you dig a hole with a shovel in 2016
Fuck you

#define CLOSE_IF_VALID(FD) if (FD) { fclose(FD); }

Ok, figured it out!

The path was fucked, and then the file type wasn't being checked properly.
I'll fix that last part later. Gotta go to the bathroom

Lisp is the opposite of low-level, it's one of the highest level languages around (don't get me wrong, lisp is fun, but it's a different kind of fun). C is fun because it is relatively high-level, really old, portable, small, simple, and runs on pretty much anything that was made in the last 30 or so years. in different ways. ARM assembly and other RISC assemblies are fun, x86 assembly is a chore but you should still learn it, every programmer should be able to read some assembly. I personally dislike C++, I find it too complex and big and confusing and it scares me.

I'm trying to make web metronome using JS.

Learn C you twat

i guess that could work, thanks

>if you google "metronome" Google gives you a metronome in JS
neat

Huh, I'd always associated Lisp with low-level languages, probably made the mistake of thinking older language = low-level.

What's the use case for Lisp over other high-level languages, in that case? I've seen that Stallman quote about how powerful it is, but I never really understood why

Huh, never even thought of that. I'm gonna try taking it apart and see if i can learn some tricks. Thanks.

Mine will have the ability for more complex beat patterns, though.

I honestly have no idea WTF to do here. Can someone please guide me in the right direction on how to do this:

Write a Java program that does the following:
1. Asks the user for the names of 3 cities, separated by spaces. It is assumed that a given city name won't have spaces in it. So assume you won't have a city name like "Santa Monica".
2. Your program then prints the 3 city names in alphabetical order. For example:
Altadena
Belfast
Covina

You've asked this before

I am not understanding Getchar for the life of me. I don't understand it conceptually I guess. What are some practical examples of this? Conceptually, what is an EOF? Here are some questions at the end of this section that I have to complete but as I don't quite understand the material, I can't.

if (f != null) fclose(f);

You are way overthinking this man.

So a sample input would be:
Covina Altadena Belfast
And the output for that would be:
Altadena
Belfast
Covina

Where do you get stuck?

This takes less than 5 minutes.
Google it.

>Conceptually, what is an EOF?
It's just a special value that signifies the end of a file. You know how '\n' signifies the end of a line? It's like that. But with files. Getchar just reads the next character from a file, that's all there is. Their example loop reads every character until it hits the EOF character, at that point it knows it has read the entire file, so it stops reading.

s =>
s.split(" ")
.sort()
.forEach(c =>
console.log(c))

Lisp has a regular, sexp-based syntax, thus making it easy to parse, and therefore stuff like code generation and metaprogramming (code that edits itself) becomes easier. It also has the whole set of functional programming tools (closures, map, first-class functions, anonymous functions), meaning it's easy to do stuff that lends itself to functional code, such as AI programming or finite-state machines. And then there's call/cc which is just a whole 'nother beast, it's kinda like cooperative multithreading except more flexible, you can pass off whole program states as arguments which can then be resumed at will. It's a different way of thinking, and one that makes a bunch of stuff surprisingly easy.

EOF is just a character that is used by convention to signal that it's the end of the file.

Files can be thought of as text streams, split into lines, words, and characters. The null character, \0, signals the end of a string in a char array. Similarly, the the EOF character, literally EOF, signals the end of the file.

You can use getchar() to read in a char at a time from STDIN (standard input) and create conditions. In K&R chapter 1, you use it to check to see if you have read in the entire file yet in most of those early exercises.

What if I write an EOF character to a file? What if I'm writing a binary file. Is it just impossible to write one kind of character?

>the whole set of functional programming tools (closures, map, first-class functions, anonymous functions)


Where are the types?

getchar() gets a character from the standard input(keyboard)
ill edit the example so its more helpful
int main()
{
int c; //getchar returns an integer, which is 0 - 128 depending on what character you entered(ASCII code.)
while ((c = getchar()) != EOF) //EOF means END OF FILE. This is similar to a \n except that instead of signaling the end of the line it signals the end of a file or input stream
putchar(c); //putchar prints the char version of the ASCII integer from getchar()
}

looking at the example loop though, there hasn't been anything assigned to an EOF. I assume a program wouldn't just randomly assign a character to be an EOF?

download and use the jquery bubblesort function

s => s.split(/\s+/).sort().forEach(console.log)
>cmon step it up bro

For languages A and B, let the perfect shuffle of A and B be the language {w | w = a1b1 ... akbk, where a1... ak is in A and b1 ... bk is in B, each ai,bi is in the alphabet}.

Show that the class of regular languages is closed under the perfect shuffle

Well, technically speaking EOF isn't a char that's just sitting there at the end of your file. It's just what the operating system gives you when you reach the end of a file. The problems you mention, like what about binary files, are up to the OS to solve.

sort . words getLine >>= mapM putStrLn

getchar() returns an int which is important, since EOF does not fit into a single char.
So writing EOF to a file is impossible.

You said it was a character first and now you're saying it's not? So then what is it? (Hint: I already know what it is, but there's problems with your explanation.)
Correct.

>needless regexp
>prints an array

withWords f = unwords . f . words
withLine f = putStrLn . f =

>jQuery
>Java

>>prints an array
Are you sure?

EOF is a macro defined by some C library. You could say it's "random", but it is that way by convention.

True, I guess saying "the whole set" is too strong. What lisp does provide is just a solid, mature implementation of untyped lambda calculus.

What are you reading /dpt/?

No, wait. It doesn't.

java is short for javascript, guess they havent taught you that yet in your intro to cs class kid

>some C library
I don't think you should call the C standard library "some library".

Java is just a subset of JavaScript.

>tfw can't figure out how to create a program to solve a problem that has to have linear runtime complexity
I feel retarded that other people were able to do it easily.

It's a bit more than just random. What if it was < CHAR_MAX?

That prints em all on a single line.

Yes, it's better that way

>You said it was a character first and now you're saying it's not? So then what is it? (Hint: I already know what it is, but there's problems with your explanation.)
Fair point, but initially he specifically asked what EOF is, conceptually speaking. Conceptually it's easy to imagine that it's a special character that signifies the end of the file.

And you could always use unlines if you really wanted them line seperated

Is your code tasty, /dpt/?

Well, what's the problem?

The issue I find with that is that it implies that there's a character reserved for EOF, which isn't true.

isn't it great when compositional operators are randomly left and right precendent
(((sort . words) getLine) >>= (mapM putStrLn))

why?
why can't haskell just either stick with left to right or right to left?

I already know C, you fucking retard.

too bad u'll never C ur penis hue hue

EOF is -1

let cities = readLine().components(seperatedBy: " ")
for city in cities.sorted() {
print(city)
}

I'm passing in a string of coordinates of knights on an nxn chessboard, where n=Integer.MAX_VALUE, and have to return true if all the knights aren't attacking each other, return false if a knight attacks another knight.
Professor said a HashSet would work to solve it but I'm retarded and can't figure out exactly how to keep the runtime linear.
Doing this in Java by the way.

Well, I would assume if you were reading and confused about chapter 1 of K&R that you wouldn't really be nitpicking over what constitutes a char vs a symbolic constant.

If you want to know really why it works, it's because getchar doesn't typecheck and EOF is by convention -1 which isn't a valid integer corresponding to the conventional size of a char.

Does that help? No, not really. Because you wade out into why arbitrary design decisions were made instead of doing the exercises.

Interleave the automata.

(((sort . words) getLine) >>= (mapM putStrLn))
sort (the) words (from) getLine (andThen) (runTheResultsThrough) putStrLn

>projecting

^D

scroll down a bit
haskell.org/onlinereport/decls.html#nested

generally I use parentheses and then remove if lint lets me and if it's not competely unclear

I never asked the original question about EOF. But I thought your explanation could be misinterpreted, which is why I started asking questions.

yes, I'm projecting my inability to see ur penis, hand me a microscope

More functional version
let cities = readLine().components(seperatedBy: " ")
cities.sorted().forEach(print)

This should be sufficient:
for each knight in input:
if this knight's square has been attacked:
return false
else:
mark the knight's square
mark any square the knight is attacking

This can't be done in time linear in n.

or ^Z on linux

if you do epsilon transitions from each A state to a B state, you need to remember what A state you left off from to go back to it

Mythical Man Month.
And a little Code Complete to help me improve my code.

I would have gone with something about needing a projector to see it.

Sure, and half of those responses were made by someone else besides me too.

If you want to know why, it's because the explanation is framed that way and then later elucidated in the book itself, so I gave an explanation that wasn't completely correct in the interest of being suitable for the person asking it in the context, since it's explained that EOF is a symbolic constant anyway when you do the exercise to find the value that getchar returns for it.

O(10n) so it's O(n), right?
Hashset add/lookup is O(1), you have a max of 1 lookup and 9 adds per knight.

You're projecting your inability to see your own penis. Buzz off, virgin.

>FD
>VALID
0 is a valid file descriptor, you know.

Yeah O(10n) is still O(n).
Are you ? Because that looks like O(n^2) to me, unless I'm wrong.

Literally don't bother with Lisp unless you're going into AI.

Fizz

a . b composes b into a
a >>= b pipes a into b
is confusing to me when used in a bulk of code because randomly mixing
a $ b applies the result of b on a
a |> b applies to the result of a on b
would be confusing too

i remember haskellers arguing in favor of $ vs |> to be consistent with the mathematical "right to left" notation, why not for >>=?

The number of knights may be O(n^2) so you can't do it in O(n).

No I'm not, but n^2 would imply looping through the knights twice & I don't see that.

that's what =

No he's not me, I'm me. And I'm pretty certain this is O(n): for // O(n)
if // O(1)
return false; // O(1)
else // O(1)
mark squares // O(1)


I don't see how it would be O(n^2).

Sure, but the asker may not necessarily be reading K&R, so they'll miss that example. Anyways in the beginning they seemed to be confused at what EOF itself was, and although that example may have been fine in K&R, where the book is structured to redefine the explanation, here, the asker may just leave with a misconception.

Oh, well I was thinking linear wrt the number knights, not the width of the board. Forgot board was described as n x n.

Yeah, same.
n^2 would have to loop knights once for each knight, something like this:
for attacker in knights:
for target in knights:
if can_attack(attacker, target):
return false

yeah but >>= is generally used, no?

It IS linear wrt the number of knights.

So, you think you're better than K&R?

Alright, finished the database/manager/everything else for this class

Recommend me more class names available to students/professors in the database

Currently I have
"Unethical hacking", "Numerology for fun and Prophet", "Phrenology basics", "Ancient Sexology", "Physiognomy for active profiling", "Slam poetry 101", and "Social engineering for profit and profit",

but >>= is naturally sequential like *>

m >>= f >>= g >>= h
h =

Not being virgin on the behind isn't something to brag about

I see what you mean, but how would I mark the coordinate being attacked? Wouldn't I have to check each knight against those squares?

but why not keep that idea for . and $?
i've found code using |> to be somewhat more readable than using code $ personally, but mixing orders like that just makes it way more annoying

Why not social engineering for ??? and profit?

Modern Dairy Science
Intro to Formalities
Tattoo Shapes
College Algebra
Big Pyramids

. and $ are pure

You mark a spot by inserting it into your hash set.

Javascript shitter here, try not to get my filth on you as I ask my peasant-tier question.

Here's a weird but simple question:

I was working on forms in express on two separate projects. For whatever reason, neither form would submit correctly - the post just wasn't being sent, nothing was happening when clicking submit. However, when I changed the submit button to an input element instead, it worked perfectly. What's up with that?

Constructed using jade/pug markup.
// Original button
btn(type="submit").btn.btn-info Submit
// Input that replaced it
input(type="submit", value="submit")

It fixed it in both cases. I have no idea why this was an issue.

Nope. Have you heard of prime sieves? This exercise looks like a warmup for a sieve of eratosthenes implementation.
en.wikipedia.org/wiki/Sieve_of_Eratosthenes

Anyway, marking a square is simply setting board[x][y] = true or 1 or whatever

// again, pseudocode because i'm too lazy for correct syntax
// these default to false
bool board[][] = new bool[8][8];

// get each new knight as an x, y tuple
foreach ( (x, y) in knights ) {
if (board[x][y] == true) return false;

board[x][y] = true;
board[x+1][y+2] = true;
// ... etc for all attacked square, make sure to do bounds checking so you're not attacking outside the board
}


You mentioned a hashmap which works just as well as an array in this case, use whatever you were taught in class.

import java.net.InetSocketAddress

import akka.NotUsed
import akka.stream._
import akka.stream.scaladsl.{Flow, Framing}
import akka.stream.stage.{GraphStage, GraphStageLogic}
import akka.util.ByteString


private object PortLine {
def unapply(line: String): Option[Int] = for {
portLine ← Option(line)
Array(port, _) ← Some(portLine.split("/tcp\\s+open", 2))
} yield port.toInt
}

private object IpLine {
def unapply(line: String): Option[String] = for {
ipLine ← Option(line) if line.contains("Nmap scan report for ")
Array(_, ip) ← Some(ipLine.split("Nmap scan report for ", 2))
} yield ip
}

private final class NmapLogParseStage extends GraphStage[FlowShape[String, InetSocketAddress]] {
val input = Inlet[String]("nmap-log-parser.input")
val output = Outlet[InetSocketAddress]("nmap-log-parser.output")

val shape = FlowShape(input, output)

def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) {
override def preStart() = {
super.preStart()
nextLine()
}

def processLine(ip: Option[String] = None)(line: String): Unit = line match {
case IpLine(foundIp) ⇒
nextLine(Some(foundIp))

case line @ PortLine(foundPort) if ip.nonEmpty ⇒
emit(output, InetSocketAddress.createUnresolved(ip.get, foundPort), () ⇒ nextLine(ip))

case _ ⇒
nextLine(ip)
}

def nextLine(ip: Option[String] = None): Unit = {
read(input)(processLine(ip)(_), completeStage)
}

setHandler(output, eagerTerminateOutput)
setHandler(input, eagerTerminateInput)
}
}

object NmapLogParser {
def apply(lineSeparator: String = System.getProperty("line.separator"), maxLineLength: Int = 10000): Flow[ByteString, InetSocketAddress, NotUsed] = {
Framing.delimiter(ByteString(lineSeparator), maxLineLength, allowTruncation = true)
.map(_.utf8String)
.via(new NmapLogParseStage)
}
}

JUST

Underwater Basketweaving
Sex and Gender in Third Wave Jihad

I see. I think I can go on from this. I just wasn't seeing it. Thanks anons who helped me.

alright so I get the concept of getchar and EOF (somewhat) but these questions still elude me. Heres what I've tried to do so far. I've also thought of putting "int EOF" under int c or a for statement like:

for(c, EOF = c)
putchar(c);

>Heres what I've tried to do so far.
Let's start with why. What are you trying to accomplish? The book shows you the correct way to read a file character by character. Are you trying to do something else instead?

A 2D array isn't technically linear so he needs to use a hash table.

*or a 2D array with lazy initialization.

>mfw microkernel morons think there's nothing wrong with running the memory manager as a user-level daemon

lmao where do these retards even come from

Not the same user, but wouldn't you have to separate the loop into two, first one for marking, and then one for the checking, since as it is now, the first knight won't have the second's, third's, etc marks.
I mean, its still O(n), but the pseudocode is bugging me...

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please input 3 city names separated by spaces in one line and press Enter.");
String city1 = input.next();
String city2 = input.next();
String city3 = input.next();

System.out.println(city1);
System.out.println(city2);
System.out.println(city3);

}


bls how do I sort the strings

I can enter with spaces and each string gets a single value, but how do I make em print out in alphabetical order

You won't miss anything because knights can always attach each other.

I'm trying to solve the second question, which is to print the value of EOF.

Oh yeah, my bad.

Stupid frogposter

Technically as long as it's O (n) or lower it's fine.
I don't think so. Your initializing all values on the 2D array to false, and you're only checking certain coordinates for each knight, not the entire 2D array. So it would be O(kn) runtime.

>A 2D array isn't technically linear so he needs to use a hash table.
It's linear in terms of time complexity (notice we never iterate through the entire board). It could potentially be non-linear in terms of space complexity. However we are talking about linearity with respect to the input, which in this case is just knight positions. The space complexity is O(1) because we're always working with a standard size chess board (in the context of OP's assignment anyway). If it had to take an arbitrary size chessboard as an input as well you would be correct to say the array doesn't have linear space complexity wrt the input.

They posted a screenshot of them reading K&R with their original question. That's why it was relevant.

You can double-check if you don't believe me. It's not like I was just assuming they were working through it for no reason.

I always wanted to make a library. Make something useful for other people to use.
And then have people use it. But everything has already been done.

Even when trying hard to think of ways to be productive and helpful I draw a blank.

Programming sucks.

microkernel micropenis detected

I.. don't think this solves the problem. Although admittedly i didn't quite understand the problem.

But if you just loop once over the knights like that you will evaluate if the earlier knights are being attacked before evaluating if the later knights are attacking, giving you false negatives.

Why don't you just print EOF?

You could always just make a better library than the existing one in that category.

this is honestly pretty cute, you're making good progress

you're really close now, just google how to sort in java

Then help maintain an existing library? There's plenty of backend projects out there that could use some help.

Oh the exercises, my bad.
EOF is just a constant that's defined somewhere in the standard library. To print it, simply do:
printf("%d\n", EOF);
Note that it's %d because EOF is defined as an int.

this is what I get.

>But if you just loop once over the knights like that you will evaluate if the earlier knights are being attacked before evaluating if the later knights are attacking, giving you false negatives.
Not true, because if knight A is attacking knight B then knight B is also attacking knight A. Therefore order doesn't matter.

Why are you printing it multiple times? And why aren't you using printf?

Don't make a library for other people to use. Make a library for you to use.

If you can't think of a library you have a use for that doesn't already exist then congratulations, you have everything you need to be in a position to be very productive. Libraries only exist to help people be more productive.

So... I'm trying to get into neural networks...
Is using an adjacency matrix with the usual bool values replaced with weight values a good way to store the graphs?

Oh, and you can use ^D for EOF.

The problem is that you are printing the value of EOF instead of the value of c.

That's basically the code for the copy program in chapter 1 with EOF being passed to putchar instead of the variable being used for getchar.

That code is saying to put EOF for each character in STDIN until EOF is reached in STDIN.

F-FUG don't say that kind of stuff

I forgot it wasn't for general n.
I'd still use a hash table or explicitly describe lazy initialization if this is a homework assignment just to make sure you don't lose points.
Initializing a MAX_VALUE x MAX_VALUE array is a bit much.

Clever. I didn't think of that. I wonder if the professor also missed that?

>If it had to take an arbitrary size chessboard as an input as well you would be correct to say the array doesn't have linear space complexity wrt the input.
The time complexity would also go to O(n^2) unless you do lazy initialization.

Is there a better way to do this? No flame plz user
ix.io/1qJ8

I don't know much about neural networks, but that sounds about right for networks with a fixed number of nodes.

If you want to add a node to the network (in any layer), then you will have to re-allocate the entire structure.

Similarly, removing a node would also be a pain.

>Is there a better way to do this?
Don't use C++.

stl already has a for_each, doesn't it?

en.cppreference.com/w/cpp/algorithm/for_each

Word up.

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
System.out.println("Please input 3 city names separated by spaces in one line and press Enter.");

String city1 = input.next();
String city2 = input.next();
String city3 = input.next();

String[] cities = {city1, city2, city3};


Arrays.sort(cities);

System.out.println(cities[0]);
System.out.println(cities[1]);
System.out.println(cities[2]);

}


OH FUG, I DID IT OH!!!!!!!!!!!!!!!!!!!!!!!!

Please input 3 city names separated by spaces in one line and press Enter.
gayguyville cuckville pajeettown
cuckville
gayguyville
pajeettown


FUG

How can I make this reverse shell bettter
>inb4 don't use python
I don't feel like writing 4000 lines of code so I used python.
heres the server.py
pastebin.com/JpaaxBAW

client.py
pastebin.com/MEAtHVcY

Now do it for a variable amount of cities.

>I don't feel like writing 4000 lines of code so I used python.
Why not use Haskell instead?

I'm trying to learn haskell and I made a list of the dividers of n, only problem is that I get this error:

* Non type-variable argument in the constraint: Num [t]
(Use FlexibleContexts to permit this)
* When checking the inferred type
dividers :: forall t. (Num [t], Integral t) => t -> [t]

the code being

dividers 1 = 1
dividers 2 = 2
dividers n = [a | a

Alright, I think I'm just about done

Sample random student:

////////////////////////////////////////////////////////////////////////////////////////////////////
/Name: His Excellency Huang /
/Date of Birth: 8/6/81 /
/Age: 35 years /
/Home Address: 1086 Atlantic Ave., United Kingdom /
/Local Address: 65 Atlantic Pass, United States /
/Visa class: f /
/Visa permissions: Permits the holder to follow courses as long as the holder is paying their fees./
/Expiry date: Thu Jun 26 16:48:23 PDT 1986 (expires in 31 days) /
/Position: Student /
/ID: -834071953 /
/Balance: 2.3116493 /
/Classes: /
/Modern Dairy Science /
/Screaming (Lecture) /
/Screaming (Workshop) /
////////////////////////////////////////////////////////////////////////////////////////////////////

Never tried it, I have no clue how I would do this in haskell.

dividers 1 = [1]
dividers 2 = [2]

vim or emacs?

what does that mean?

more then 3 cities?

ed

spacemacs.org/
Why not both?

Still working on akari-bbs!

I didn't like how I implemented code tags, so I'm rewriting it so I could use it for other things as well.

Any amount of cities.

Try them both and see which you like more.

The only cost there is time.

Is it that bad? If you had to make spoiler tags with that part of the code, would it be horrible?

>mfw
Am I retarded or is the haskell error that stupid to not point me at the right place?

you are my favourite user

If you're a newbie, vim is easier to get into.
Emacs is really nice if you're working with a Lisp though.

uemacs

The type error is there because it's possible to unify those two types, but because you don't have an extension enabled that would unify them it doesn't.

Numeric literals have type
forall a. (Num a) => a

i.e., a numeric literal can be any type that instantiates Num such as Integer, Float, Double, etc.

It's possible to define a Num instance for lists, so it's possible to unify those equations.

I need a break from web shit, does anyone know a quick and fun C book?

Why are you writing it in C?
Was this a design choice or you just like the language?
And how does writing web stuff in C compare to things like Java or Python?

>fun C

and then that C programmer is dropped into C++ land (because there are no C jobs anymore), calls a function in the "do something" space that throws an exception and he ends up never getting to fclose(fp) and now has a resource leak.

when will the C meme end?

K&R, alternatively Expert C.

K&R.
It's actually pretty short and to the point.

Aside from K&R

C++ is the memiest of memes, mate.
C is here to stay, and there is no indication that it's going to go away any time soon.
>exception
Kill yourself.

I guess you could say took exception to that

this one?
>electroons.com/8051/ebooks/expert C programming.pdf

...

no, the memiest of memes is anything with ".js" at the end.

>using stdio.h in c++
Don't you guys have streams for file io now?
Isn't stdio.h just backwards compatability anyways?

So why do you apply my informative answer into a surrounding it was never intended to be used in?

did my joke catch (you off guard) { ... }

C++ iostreams are an absolute joke.
I can understand why some sepplesfag would want to use the much more sane stdio.

stdio is apparently much faster than iostream too

sepples allows you to
throw 22;

but it doesn't allow you to
catch(22)

She's cute. What anime?

Ye, the fish book.
It has a ton of tips, challenges, real life stories, etc.
It's one of the few technical books I had fun reading through.

>or you just like the language?
It's mostly because I only know C and I wanted to try webdev.
I really do like C tho.

When writing CGI in C, you pretty much have to roll your own everything.

Other languages probably have import do_everything in their standard library for the basic stuff like GET/POST data, input validation, etc.

C++ might be getting a second standard library.

Who #hype here?

link: youtu.be/j84pZM840eI?t=15m17s

it will be shit

>When writing CGI in C, you pretty much have to roll your own everything.
That's part of the charm.

I am expecting to get shat on a bit for posting this, but if I don't like programming, should I get my bachelor's in Informatics? Or should I just do something that isn't related to IT at all.

I am currently in an Associates program for Computer Information Technology, and while I passed the classes with excellent grades that had programming, it was really very basic-tier shit, as I'm sure all of you can figure since its at the junior college level.

I didn't really care for it though. Do understand, this isn't about me coming here and saying "I don't like thing that you like", this is me realizing that if something is not for me, I would be a fool to stick my nose deeper into it.

tl;dr
I don't care for programming. Is a bachelor's degree in Informatics a viable option, or should I seek to obtain a degree unrelated to IT?

Andrei looks so cute~

>C++ might be getting a second standard library.
That sounds terrible.

The mod sounds like he just hit puberty.

Don't mistake your vocation
Select the right location
Avoid debt
Persevere
Whatever you do, do it with all your might
Depend upon your own personal exertions
Use the best tools
Don't get above your business
Learn something useful
Let hope predominate but be not too visionary
Do not scatter your powers
Be systematic
Read the newspapers
Beware of "outside operations"
Don't endorse without security
Advertise your business
Be polite and kind to your customers
Be charitable
Don't blab
Preserve your integrity

Andrei > Scott > Herb imho

He looks like he just hit puberty

There are a ton of other IT degrees that involve less programming. Anything from UX design to networking (i.e. configuring routers) to business management with a tech focus. You don't have to give up on all of IT just because you don't like programming. It could also be that you'd enjoy more of a tech support role, which you can probably go to trade school for (it'll depend on where you live). Tech support is generally seen as low on the IT totem pole, but even tech support comes in all kinds of different forms, sometimes overlapping with system administrator stuff.

I've started learning Perl.
How much of a mistake am I making and what are the most often used cases for it?

Why is programming so shit?

>use cases for perl

no one seems to want it anymore
it's kinda fun

you will be a 1337 hacker

Can you do this on Windows?

#!/bin/bash

for image in "$@" ; do
filename="$(shuf -i 1400000000000-1469999999999 -n 1)"
extension=$(echo ${image##*.})
mv "$image" "$filename.$extension"
done

It seems like it would be very pleasurable to write in overall
>no one wants it anymore
:(

You would probably have to do some registry tomfuckery but there's no reason you couldn't add in a "scripts" context menu and then have that point to a folder with said scripts in them.

Can I do this in OSX?

If hell freezes over and orange Hitler wins the debate, I'll spend the night programming in a one piece

Yes

My choice of variable names was poor. It's a FILE pointer.

Post pics.

The bash script would work at least. Also I realized there is a mistake, useless use of echo.

extension=${image##*.}

Is that a celebration or because you don't like Trump?

If you don't like Trump please escort yourself back to tumblr.

duh

What's a good place to learn about various media encoding algorithms like HEVC?

We'll be waiting! :3

Well, aside from the fact that Bash is supported on Windows through MSYS2, Cygwin, and the Linux Subsystem for Windows, I am pretty sure all of those are features that are available in Powershell (although the syntax would be different).

Trump pledged to aggressively enforce federal obscenity law which applies to lolis.

Just so we're clear, which one is orange Hitler?

Linus Torvalds

Doubt you could get bash scripts integrated and working with a file manager like that on Windows though.

Do you even have a terminal emulator available on Windows that supports copy and paste?

Windows doesn't even support newlines, I would have to backspace it all and then re-create the newlines in Notepad because Windows can't into newlines.

Nothing compared to the civilization-ending leftist ideals that Hillary further pushes.

facebook servers choking
gonna be some job openings over there tomorrow

>every time a website crashes, a web dev loses his job

I need something like this
a single particle in the middle that repels all others

my professor asked me to do this but I have no idea where should I start
any help? I'm thinking about coloumb's law

Make it so it can't overwrite another image.

ofc windows DOES support newlines, anything that does ascii has a newline character, but pressing enter in windows is a /r or a /r/n for some archaic backwards compatibility reason.

I have no idea how this really relates to your conversation, but I am sure you could do a simple find & replace to fix em all in vim. I think its ":s *string*"

Currently working through project euler problems, im relatively new to programming so i've only been able to do the first three on my own (」゚ロ゚)」

blog.cleancoder.com/uncle-bob/2016/05/01/TypeWars.html

its usually ops / IT fault

dev mistakes are generally more subtle than causing the entire website to choke.

don't ruin my dreams user

>OOP and procedural fags arguing about types
Hilarious

Use a repelling inverse square law and the Euler-Cromer method.
What language?

Implementing an Extended Kalman Filter off of my old basic Kalman Filter implementation :D

> You don't need static type checking if you have 100% unit test coverage.
Oh jeez. It's like they don't realize how easy it is to get 100% unit test
coverage if you constrain the types a function will accept/return -_-

not that guy, but if you check the range he's working in is in the range of a short cryptographic hash. unless he is doing this often, with every picture in a folder of thousands of pictures, the chance of a single collision is diminishingly (but not unreasonably) small.

but if someone wants to do the probabilities on that collision and drop some objectivity in here, go for it.

thanks, I'll take a look
C++

>What language?
How is that even relevant?

Just curious.

maybe he wants to help?

how are you even relevant...

Will it happen, probably not but for such a simple script might as well make it impossible imo. I'd be paranoid about being unlucky or having a weird non-default random seed or something.
I think all it would take is something like
while [ -f "$filename.$extension"]
do
filename="$(shuf -i 1400000000000-1469999999999 -n 1)"
done
mv "$image" "$filename.$extension"

It's just stupid how much /dpt/ cares about language.

This is when I say I love writing functional javascript and slip out the back.

bon nuit amigos

I wasn't going to mock his language choice or anything.
I've just seen those sorts of exercises using different languages and was curious.

Donald Trump imagines the average hacker as "someone sitting on their bed who weighs 400 lbs". Welp.

I'm pretty sure that the average American isn't a hacker.

>javascript
>functional
>in any sense

But if the average hacker is american...

QUICK, MAKE A PROGRAM THAT OUTPUTS A STAR OF DAVID WITH A GIVEN SIZE FROM THE COMMAND LINE

OR I WILL FUCKING STAB YOU BITCH

Perl is the only scripting language in the OpenBSD base install. Therefore, the OpenBSD packaging system is 100% pure perl, and so are many of its modules. That's something, right?

Perl is dead on Linux, though. And on the other platforms it was never even alive.

People like to be fanboys and argue about shit like that. See: Windows vs. Linux, Firefox vs. Chrome, GNOME vs. KDE, VIM vs. Emacs, GPL vs. BSD, systemd vs. sysvinit. They're all tools, people. You don't see people arguing screwdriver vs. drill, do you?

#include
#include

int main(int argc, char *argv[])
{
if (argc != 2)
return 1;

int n = atoi(argv[1]);

while (n--)
printf("\u2721");
putchar('\n');
}

>owning a drill

>int main
>char *argv[]

That is the proper type signature for main in C.

does char *argv[] make a copy of the cli args
does char **argv point to the actual cli args?

>You don't see people arguing screwdriver vs. drill, do you?
Those do different things. More apt comparison would be people arguing about screw drives.

[] is just syntatic sugar for * afaik

In C, they are both exactly equivalent, and are valid to put as main's second argument.
The first just seems a littler for "obvious", as it's an array of char pointers.

>a littler for "obvious"
Jesus, I really need to read my own shit before I post, especially after I change a sentence. That didn't come out right at all.
a little more obvious*

>compiler for compressor's language isn't compiling
>normies just use nomachine to connect to the linux machine on campus that has it installed and working
>i have linux on my computer and nomachine doesn't work on it
cs.ecu.edu/karl/cinnameg/8-2/lin/Misc/get.html
this is it if you want to try and tell me how to do it. i ran into a couple blocks that i managed to get past by untar'ing it into a directory in my home directory, then doing the configure, and then touching t_parser.c before sudo make install. also i had to create some directory for make install when it gave an error for the directory not existing. i have to run make install as sudo because otherwise it tells me i don't have permission and has an error because of it.

past all that now, and it does literally thousands of make commands for like idk how long, and then tells me there was an error. i didn't note down the error and i dont want to do it again because it took ages and i couldn't barely use my computer while it was doing all of them

please send help

Proper type sig is
int main(int argc, char *argv[argc])

Stupid frogposter

*compiler for professor's language isn't compiling

do it yourself you lazy cunt

>not
>int
>main(int ac, char **av)

pls

>char *argv[argc]
It would be argc + 1 though, since argv[argc] is guaranteed to be the null pointer. You also missed the opportunity to use 'static' there.
However, that is not what the standard states, so it's not important.

>not
>public static void main(String[] args)
wew

>while "subtract 1 from n", print some character
>add a line break

What kind of nigger bullshit is this? First of all, planning for a variable to overflow to end a loop is the programming equivalent of crashing a plane into a car to make the car stop. Secondly, this just prints a string of stars of David. You are asked to draw a star of David.

Nice code camp skills.

>Not main(argc, argv)
char *argv[];
{
}

Please

why are you declaring argv between the function constructor and its definition? Does that even compile?

>planning for a variable to overflow to end a loop is the programming equivalent of crashing a plane into a car to make the car stop
n being greater than or equal to zero is a precondition of my program.

Yes, but you subtract 1 every iteration, and the loop ends when subtracting 1 doesn't work anymore because it reached 0.

You're counting on the fact that your exception will be handled as a simple "false", but it's an exception. Just because it works doesn't mean it's not stupid.

>not int
main(int c, char **v)
{
code here
}

pls

>code here
nice job fag lmao, that's not even going to compile haha I win

publicstaticvoidmainstringargs

>Does that even compile?
Yes. Although I forgot to put the return 0 in the function body.
It's the old style function declaration, as well as implicit int.

>when subtracting 1 doesn't work anymore
int is signed, you know.
>You're counting on the fact that your exception will be handled as a simple "false", but it's an exception.
What are you even talking about? n is guaranteed to be zero at some point, and when that happens, the loop will fail.
After the loop finished, n will be -1.

>not global int c; global char *v[];
int main(int argc, char *argv[])
{
c = argc;
v = argv;
actual_main();
}
actual_main()
{
code
}

global is not a keyword in C.

If n is signed, then why would the loop fail? As long as the subtraction wields the expected result, the expression is true.

Finally started to learn Go. And damn, what a fun and sexy language. I can't wait to start a few pet projects with it. All the hate towards Google kept me off it for so long. What a waste.

Nice try b8er.

In C, zero is false, and non-zero is true.
When n reaches zero, the loop will terminate.

while(n--) does not evaluate n, it evaluates the expression n--

n-- evaluates to n, with the side-effect of decrementing n.

Alright faggot

Time to deliver

well that's fucking retarded

Do you seriously not know any C-like languages?

This is what happens when you people keep pushing the haskell meme.

i started playing with it today. it's fun but i'm not sure why
what are you going to write?

he means it's fucking retarded to do it like that instead of just using a for loop, which it is

nice trips btw

>a countdown while loop is now "fucking retarded"
Also uses one less variable.

>he means
Sure you do buddy.

why would you not just use a for loop like everyone else?

nice dubs btw

You watched the debate, right?

Trump was destroyed for 75% of that debate.

No, it's retarded that the expression is not what is evaluated for the loop.

while(n--) should equate while(n = n - 1)

Otherwise it's a very arbitrary shortcut and it just gives pajeets opportunities to make their code confusing.

What does while(n-- && m--) evaluate? n * m? Come on!

Also, not

Why don't more languages support swap syntax like Python?

Why introduce another variable for absolutely no reason?
I'm not using n to index anything or need its original value later.

The only real problem with my code is that it doesn't handle negative numbers.

How about just putting n-- inside the loop, where the subtraction is actually occurring.

>why make your code easy to read?

what for?

It's not confusing or hard to read if you use C at all.

Where are you getting this "another variable" from?
for (n = atoi(argv[1]); n > 0; n--) doesn't need any other variables.

>Otherwise it's a very arbitrary shortcut
Yes, that's the whole point of the prefix/postfix increment/decrement operators.

>What does while(n-- && m--) evaluate? n * m? Come on!
0 if either n or m is zero, 1 otherwise. There is also the side effect of decrementing n, and decrementing m is n is non-zero.

>where the subtraction is actually occurring
The subtraction IS actually occurring. Any expression is allowed to have side effects in C (and most non purely function languages).

I'll probably use it on the backend of a new web project.

>why should I write my program on separate lines, it's not hard to just read between the semicolons!

What do you mean swap syntax?

It's a simple decrement in a while loop.

New thread:
Trips and no traps edition.

>why can't these plebs understand my poorly written code? why must my intellect be so superior?

I believe this would do it.

#!/bin/bash

for image in "$@" ; do
while true ; do
timestamp="$(shuf -i 1400000000000-1469999999999 -n 1)"
extension=${image##*.}
filename="$timestamp.$extension"
[[ ! -f "filename" ]] && break
done
mv "$image" "$filename"
done

Chi-chan is not autistic, you dumbshit.

>[[ ! -f "filename" ]]
>"filename"

>while(n--) should equate while(n = n - 1)
It does
n = n - 1 also returns n

Beautiful

Assburgers at least.

Maybe some crazy person has their images named like "image. _ jpeg"

Better safe than sorry.

What is $@?

All arguments. In a bash script "$1" and "$2" would be the first and second arguments respectively.

So if you ran a script like

./script.sh arg1 arg2

Then "$1" would be arg1, and "$2" would be arg2.

If you use "$@" that means ALL arguments. So if you ran

./script.sh arg1 arg2 arg3 arg4 ...

It would collect all arguments into $@. for x in "$@" is a way to loop through all of them.

I see, thanks.

Woops, just realized there was no $

Holy shit I'm stupid.