[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 | Free Show | Home]

/dpt/ - 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: 321
Thread images: 30

File: 1490554756635.gif (385KB, 500x281px) Image search: [Google]
1490554756635.gif
385KB, 500x281px
What are you snoozing on, /g/?

Old thread: >>59600079
>>
File: logocaml.gif (5KB, 375x352px) Image search: [Google]
logocaml.gif
5KB, 375x352px
>>59610823
First for OCaml
>>
reimplementing rust in haskell
>>
>>59610823
Ps3 emulator
>>
File: 1489784838538.gif (2MB, 350x545px) Image search: [Google]
1489784838538.gif
2MB, 350x545px
i worked on my language

i still need to make some sort of a generic syscall before i can really implement IO and a memory allocator - if anybody has a quick tutorial on how the syscall thing is done in the easiest way possible, so i don't have to search, feel free to post, but it's ok even if you didn't

i'lll find it

have a qt afro american pornstar to motivate your coding
>>
>>59610790
>>59610816
>>59610820
Could have resolved the problem more gracefully if I had another week.
Got all the way from lexing to generating LLVM in a few weeks for a dynamically typed language that hadn't even been fully designed yet.
>>
implementing haskell in javascript
>>
@#59610894
>3d
awful
>>
>>59610850
Rewriting GHC in rust
>>
>>59610923
impossible
>>
On what platform are you handling syscalls in your language?
>>
>>59610895
>he used LLVM
>he didn't compile str8 to assembly
brainlet you will never make it
>>
File: fantastic2.png (105KB, 638x1108px) Image search: [Google]
fantastic2.png
105KB, 638x1108px
PHP+MySQL name voting thing is working. Now the main problem is that there are 6466 names to vote on, and that's just way too many for me+a couple skype friends to handle. I guess I should look into cheap hosting and put it up online.
>>

module deduplicate_string_array;

//re creating the array without duplicate values
//updates the array, returns void
void deduplicate_string_array(ref string[] elements)
{
for (int i = 0; i < elements.length; i++)
{
for (int j = i+1; j <= elements.length - 1; j++)
{
if (elements[i] == elements[j])
{
elements = elements[0 .. j] ~ elements[j + 1 .. $];
}
}
}
}
>>
>>59610939
i assume this is directed at me
i use linux and have been thinking about an easy way of making a generic syscall

the issue is that in linux syscalls use registers and not just put function parameters on the stack when you do a 0x80 interrupt, so it almost feels like i need to sit down and write assembly, but i haven't done much research yet
the language doesn't touch the heap yet, because no brk

either way even if i left the lang alone, i'd be able to work on it in the future it has some degree of completeness, just doesn't touch the heap lol
>>
>>59610956
what happens if two people upboat at the same time?
>>
>>59610941
>generating 1:1 target dependent code
You have to know register coloring which we never didn't have time to cover
>>
>>59610993
That's a good question. I haven't considered race conditions. My MySQL skills are very basic.
>>
Do compiler optimize the target code or the user code? Or an intermediate?
>>
>>59610983
>the issue is that in linux syscalls use registers
Windows sys calls use registers aswell.
I don't know how to make a language but what if you specified the syscalls for each os and architecture?
>>
>>59611017
shit, that's actually something that requires learning
i just did a 'I'm all over the stack approach and push and pop a lot'
>>
>>59611039
It optimized an intermediate representation
>>
>>59611053
>what if you specified the syscalls for each os and architecture?
oh no, this is only for linux

it's supposed to be easy and for learning purposes
>>
>>59611018
well, what's your schema?
>>
>>59611053
probably stay inside of posix standards, but that's not always perfect either
>>
File: 1489612835461.jpg (139KB, 850x923px) Image search: [Google]
1489612835461.jpg
139KB, 850x923px
Is division still considered as a slow-downer in the code or it's not important nowadays?
>>
>>59611116
If you don't need a float, just do repeated subtraction instead.
>>
>>59611116
Sure, but there are usually more pressing issues to worry about, such as memory access.
>>
>>59611059
You probably don't get to learn that unless you focus on languages in a phd program. For everyone else, intermediate languages are the way
>>
>>59610983
>i assume this is directed at me
Yes, I forgot to add a quote/backlink.

>i use linux and have been thinking about an easy way of making a generic syscall
Are you aware that on Linux, syscall() is also a function?
http://man7.org/linux/man-pages/man2/syscall.2.html

>the language doesn't touch the heap yet, because no brk
Just link against libc. You'll get brk() for free.
>>
C is a fine intermediate language
Is there really any reason to use LLVM instead?
>>
File: 9e0.jpg (18KB, 300x233px) Image search: [Google]
9e0.jpg
18KB, 300x233px
>>59611213
The purpose of intemediate language is to be easily parseable. Such language is usually bytecode.
C is not a fine intermediate language.
>>
File: nm.jpg (75KB, 927x1280px) Image search: [Google]
nm.jpg
75KB, 927x1280px
>>59611022
these sluts are starting to grow on me a little
i like to stare at them especially irl, i like to stare like a creep
though black girls around here are different than in america
>>59611144
well i made use of a simple intermediate language that looks like python lists, since i wrote the compile in python

anyway i think i'll move to a differnet project and worry about heap and syscalls and memory at a later point
>>59611174
yes i'm now aware and i did some quick reading and you can actually implement a generic syscall, but i am not very clever and will need to try it out first, how it works in C exactly, maybe look at the assembly and get ideas
i don't want to link against libc, for no logical reason
>>59611213
>compiling to c
doesn't that make things too easy? but it probably works VERY well in practice
#["while", ["<", "i", "100"],
# ["begin",
# ["if", ["and", ["==", ["%", "i", "5"], "0"], ["==", ["%", #"i", "3"], "0"]],
# ["print", "fizzbuzz", "16"],
# ["if", ["==", ["%", "i", "5"], "0"],
# ["print", "buzz", "8"],
# ["if", ["==", ["%", "i", "3"], "0"],
# ["print", "fizz", "8"],
# ["print_num", "i"]]]],
# ["=", "i", ["+", "i", "1"]]]])
>>
How much time is spent debugging and fixing errors?
>>
>>59611393
Depends on almost everything
>>
>>59611258
for (var i = 1; i <= 100; i++) 
{
if (i/3 % 1 == 0)
{
document.write("Fizz") + document.write("<br />");
}
else if (i/5 % 1 == 0)
{
document.write("Buzz") + document.write("<br />");
}
else {
document.write(i + "<br />");
}
}


Javascript master race :^)
>>
>>59611258
>these sluts are starting to grow on me a little

They are perfect in every way.

>i like to stare at them especially irl, i like to stare like a creep

Me too, but I'm sure they can tell I'm autistic.
>>
>>59611403
>i + "<br />"
>Integer + string
How to dynamic shitters defend this?
>>
>>59611053

>Windows sys calls
Windows syscalls should ONLY be done as calls into kernel32.dll functions, as the syscall number for any given syscall on Windows can be subject to change between different versions of Windows, or even between different service packs. There is zero guarantee of any consistency in the ordering of the syscall numbers.

>>59611213

1. Less time spent parsing C. It's silly to compile into one intermediate format that will only need to AGAIN be needed to be compiled into an intermediate format.

2. Ability to use intrinsics that might map to certain instructions that C compilers won't necessarily emit.

>>59611258

>how it works in C exactly, maybe look at the assembly and get ideas
A C compiler is not going to emit the syscall instruction at all, unless it is built on a platform where it is forced to. Functions like write(), read(), brk(), and such are all going to be in the libc library on POSIX systems. Those functions are then going to call a function called syscall(), which will ACTUALLY invoke the syscall instruction, and the kernel does the rest.
>>
>>59611255
in practice C code runs very close the machine and is very portable.
While LLVM might be proper, it would still work pretty well.
Also C doesn't even have a proper parser in the traditional sense since it was designed before most of that.
>>59611258
Is this your AST?
Why do you need an intermediate language for it?
>>
>>59611419
>1. Less time spent parsing C. It's silly to compile into one intermediate format that will only need to AGAIN be needed to be compiled into an intermediate format.
>2. Ability to use intrinsics that might map to certain instructions that C compilers won't necessarily emit.
fair enough
>>
>>59611419
>A C compiler is not going to emit the syscall instruction at all, unless it is built on a platform where it is forced to. Functions like write(), read(), brk(), and such are all going to be in the libc library on POSIX systems. Those functions are then going to call a function called syscall(), which will ACTUALLY invoke the syscall instruction, and the kernel does the rest.
oh i see then i will think about linking against libc and then just writing an allocator after i have brk, though i will have to read for that too because i don't exactly remember how that worked - the details
>>59611422
the real language looks almost exactly like the 'intermediate', but it's more convenient to write in
i posted in last thread
@(function fizz_buzz () ((str fizzbuzz "fizzbuzz\n") (str fizz "fizz\n") (str buzz "buzz\n") i)
(while (< i 100)
(begin
(if (and (== (% i 5) 0) (== (% i 3) 0))
(print fizzbuzz 16)
(if (== (% i 5) 0)
(print buzz 8)
(if (== (% i 3) 0)
(print fizz 8)
(print_num i))))
(= i (+ i 1)))))
>>
>>59611416
They don't need to, because they're busy getting things done instead of bickering over types.
>>
>>59611419
Windows syscalls should ONLY be done as calls into kernel32.dll functions, as the syscall number for any given syscall on Windows can be subject to change between different versions of Windows, or even between different service packs. There is zero guarantee of any consistency in the ordering of the syscall numbers.
Thanks from now on this will improve my advancements on learning asm.
>>
File: 1488075576624.jpg (286KB, 850x1259px) Image search: [Google]
1488075576624.jpg
286KB, 850x1259px
>>59611502
What do i need to crack an android app?
>>
>>59611547
Lucky Patcher?
>>
>>59611547
Brains
>>
opening for an embedded controller programmer nearby. I think its for like forklifts and shit

what am I in for bros? I'm guessing C?
>>
for (var n = 1; n <= 100; n++) {
var output = "";
if (n % 3 == 0)
output += "Fizz";
if (n % 5 == 0)
output += "Buzz";
console.log(output || n);
}
>>
>>59611612
>I'm guessing C?
probably something earlier
>>
>>59611715
yeah hopefully the fuck not because I'm not going back in time any further than C
>>
There's an API for finding information on books that I use by creating an HTML script tag which includes the ISBN in a certain way, which then sends an object to a Javascript function as an argument if the book is known.

The problem is though that I need to somehow have the ISBN passed to the function as a second argument, because if the book is not known, the function needs to know which book it was run for so it can do what it does if book information is missing.

The script tag src looks like this:
'https://openlibrary.org/api/books?bibkeys='+books[i].id+'&callback=bookInfo&jscmd=data'

Is there a way I can modify this src so that it sends a second argument to the function "bookInfo"? The argument must be books[i].id
>>
File: telegraph-machine.jpg (58KB, 1000x655px) Image search: [Google]
telegraph-machine.jpg
58KB, 1000x655px
>>59611744
something like this probably
>>
So I took the windows-pill a few months ago, and I can see the appeal.

I've been messing around with the Win32 api, which is total shit but I learned it faster than any other api so far. The reason for this is because of just how well it is documented. Linux NEETs need to learn how to document better before complaining about their small market share
>>
>>59611848
what they really need is preinstalls
>>
>>59611848
>Linux NEETs need to learn how to document better
What? The POSIX C API has excellent documentation.
>>
>>59611492
Will you post the source?
>>
File: oss.png (134KB, 613x507px) Image search: [Google]
oss.png
134KB, 613x507px
>>59611848
>>
>>59611213
>C is a fine intermediate language
C is a fine beginner language
>>
Haskell is a good beginner language
Idris is a good intermediate language
ATS is a good advanced language
>>
>>59611917
Sounds like a very angry manlet. Is that your blog?
>>
>>59611998
And they're all trash to boot!
>>
>>59611547
source?
>>
>>59611986
intermediate from user to target language
>>
Making a dumb little gui that has a picture on it with window forms.
It won't resize when the window does
>>
>>59611998
Haskell is a good beginner language
Haskell is a good intermediate language
Haskell is a good advanced language

What we learned here is that Haskell is the best language for anyone, period.
>>
>>59612028
t. OOP programmer
>>
>>59612077
t. brainlet
>>
>>59612096
t. hated his Haskell classes
>>
>>59612103
Haskell typeclasses are indeed worthy of hate.
>>
>>59612120
You seem to be an incoherent sort of person.
>>
>only ebook lunk is a usenet one
fuck i really need to join a private tracker.
>>
>>59612165
I'm about as coherent as Haskell's syntax.
>>
Do you guys hate github? I don't like that I need to download their thing to upload some code onto their site
>>
>>59610823
Sup /dpt/
>starting from the bottom beginner here
where should i start to be the wizard?
I don't have any previous knowledge of what programming it's, but i have a concept
so guises feel free of helping me out
>>
>>59612218
github is not related to git
>>
>>59612218
what is git
>>
>>59611917
How is the first supposed to be a bad thing? Most closed-source software that isn't by a big name company ends up like that. At least it being open source means YOU can look into the bugs and fix them yourself, which simply isn't an option with closed-source.
>>
>>59611848
Windows is documented shitty as fuck, it's just easy. Coding some angular site with a .net core backend for a customer and this windows shit is boring as hell
>>
>>59612255
i've been falling for opensource meme for quite some time. then i looked at world practices and was like fuck it, fuck open source. the users can only be free under my control. this is how its gonna be. everyone is building their botnet, i am building mine. normies deserve to get fucked.
>>
>>59612275
>.net

that's too bad
>>
resources on program correctness?
>>
>>59612500
git gud
>>
thoughts on recursion?

long rec ( int n, int r )
{
if (n < r) return 0;
else if (r == 0) return 1;
else return rec(n-1,r-1) + rec(n-1,r);
}
>>
File: timerwtf.png (27KB, 728x466px) Image search: [Google]
timerwtf.png
27KB, 728x466px
my timer keeps doing these spikes and I don't know why.
>>
>>59612593
See >>59612593
>>
>/g/ is still comparing their fizzbuzz e-penis
why

>>59612593
Inefficient as fuck
>>
>>59612600
error in nanoseconds btw. i is incremented every 10ms.
>>
>>59612593
better use a loop
>>
I made this:
http://codereview.stackexchange.com/questions/159056/find-all-distinct-8x8-chessboards-where-5-queens-attack-occupy-every-square

I was inspired by this:
>>59601324

Please help to improve
>>
>>59612600
1) floating point?
2) overflow?
3) you're an idiot?
One of these
>>
>>59612632
1) std::uint64_t
2) see 1
3) possibly
>>
>>59612637
No one knows what error is, btw
>>
>>59612659
auto i = 0;
auto t = clock::now();
while (true)
{
t += 10ms;
thread::yield_until(t);
auto now = clock::now();
std::cout << "i=" << i++ << ",\terror=" << (now - t).count() << '\n';
}

it's in nanoseconds.
>>
File: 1487974409142.jpg (79KB, 640x640px) Image search: [Google]
1487974409142.jpg
79KB, 640x640px
The virtual address space allows for 4 billion goroutines with 4 billion bytes each of stack. The MMU can map and remap that to physical memory on demand through the address translation tables.

Moving stacks is a great solution for 1995 computers.
>>
>>59612683
OS Scheduling
>>
File: wheres her eye.png (185KB, 636x405px) Image search: [Google]
wheres her eye.png
185KB, 636x405px
>>59612528

the lecture notes my prof gave me isn't formal enough, they sound hand wavy to me. Please brothers.
>>
>>59612500
Effective C++
>>
>>59612609
>>59612626
in this case yes but when is recursion better than a loop/something else?
>>
File: timerwtf.png (39KB, 760x841px) Image search: [Google]
timerwtf.png
39KB, 760x841px
>>59612730
if you mean thread::yield_until, that's my own scheduling and there are no other threads, so it's more or less an expensive no-op.
windows scheduling, possibly.
I think it's in my timer code somewhere though since the interval between spikes keeps getting longer until they eventually disappear.
>>
>>59612782
When the solution is more elegant with it, assuming you have the space to do it.
>>
>>59612782
A recursive problem demands a recursive solution
>>
>>59612747
Post notes.
>>
>>59612782
When a loop can't do it.

A loop is always better
>>
>>59612747
Does a program do what it claims to do (satisfy its post-condition) given its precondition is met?
It's partially correct.
Is it also guaranteed to halt?
It's totally correct.
>>
>>59612500
building high integrity applications with spark
>>
>>59612885
*building dynamic web applications with React and Agile
>>
File: download_2.jpg (8KB, 206x156px) Image search: [Google]
download_2.jpg
8KB, 206x156px
>>59612893
>>
>>59612629
Anyone?
>>
>>59612835
>>59612852
any examples of a problem like that?
>>
File: formally understand this.png (97KB, 1457x817px) Image search: [Google]
formally understand this.png
97KB, 1457x817px
>>59612863

that is not enough to formalise multiplication.

or is that all there is to "program correctness"?? just some vague concept?
>>
>>59612981
Trees in their various shapes and sizes. They come up in a lot of places (e.g. file hierarchies, HTML DOM, syntax trees)
>>
>>59612782
A loop is useful when each step of a computation produces one or zero subsequent steps. It doesn't work so well when it produces two or more steps and you have to execute them all. For example, a loop works fine for searching a balanced binary tree, but if you have to traverse the entire tree, you should use recursion.
>>
>>59613047
What does it mean to "formalize multiplication"?
The definition of multiplication (in terms of peano axioms) is very straightforward. Implementation follows directly from that definition.
Loops with invariants is the same thing as recursion with constraints
>>
>>59613086
def iteratetree(root, process):
s = [root]
while s:
n = s.pop()
process(n)
for c in n.children:
s.append(c)

No recursion required.
>>
test
>>
>>59613183
Good work, anon. Not many programmers can figure out how to do that.

Recursion is very dangerous, like a runaway nuclear reactor. The best programming languages don't allow recursion. They never overflow the stack because they know how much stack space they need at compile time.
>>
>>59612981
https://mitpress.mit.edu/sicp/chapter1/node15.html

Here's an example of recursion. As an exercise, try to think of a way to do this using a for or while loop
>>
Why do you use a Turing-complete language for everything, when most of the time you don't need all that power?
>>
>>59613286
>not using a dependent language in which you can do both
>>
>>59613286
t. programlet
>>
>>59613311
Who are you quoting?
>>
>>59612852
>A loop is always better
"Better" how? In languages where local recursion comes for natural, many problems let themselves be described more naturally in recursive terms.

For instance, in Scheme, it's quite natural to express simple iteration in terms of recursion:
(let next ((i 0))
(print i)
(if (< i 10)
(next (+ i 1))))
>>
>>59612500
>>59612885
Developing Safety Systems: A guide using Ada
>>
>>59613357
>I'm not quoting anybody.
So why did you write a quotation?
>>
>>59613286
>Good work, anon. Not many programmers can figure out how to do that.
What? It's an extremely simple algorithm. Not to be elitist, but if you can't even read that naturally, you probably shouldn't be projecting your competence onto others.
>>
>>59613369
Who are you quoting?
>>
>>59613286
>The best programming languages don't allow recursion.
... Like FORTRAN?
>>
>>59613363
>"Better" how?
Recursive thinking is unnatural and very difficult. Humans normally think in terms of iterative steps. Maybe if you're a mathematician, recursion is easier. Everyone else prefers loops.
>>
>>59613391
I'm quoting your post at >>59613357.
>>
>>59611848

I have never had any problems with POSIX documentation. I have found MSDN lacking on a number of things, however.
>>
>>59613412
There is no such post
>>
>>59613410
>Humans normally think in terms of iterative steps.
Imperative programmers do that. If your mind isn't molded from years of imperative programming, it's often far more natural to think in recursive terms.
>>
File: quoted-post.png (8KB, 410x83px) Image search: [Google]
quoted-post.png
8KB, 410x83px
>>59613423
There was, until you deleted it. Chances are it still exists in an archive somewhere.
>>
File: consider-suicide-2.jpg (21KB, 460x276px) Image search: [Google]
consider-suicide-2.jpg
21KB, 460x276px
>>59613391
>thinking gt-signs are reserved for citations
>>
>>59613438
Imperative programming is the dominant paradigm for a reason.
>>
>>59613410
>Recursive thinking is unnatural and very difficult
>t. turbo brainlet
>>
>>59613454
Who are you quoting?
>>
>>59613456
Yes, the fact that CPUs are imperative. Not because it's easier on the mind.
>>
Can you recurse a main function?
>>
>>59613452
proof
>>
File: consider-suicide-3.jpg (28KB, 640x730px) Image search: [Google]
consider-suicide-3.jpg
28KB, 640x730px
>>59613463
Noone. You may have noticed that was the entire point.
>>
>>59613474
In practice yes, but I believe the C standard special-cases the main function such that compilers aren't required to support calling it.
>>
>>59613476
https://archived.moe/g/thread/59610823/#59613357
>>
>>59613463
If you're going to go around being pedantic, you should at least use "whom" properly.
>>
>>59613504
"Who" is perfectly acceptable in modern-day English.
>>
>>59613492
you got me
>>
>>59613504
Whom are you?
>>
>>59613512
Just like using >-syntax without exact quotes is perfectly acceptable in modern-day 4chan use.
>>
Pretty good talk: https://www.youtube.com/watch?v=A-lmrvsUi2Y
>>
>>59613549
Whom quotest thou?
>>
Daily reminder that if you don't use Rust then you are enabling the CIA and other three letter organizations to exploit your software.
>>
>>59613572
This
>>
>>59613572
Even if I'm using Haskell or Idris instead?
>>
>>59613286

>Recursion is very dangerous
Non-tail recursion is dangerous. Tail recursion is optimized out by the compiler. That said, if you can fit an upper bound, non-tail recursion can still have a use for things like backtracking (if you can't fit an upper bound, a heap-based stack may perform a little slower, but will do the trick).

>>59613299

Every decent language for making programs is Turing complete. And for what it's worth, pretty much all of the time you do need that power. The criterion for being Turing complete are pretty damn simple. If you can do a loop with a conditional, store elements in memory, perform some sort of output and receive some sort of input, you could probably create a Turing machine. And if you don't have these features, you've pretty much got yourself a hunk of flaming garbage.
>>
>>59613589
>If you can do a loop with a conditional, store elements in memory, perform some sort of output and receive some sort of input
I often don't need all of those things.
>>
>>59613583
Those are fine
>>
>>59613572

Modern idiomatic C++ can be used just fine for developing secure software. You don't need Rust.

>>59613605

What kind of software do you develop? Even a simple CRUD application requires all of those.
>>
>>59613610
What about Common Lisp or R7RS-small.

Also, Ada-2012
>>
>>59613629
>Modern idiomatic C++
I keep hearing this non existent meme but the fact of the matter is C++ will always be just as unsafe because of legacy code compatibilities, specially due to C source level compatibilities. What you got now is _one more_ set of doing the same thing. Furthermore no books teach the so called modern C++ to a newcomer, who are more likely to produce vulnerabilities

C++ is beyond saving. https://news.ycombinator.com/item?id=7587978
>>
>>59613641
Anything but C
>>
>>59613672
>set of methods* for*
>>
>>59613629
I'm often writing scripts in some embedded DSL that do some work and then finish. They don't need to do IO (they're effectively pure functions working on finite inputs), they don't need to loop. With a sufficiently advanced type system/compiler they could be proven to terminate, so a total language could be used, and a total language is not Turing-complete.

Sure, the interpreter for them probably needs to be written in a Turing-complete language, but the scripts themselves don't.
>>
>>59613694
Clarification: when I say they don't need to loop, I mean they don't need general recursion.
>>
>>59613557
pretty annoying it takes an hour to watch an hour long talk
>>
>>59613572
>Rust has no exploits
Lmao. Just because they aren't discovered, doesn't mean they don't exist.
>>
>>59613672

>specially due to C source level compatibilities
When I say "idiomatic" I mean "not writing C++ like it's C with classes". Just because you can throw raw pointers around everywhere doesn't mean you should. You can do the same shit C allows in Rust too, but that requires an unsafe block. C++ just assumes that you know what you're doing and that it shouldn't hold your hand.

>Furthermore no books teach the so called modern C++ to a newcomer
Who said anything about newcomers? I'm not one, and you're the one trying to sell Rust onto me...

>>59613694

>They don't need to do IO
Allow me to provide you with an equivalent C program to do all of your work from now on:
int main(void)
{
return 0;
}
>>
>>59613758
Click the gear in the bottom right of the player, you can speed it up.
>>
>>59613764
I'm not selling you anything and I clearly mentioned why I said newcomers, dumb tripfag
>>
>>59613764
>Allow me to provide you with an equivalent C program to do all of your work from now on:
Dude, where's my return value?

I realize that the thing running the scripts needs to do IO. That doesn't mean that the scripts need to be able to do IO too.
>>
>>59613764
You should stop using unsafe C++ and C and start using a proper language like Rust, or are you a CIA shill?
>>
>>59610823
Took a look at the blender source code to see if I could figure out how it can UV unwrap an arbitrary mesh so I could do something similar. Turns out I have no idea how to go about understanding a project of that scale.
>>
>>59613794
>where's my return value
That is a form of I/O.
>>
>>59613891
I'm talking about the B in A => B, which Ruby so cruelly discarded.
>>
>>59613794

>Dude where's my return value
Where's your input? If you have no input, whether it be command line arguments, files, standard in, network traffic, whatever... your program is equivalent to returning a constant. You might as well punch the numbers into a calculator.

>>59613806

I'm a programmer and I don't like people telling me what to do. Rust has its merits, but what benefits it offers can just as easily be performed using the safe features of other languages. C++ has RAII, it has references, it has move semantics, it has a standard library with decent container types (unique_ptr and shared_ptr do the job of Rust's box types)... and if necessary, it can call into C libraries without much of a wrapper, because of the header compatibility. That last part makes it a hell of a lot more flexible. Why would I ever stop using it?

>>59613913

Input A
Do computation
Output B
>>
>>59613948
ruby are you a boi
>>
>>59613948
>Why would I ever stop using it?
Because C++ is objectively a poorly designed language.
>>
>>59613948
Like I said, the scripts are effectively pure functions, they transform (finite) inputs into (finite) outputs. The output varies with the input. Whatever is running the scripts supplies the input and does things with the output. That's none of the scripts' concern, they don't need to know about it.

>Input A
>Do computation
>Output B
This does not imply doing IO.
>>
>>59613948
>being this much of a CIA shill
You just want to infect people's minds that C++ is an acceptable language (hint: it's not) and they should risk using an unsafe language because you think that C++ has any benefits over Rust.
>>
>>59613953

I am a 25 year old MAN.

>>59613977

But the program is the script plus whatever is controlling the script. A function on its own, which receives no input, and produces no output, is not a program.
>>
File: 1485262515835.jpg (76KB, 1065x859px) Image search: [Google]
1485262515835.jpg
76KB, 1065x859px
>>59613977
>My program doesn't do I/O, if I just change what the definition of I/O is to suit me
>>
>>59613992
but are you cute???
pls post boipucci so i can verify thanks
>>
>>59612225
Unironically learn C. C is a good starting point as it is, in laymens terms, a step above assembly. It's used everywhere and can be utilized for low level (think embedded processors, microwaves, thermostats) and high level (games, user level applications). You can basically branch off to any language after learning C, including C++, java, python or any other shitty memelang of the month. C Primer 5th edition is a very good starting point if you want to start learning programming in general.
>>
>>59613978

>Everyone who has an opinion different than mine is a shill
You know, Anon, I'd sure love to be on the CIA's payroll, getting some nice healthcare benefits and a great retirement plan in exchange for shilling "unsafe" systems programming languages on a forum only used by Haskell programmers that aren't going anywhere in life. Unfortunately, the job position isn't available, to my knowledge. Furthermore, I've actually attended a CIA recruitment event at my university. I came to the conclusion that despite the many possible benefits, I simply cannot see myself working for an employer that believes that a method as un-scientific as a polygraph test can be used as a legitimate means of being able to determine a candidate's trustworthiness. Not only is it possible to fool a polygraph test if you are a psychopath, but it is easy for people to fail a polygraph test just for being nervous, even if they are telling the complete and honest truth. It is complete pseudoscience, and I refuse to work for any employer who makes use of it.

>>59614068

>But are you cute
Imagine a skinny-fat Richard Stallman with less years on him. No, I'm not attractive.
>>
>>59612225
Don't listen to this CIA shill >>59614103
Learn Rust, it's memory safe, has better high level abstractions than C and is comfy.
>>
>>59612593
Is my knowledge failing me, or is that the Ackermann function?

And if so, kek@
>>59612626
>>59612609
>>
>>59614142
my peepee is HARD ruby
>>
>>59614146

Not quite.

https://en.wikipedia.org/wiki/Ackermann_function
>>
>>59612225
>>59614103
>>59614144
Whenever I see questions and answers on the topic of "where to begin", I feel a strong Dunning–Kruger effect. I mean, a few years ago I would be able to answer a question like that on the spot and give the poor fellow some tl;dr advice, but now I'm like: "This is more complicated than whatever I could write. Just go to a college dude"
>>
>>59614193
Ruby, you're in grad school right?

I'm almost done with my bachelor's in CS and I never considered grad school until very recently, and I'd like to get my masters in CS and possibly pursue a doctorate in the far future.

If someone has a high GPA but absolutely zero research experience, can they still make it into a good master's program?

Is it even possible to get into a good CS phd program without undergraduate research?
>>
>>59614234
because as you learn more you realize all the shit you're not telling them. Simplify that garbage and get the basics to them.
>>
>>59614146
>>59614193
Holy shit, all it calculates is
res = a < b ? 0 : a;
>>
>>59614272
Damn I'm retarded, it's choose(n, k).
>>
>>59614253

I got into my master's program with zero undergraduate research experience. It helps to have good GRE scores and letters of recommendation. With regards to doctoral programs... I haven't heard back from most of the universities I've applied to (although I've been talking with one of the professors at WSU, so I'm keeping my fingers crossed here), but I would presume that research in one's master's program would make up for a lack of undergraduate research.
>>
File: AESTHETIC.png (29KB, 651x155px) Image search: [Google]
AESTHETIC.png
29KB, 651x155px
>he uses syntax highlighting
>>
C++ has a bool type. It is the most idiotic boolean type you will ever see. Firstly, you can use any integral type in a place where you need a boolean value. This leads of course to programming errors like if (i = 2). But if you actually decide to use the bool type, you run into funny stuff, for example: An uninitialized bool variable may be neither true nor false - depending on your compiler, if you define bool a;, both a and !a may evaluate to true.
Functions that don't have void as return type are not required to return a value. Seriously? This just screams for bugs if someone somewhere forgets to write return result; and the compiler doesn't remind him.

C++ BTFO use D
>>
>>59614337

>and then
https://www.youtube.com/watch?v=GKNX6dieVcc
>>
>>59614343
>Functions that don't have void as return type are not required to return a value.
Not even C has this problem
>>
>>59614321
That gives me hope, thanks.
>>
>>59614337
> :=
What other language uses that god-awful thing?
>>
>>59614343
>use D
Why would I be using OOP trash?
>>
>>59614392
Don't you have to be over 18 to post here?
>>
>>59614392
My language. It makes more sense in this context.
>>
>>59614393
Why were you using C++ in the first place?
>>
Learn elixir right now,
what a language man, expressions are actually data types combined, all expressions can be broken into tokens like a built-in language parser, you can create everything with the built in data types and functions
you faggots should try
>>
>>59610823
how can I force gcc to use push instead of mov?

using -mno-accumulate-outgoing-args when compiling but still have mov everywhere(when passing parameters).
>>
>>59614405
It's pretty clear that I wasn't.
>>
>>59614398
i literally just asked a question.
>>
>>59614424
It's pretty clear I was talking to C++ users.
>>
>>59614343
>Functions that don't have void as return type are not required to return a value.
Wrong. Functions that don't have void as return type ARE required to return a value. The value they return just isn't required to be manually populated.
>>
>>59614434
Why would you recommend them to use OOP garbage?
>>
>>59614421
gcc generates garbage code often. Some speculate there are serious logic bugs in many of the optimization routines. Have you looked at the output with clang?
>>
>>59614443
Because they are OOP users
>>
>>59614445
I've just called gcc -S -mno-accumulate-outgoing-args example.s example.c

Looked at the assembly and it's identical to using -o

void function (int a, int b, int c){
char buffer1[5];
char buffer2[10];
}

void main(){
function(1,2,3);
}


can't be too hard right?
>>
>>59614421
Also use
-mpush-args
>>
>>59614453
So? Wouldn't trying to stop someone who is eating his own feces be better than just telling him to continue?
>>
>>59614466
just tried gcc -S -mpush-args -mno-accumulate-outgoing-args example.s example.c

still the same
>>
>>59614476
>muh side effects
>>
>>59614465
The assembly looks correct to me. Why would it need to use push? You are giving it enough arguments to require spilled variables onto the stack.
>>
>>59614495
Who are you quoting?
>>
>>59614476
Why do you care?
>>
>>59614497
aren't*

The complete opposite is closer than nowhere close.
>>
>>59614421

>but still have mov everywhere(when passing parameters)
On pretty much every architecture other than 32-bit Intel, the standard method of passing parameters is through the registers. The stack is only used for functions with many parameters.

No, you cannot tell GCC to use push instead of mov. It was designed to generate code that is both compliant with application binary interface standards, and which is reasonably performant. The only way you're going to get specific instructions being executed is with inline assembly, but to be honest, you don't need to.

Why the hell do you want a push instruction to be generated anyways?
>>
>>59614502
Why would I not care?
>>
>>59614509
Because it's none of your business
>>
>>59614465
void function (int a, int b, int c, int d, int e, int f, int g){
char buffer1[5];
char buffer2[10];
}

int main(){
function(1,2,3,4,5,6,7);
return 0;
}

results in
function(int, int, int, int, int, int, int):
push rbp
mov rbp, rsp
mov DWORD PTR [rbp-36], edi
mov DWORD PTR [rbp-40], esi
mov DWORD PTR [rbp-44], edx
mov DWORD PTR [rbp-48], ecx
mov DWORD PTR [rbp-52], r8d
mov DWORD PTR [rbp-56], r9d
nop
pop rbp
ret
main:
push rbp
mov rbp, rsp
push 7
mov r9d, 6
mov r8d, 5
mov ecx, 4
mov edx, 3
mov esi, 2
mov edi, 1
call function(int, int, int, int, int, int, int)
add rsp, 8
mov eax, 0
leave
ret
>>
I thought the C++ memes were just memes, but holy shit this language is insufferable and whoever designed this standard library deserves to be thrown off a bridge.
>>
>>59614497
>>59614505

>Why would it need to use push?

wanting to use a buffer overflow to change the return address

http://insecure.org/stf/smashstack.html

^seems to be quite out of date then

>>59614516

Thank you, now I need to look for a proper tutorial on buffer overflow exploitation.
>>
>>59614534
Rust or D is the only sane choices left.
>>
>>59614515
It actually is. I might get attacked and pozzed by one of them. You can't trust someone that animalistic.
>>
>>59614534
Reminder that
int a;
if (a = 0)


is perfectly legal code in C++
>>
>>59614554
>POO
>sane choice
what did he mean by this?
>>
>>59614558
>I might get attacked and pozzed by one of them
Not their fault you are too afraid for a confrontation
>>
>>59614585
I'm pretty sure any human would be afraid of contracting a disease which turns you into an animal of sorts.
>>
>>59614553

If you are trying to corrupt the return address, why do you need function arguments to be located on the stack?
>>
>>59614593
Yeah but you don't count as a human
>>
>>59614607
Why is that? I believe I am human since several tests I've done seem to suggest that.
>>
>>59614616
You have been tricked into thinking so
>>
>>59614565
The assignment operator returns the result of the rvalue.
The rvalue is zero, meaning that the if statement conditional is unreachable and can be safely optimized away.
>>
>>59614604

I don't know it was just part of the tutorial I linked
>>
>>59614565
a = 0 is an expression that produces values.
I don't like C/C++ btw
>>
>>59614632
Well my point is that assignment and equality can be interchanged in that context. Which is fucking awful.
>>
>>59614565

C is not the only language that allows this.
(if (set! a 0)
(display "totally")
(display "legal"))
>>
>>59614656
That's your problem, not the compiler's.
>>
>>59614656

if (ptr = malloc(amount)) {
/* Do work with ptr */
}
else {
/* Produce error; malloc failed */
}


It has its uses.
>>
>>59614683
What could be the actual reason of allowing code like that though. No one does it intentionally
>>
>>59614726
if ((err = some_lib_func(...))


if a non-zero error code is returned, the if conditional is triggered, it makes for easy exception handling
>>
>>59614656
Well your point is invalid.
>>
>>59614762
That is some shitty programming
0/10
>>
>>59614816
for using a well designed language it certainly is.
Strict semantics are very important
>>
>>59614827
I haven't even mentioned how goto comes into play.

>>59614722
Serious question, how do you recover from a malloc error?
I doubt the OS is suddenly going to give you memory if you try again.
>>
>>59610823
Even though I'm as tech-savvy as Hakase, I'll never be as cute.

Why am I thinking about this.

I'm a man. What the fuck is my problem.

/dpt/, I want to program but I'm stuck on the self-loathing train, please advise
>>
>>59614858
By knee socks
>>
>>59614858
it's ok, I wish I was a cute anime girl too.

but it's never gonna happen
>>
File: dpt.jpg (164KB, 800x1000px) Image search: [Google]
dpt.jpg
164KB, 800x1000px
>>59610823
>>
>>59614851
>Serious question, how do you recover from a malloc error?
Shitstorm incoming. The GNU was right. The program should exit. Ideally it should be the offending program, but that's not really something that's easy to determine on the user program side.
>>
>>59614851
>Serious question, how do you recover from a malloc error?

Statically allocate a global exception object at the beginning of the program that informs the user their RAM is full. (Because you won't be able to allocate it later, for obvious reasons.)

If malloc throws, throw the exception.

The real question is, how do you recover from a stack overflow. I mean you can't even so much as catch the exception; doing so would use the stack, which has overflown.
>>
>>59614874
me on the bottom
>>
Lightweight Outlook replacement as the company i work for went with E1 licenses but wanted an Outlook-like client.

Background workers keep getting hung when making multiple EWS calls at the same time (never triggers completed event). Anyone else encountered this?

Current workaround:
If (callInProgress){
Thread.Sleep(1000)}

C#, using MS EWS Managed API 2.2.
>>
>>59614848
Do you even know what "semantics" means? Google operational semantics, they're unambiguous in the case of C++.
>>
>>59614870
No disrespect man but fuck that mentality. I'm gonna buy estrogen on Amazon and starve myself
>>
File: john_530_big.jpg (208KB, 530x424px) Image search: [Google]
john_530_big.jpg
208KB, 530x424px
Explain pointers in c, why I should care about them and when and when not to use them like I'm a fucking toddler please.
>>
>>59615058
>why I should care about them
they're important
>when
when you need to
>when not to
when you don't need to
>>
>>59615058
Experience. Use them. Fail. Learn why you failed and use them according to your new knowledge to learn more. You should start by learning about assembly too at some point if you really want to know how your computer works.
>>
>>59615016
You'll just relapse and gain it all back.

It's not the self control that's the problem, it's the part where you put the following together in your head:
1) Doesn't matter how fat you are, if you don't eat, your body won't want to use energy as liberally as it was using it when you did.
2) Your brain is a part of your body.
3) If your brain doesn't get to use energy liberally, your boss gets mad at it.
>>
>>59614851

>how do you recover from a malloc error
Depends upon the program and the circumstances. If you're running some sort of language virtual machine, a malloc error might be a time to say "okay, let's run the garbage collector and try again." If you're trying to allocate memory for some sort of vector that doubles in capacity each time you push back behind your limits, you might say "well, let's try and allocate 1.5 times instead of 2 times, and see if that works."

I'd imagine in most cases though, you'll just inform the user that the program has run out of memory, and then crash.
>>
>>59615016

>I'm gonna buy estrogen on Amazon and starve myself
Are you trans? Go see a psych first. Also, don't starve yourself. Eat healthy, and burn fat through exercise.
>>
>>59615165
>Go see a psych first
First see a psych
then kill yourself.
>>
>>59615101
kek this is so true
>>
Reminder that
[](){}()

Is perfectly valid code in C++
>>
>>59615165
You can literally burn fat by not eating like a pig. But yeah what he >>59615171 said.
>>
>>59615246
>and people say there is no void literal
>>
I spent all this time learning monad transformers and creating a small MVC API and now i3 won't even accept my JSON output for no reason
>>
File: bowie.jpg (105KB, 937x937px) Image search: [Google]
bowie.jpg
105KB, 937x937px
Listening to David Bowie as I try to follow this tutorial
-> http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/

Quick question... It appears that I'll need to draw pixel by pixel, but how would I go about doing that with SDL? I'm very unfamiliar with graphics in programs. Should I just wait until after I complete some of the other tasks?
>>
>>59615289
monad transformers are cute
>>
>>59615171

The point of telling them to see a psych is so that they don't kill themselves, Anon. A psychologist might be able to determine if Anon's self-loathing and desire to be like a girl are a result of some deep-seeded gender dysphoria (a neurological condition for which the best known treatment is hormone replacement), or as a result of some other influence in their life that may be able to be addressed. If it is the former case, they would be able to refer Anon to a psychiatrist, who would be able to determine which hormone drugs, and in which quantities, Anon should take, which will not interfere with other medications they are taking, or any health conditions they may have.

The goal is to make people healthy, or at least as healthy as possible. You can't achieve that by letting them die, nor can you achieve that by letting them self-medicate when a medical professional can help them make more informed decisions.

>>59615261

You know, you can make a void statement in C++. A common macro for indicating that a parameter in a function is unused, but still has to be there, looks like this:

(void) param;
>>
>>59615371
No psych is going to tell a trans that they are just mentally ill and not actually a girl. That is a one way ticket to getting getting your license revoked. That is just the current political climate. Plus there is no concrete objective way to diagnose such an issue. If one wanted, one can psych hop till they arrive at one that confirms their bias of what they want to hear. This is what many people do to get pills they want.
>>
>>59615371
Most dysphoria cases are misdiagnosed disassociative personality disorder combined with depression, the political climate is so open to the idea of transgenderism they'll probably encourage him to become a tranny even if he wasn't really that dysphoric to begin with
>>
>>59615411
>There's no concrete objective way to diagnose such an issue
>What is the DSM, APA, or most generally accepted standards in Psychology?
>>
>>59615411
>>59615416

While there is a point to be made about psychologists today being more likely to have a bias, the point about seeing a psychiatrist first before putting one's self on any sort of drug still stands, especially if the alternative is self-treatment. While I am no expert on the subject myself, I do not think it is a wise idea to treat hormones like over the counter drugs.
>>
>>59615480
Standards which are open to interpretation. If standard illness can get misdiagnosed all the times, you thing feelings won't get misdiagnosed? Are you fucking retarded? Go be a real doctor.
>>
>>59615487
There is literally no scenario where you won't walk out of a psych office with a gender dysphoria diagnosis if you tell them "i wish i was a cute girl"

That's just how it is.
I would much rather that anon starve himself and play dress up than to halt critical bodily functions because he watched too much anime.
>>
File: rails_welcome.png (1MB, 1154x1110px) Image search: [Google]
rails_welcome.png
1MB, 1154x1110px
Why don't you use ruby on rails, /g/? It just works!
>>
>>59614945
me on the top ;)
>>
>>59610923
Rewriting UNIX in Fortan
>>
>>59615598
It is quite unfortunate that in spite of the myriad of advances we have made in the field of medicine over the past century, we still have quite a ways to go with regards to mental health.

>>59615669
I don't really do much web development, and in the areas where I might consider doing web development, I can't see a place for using the Rails framework. If the application is small, and not expected to see a lot of users, a simpler web framework like Sinatra would make it easier to set up and easier to manage. If it needs to scale up, then Ruby is not the appropriate language.
>>
How worried should I be if I can't write insertion sort easily? I feel like I've been getting dumber and this wake up call alarms me
>>
Can anyone point me in the direction of how to parse large amounts of CSV data in a column format in PHP?
 WGT;  160000    ;  200000    ;  210000    ;  220000    ;  230000    ;  240000    ;  250000    ;  260000    ;  270000    ;  280000    ;  290000    ;  300000    ;  310000    ;  320000    ;  330000    ;  340000    ;  350000    ;  360000    ;  370000    ;  380000    ;  390000    ;  400000    
1000; 7952.0;315; 7952.0;315; 8228.0;320; 8532.0;326; 8864.0;332; 9212.0;339; 9564.0;347; 9920.0;354; 10280.0;361; 10632.0;367; 10972.0;374; 11296.0;379; 11604.0;384; 11904.0;388; 12116.0;391; 12252.0;391; 12400.0;391; 12556.0;391; 12720.0;391; 12896.0;391; 13084.0;391; 13284.0;391
6000; 7952.0;315; 7952.0;315; 8228.0;320; 8532.0;326; 8864.0;332; 9212.0;339; 9564.0;347; 9920.0;354; 10280.0;361; 10632.0;367; 10972.0;374; 11296.0;379; 11604.0;384; 11904.0;388; 12116.0;391; 12252.0;391; 12400.0;391; 12556.0;391; 12720.0;391; 12896.0;391; 13084.0;391; 13284.0;391
8000; 7808.0;321; 7808.0;321; 8128.0;328; 8464.0;335; 8816.0;343; 9168.0;350; 9528.0;358; 9880.0;365; 10220.0;372; 10540.0;377; 10848.0;383; 11140.0;387; 11424.0;391; 11704.0;395; 11988.0;399; 12232.0;401; 12384.0;401; 12544.0;401; 12720.0;401; 12904.0;401; 13100.0;401; 13308.0;401
10000; 7724.0;330; 7724.0;330; 8064.0;338; 8412.0;346; 8772.0;354; 9124.0;362; 9468.0;369; 9792.0;375; 10096.0;381; 10388.0;385; 10668.0;390; 10944.0;394; 11228.0;398; 11520.0;402; 11820.0;406; 12136.0;410; 12408.0;413; 12580.0;413; 12764.0;413; 12956.0;413; 13164.0;413; 13380.0;413
>>
>>59615828
What exactly are you trying to do?
If you just want to put a CSV file into a database, then Python would make your task a lot easier.
>>
>>59615828
Put it into a database and query it out?
>>
>>59615828
Why the fuck are you parsing CSV data with language meant for web dev?
>>
File: data.png (105KB, 1386x589px) Image search: [Google]
data.png
105KB, 1386x589px
>>59615868
I have a lot of CSV files with data about aircraft fuel burn at specific altitudes and I'm trying to figure out how to parse it, and getting nowhere. Basically given a weight (top row) and altitude (left column) figure out the speed and fuel burn of an aircraft
>>
>>59615923
Python.
Panda.

Do you need to use PHP?
>>
>>59615936
Its part of a web application
>>
>>59612218
you can just drag and drop you files onto you repo lol
>>
>>59615942
Do you need to use PHP? Cause Python can do web application as well.
>>
>>59615950
Well Im pretty deep into the application and would prefer not to do a complete rewrite
>>
>>59610823
I am learning tkinter and it gives me suicidal thought
>>
>>59615923
So if I ask your program to get fuel burn data for weight 210000 at weight 10000, I should get back "8064.0;338;"?

If so, you want to get to the correct row by looking at the left-most value (Is the current row the one I'm looking for? If not, go to next row and repeat) and then use a similar process to go across the row.

Since you're making this in PHP, I'm wondering if this is a small helper "web app". If it's not for a class assignment with strict rules, you should consider just putting that data in a static 2d array in PHP (or an actual database if it's constantly changing). That way you won't have to parse the entire file for each lookup
>>
main[-1u] = { 1 };


defend this
>>
File: out.webm (813KB, 1024x720px) Image search: [Google]
out.webm
813KB, 1024x720px
Is it possible to rewrite this script in powershell?

#!/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
>>
>>59615999
that's some disgusting shell scripting
>>
>>59615963
Hmm what do you plan do with this csv data? It is possible to interface python with PHP. Or you could always head over to webdev gen and ask them.
>>
>>59615969
Yes exactly, where 210000 is weight and 10000 is altitude. Fuel burn is 8064 kg/hr and speed is 338 kts

I'm trying to figure out the best way to put it into a static 2d array without doing it manually, as I have a couple other profiles to parse too
>>
>>59615966
Just give up on tkinter and learn pyqt. You are going to be using that 90% of the time anyway.
>>
>>59615999
Dir *.jpg | ForEach-Object  -begin { $count=1 }  -process { rename-item $_ -NewName "image$count.jpg"; $count++ }
>>
>>59616005
4chan's syntax highlighting makes it look disgusting, but what would you even do to make it look better?

Inb4 no response.
>>
>>59616013
>I'm trying to figure out the best way to put it into a static 2d array without doing it manually

Execute a python script to put it into a static 2d array and have the script give the array to your PHP the array.

http://stackoverflow.com/questions/166944/calling-python-in-php
>>
>>59616013
Honestly, if each profile is about the same size and you only have to do it once, I would just use a vim macro.

If you know how to use vim, it's incredibly easy to make and you "define" a particular movement and copy it over to the entire row.

Personally, I wouldn't bother making a whole script to parse the file if I only need to do it once.
>>
>>59616028
alright, thats a good point. i'll look into pandas
>>
>>59616017
>Dir *.jpg

That's not the same as looping through every argument given to the script.

>{ rename-item $_ -NewName "image$count.jpg"; $count++ }

Are you just taking all .jpg files in a directory and renaming them "image1.jpg", "image2.jpg", etc. ? Are you retarded? That's not anywhere close to what that script is doing.

The script is

1) Taking all arguments given to it and looping through each of them

2) Generating a random number between 1400000000000 and 1469999999999

3) Getting everything after the last "." in an argument given to it (for example if given "image.foo" then $extension will be "foo")

4) Creating a new filename to resemble a fake 4chan filename, checking to make sure that filename doesn't already exist, and then breaking out of a loop

5) Renaming the file given as an argument to the new fake filename.
>>
>>59616028
Wouldn't that load and parse the file from disk on every single web request? Doesn't seem efficient if the data is static, and would also make his service very very easy to DDOS (which may not be a concern).

OP should run the python script once, then hardcode the data into the PHP script if it will never change.

Operating systems are finicky about file access, and if 5 people request data from your PHP script at the same time, and you try to open 5 file descriptors for the same file at the same time, the server may not serve all of them, leading to random errors on some machines.
>>
>>59615999
Post image1 and image2.
>>
>>59616065
Seems logical. I don't do web dev so I don't think about these stuff.
>>
File: image 1.jpg (114KB, 551x740px) Image search: [Google]
image 1.jpg
114KB, 551x740px
>>59616081
>>
NEW THREAD NOW!!!

>>59616097
>>59616097
>>
>>59616061
That's exactly what one of those scripts does.
>Dir *.jpg
Change it to just dir |

>1) Taking all arguments given to it and looping through each of them
What arguments? You're just grabbing every files. Dir |

>2) Generating a random number between 1400000000000 and 1469999999999
replace { $count=1 } with { $count=Get-Random -Maximum whatever -Minimum whatever }

>3) Getting everything after the last "." in an argument given to it (for example if given "image.foo" then $extension will be "foo")
$_.Extension

>4) Creating a new filename to resemble a fake 4chan filename, checking to make sure that filename doesn't already exist, and then breaking out of a loop
if (Test-Path "$count."+$_.Extension)

>5) Renaming the file given as an argument to the new fake filename.
That's what the rename-item command does.

I'm not going to sit down and actually write all this shit out for you, it takes like 2 seconds of googling to figure out how to do any of this.
>>
File: image 2.jpg (631KB, 768x1024px) Image search: [Google]
image 2.jpg
631KB, 768x1024px
>>59616081

>>59616118
>What arguments? You're just grabbing every files.

No I'm not, do you even know what "$@" means? It means all arguments given to the script, for example I might run the script like this

cstamp image.jpg image.png image.gif image.tiff


And
for x in "$@"
would loop through each of those arguments.

Can you even loop through arguments given to a powershell script? LMAO
>>
>>59616147
>Can you even loop through arguments given to a powershell script?
https://ss64.com/ps/for.html
$args[]
>>
File: 29581.jpg (109KB, 854x480px) Image search: [Google]
29581.jpg
109KB, 854x480px
>>59610823
Learning Ruby.

Currently reading "The Well-Grounded Rubyist"

What languages are you guys learning?
>>
>>59616465
Swinglish.
Thread posts: 321
Thread images: 30


[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]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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 RandomArchive shows their content, archived.
If you need information for a Poster - contact them.