/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

schneier.com/blog/archives/2016/10/security_design.html
en.wikipedia.org/wiki/MIFARE
en.wikibooks.org/wiki/R_Programming
twitter.com/NSFWRedditVideo

Thank you for using an anime image.

You're welcome, senpaichan.

var board = new Board("g");

var thread = board.Threads.Where(t => t.Subject.Contains("/dpt/")).OrderByDescending(t => t.Posts.Count()).FirstOrDefault(t => t.Posts.Count() < 300);

Guess what
class FileSplitter(chunkSize: Int, hashAlg: String) extends GraphStage[FlowShape[ByteString, Chunk]] {
val inBytes = Inlet[ByteString]("FileSplitter.inBytes")
val outChunks = Outlet[Chunk]("FileSplitter.outChunks")
val shape = FlowShape(inBytes, outChunks)

def createLogic(inheritedAttributes: Attributes) = new GraphStageLogic(shape) {
val messageDigest = MessageDigest.getInstance(hashAlg)
var buffer = ByteString.empty

def hashBytes(bytes: ByteString): Unit = {
val size = chunkSize - buffer.length
if (size > 0) {
val array = bytes.take(size).toArray
messageDigest.update(array)
}
buffer ++= bytes
}

def emitBuffer(): Unit = {
require(buffer.nonEmpty, "Buffer is empty")
val (drop, keep) = buffer.splitAt(chunkSize)
val newChunk = Chunk(chunkSize, ByteString(messageDigest.digest()), ByteString.empty, drop)
emit(outChunks, newChunk, () ⇒ {
buffer = ByteString.empty
messageDigest.reset()
if (keep.nonEmpty) hashBytes(keep)

if (buffer.length >= chunkSize) emitBuffer()
else {
if (isClosed(inBytes)) {
if (buffer.nonEmpty) emitBuffer() else complete(outChunks)
} else {
pull(inBytes)
}
}
})
}

setHandler(inBytes, new InHandler {
def onPush() = {
val bytes = grab(inBytes)
if (bytes.nonEmpty) hashBytes(bytes)
if (buffer.length >= chunkSize) emitBuffer()
else tryPull(inBytes)
}

@scala.throws[Exception](classOf[Exception])
override def onUpstreamFinish() = {
if (buffer.isEmpty) complete(outChunks)
else emitBuffer()
}
})

setHandler(outChunks, new OutHandler {
def onPull() = {
tryPull(inBytes)
setHandler(outChunks, eagerTerminateOutput)
}
})
}
}

if haskell is so great, why chome uses javascript?

...

SDL vs SFML, which is better?

you can say the same about c/c++

>lecturer starts introducing C
>girl in the class asks if it has double so that it can represent numbers with two decimal places
>asian asks if it has classes, lecturer says no, so asian concludes it must not be useful for complex programs

>t.Posts.Count() < 300
310

Better yet, t.Posts.Count() < board.BumpLimit.

Why are asians so fucking stuck up? They usually aren't as smart as they think they are.

>so asian concludes it must not be useful for complex programs
This is somewhat true, though.

No one writes anything complex in C unless it has to be that low of level. Even then, C++ is used instead for the best of both worlds.

>complaining about asians but not the girl

SFML is meant to be used standalone and it comes with everything you need to make a 2D game without touching OpenGL yourself.

SDL is more of a basic platform abstraction library (including a super low level audio abstraction module), but it comes with useless things like its renderers and thread/filesystem stuff that is probably in your standard library anyways. You need extension libraries to do things like higher level audio and image loading anyways.

GLFW is better than SDL if you just want a window with input and an OpenGL context. SDL is more battle-tested despite half of the library being useless for anything substantial.

Good point, I'll add board constants

What's good replacement for c++ if you don't care if it has gc or no?
thinking about chapel, d, ocaml, sml?

If you're okay with GC you should probably just use C#, it's got much better support than D. OCaml is its own thing, no reason to use SML if you can use OCaml, and Chapel is its own thing.

haskell

>C#
microshit
>no reason to use SML
Standardized language with many implementations compared to lang with only one implementation

Just making sure, you're going to actually check the json to get the bump limit value at runtime, right?

Bump limits change, and they're different from board to board.

Rate my script, /dpt/!
#!/usr/bin/perl

use v5.14;

$a = ;
$a = reverse $a;
$a =~ s{(\d)(\d)?(\d)?([0-3])?}
{("M" x $4) .
(($3 == 9) ? "CM" :
(($3 > 4) ? ("D" . ("C" x ($3 - 5))) :
(($3 == 4) ? ("CD") : ("C" x $3)))) .

(($2 == 9) ? "XC" :
(($2 > 4) ? ("L" . ("X" x ($2 - 5))) :
(($2 == 4) ? ("XL") : ("X" x $2)))) .

(($1 == 9) ? "IX" :
(($1 > 4) ? ("V" . ("I" x ($1 - 5))) :
(($1 == 4) ? ("IV") : ("I" x $1)))) }ex;
say ($a);

common lisp
it's better than sepples or java
has CLOS

>microshit
DevDiv, so this isn't inherently anything against the language.

>Standardized language with many implementations compared to lang with only one implementation
This isn't inherently good.

I just want to do some graphics programming which probably entails getting deeper into opengl. I've been comparing all 3, I like the look of GLFW but it pissed me off because apparently there's no way to get a floating window in i3 wm, I tried using the floating window hint from the docs but it always tiles no matter what and I have to manually detach the window instead of having it start floating. This isn't an issue with either of the other 2.

Yeah, basically I'll add it as a lazy evaluation. Once the user checks one board's bump limit (or any other constant), it'll get downloaded and cached for all other boards to use. The idea is that the bump limit won't change while the application is running.

>What's good replacement for c++ if you don't care if it has gc or no?
C#, depending on your other goals for the language.

If you just want a window and OpenGL context, no reason to use SFML over either of the others. Between SDL and GLFW then I guess it comes down to that.

I'm currently on a facebook messenger bot
I'm using heroku to host and i configured the facebook's webhook with this
But is it possible to work on local with heroku ? or am i supposed to push every time i want to check if it works ?
I've seen that ngrok do this , can i do the same with heroku or bitbucket or anything similar ?

C is used for the Linux Kernel and the majority of NASA's control software on shit that goes to space, that's pretty complex to me.

The asian is an idiot, but if you guys are just starting adn haven't done a course where you've covered single and double precision it's a simple wrong assumption to make.

If you need to keep C++'s low-level characteristics (i. e. you need a language that has pointers and compiles to object code), then Object Pascal.

If a high-level language is okay, then Ruby.

Her question was so stupid I thought it didn't even merit a comment tbqh.

To take the course you already need two semesters in Java (or an accelerated single semester equivalent) and that kind of thing was covered very early on.

>C is used for the Linux Kernel and the majority of NASA's control software on shit that goes to space, that's pretty complex to me.
Nice reading comprehension, dumbfuck.

$ cat cpu
#!/bin/bash

CPU=`sed '/^model /!d;s/^.*: //' /proc/cpuinfo`
CPU_A=`echo "$CPU" | wc -l`
CPU_B=`echo "$CPU" | head -n 1`
CPU_C=`lscpu | sed '/^CPU M/!d;s/^.*:\s*\([0-9][0-9]*\)\..*$/\1/'`
CPU_T=`sensors | sed '/^Core 0/!d;s/^.*\s\([+|\-][0-9\.]*.C\)\s.*$/\1/'`


printf "%s x%s (%s - %s MHz)\n" "$CPU_B" "$CPU_A" "$CPU_T" "$CPU_C";
$ ./cpu
Intel(R) Celeron(R) CPU N3150 @ 1.60GHz x4 (+46.0°C - 482 MHz)


what is my script missing?

nope, you are wrong, some faggot said that C sucks and NASA used common lisp

>"No one writes anything complex in C"
>he wrote, on his computer whose entire software stack is written in C

Are there any easy/simple ways to prevent human error in your gui application?

Stuff like inputting invalid information that would cause a crash or just regular fuckery?

remove the human

see

Event-driven architecture.

oh ok then, that's a red flag desu

>Even then, C++ is used instead for the best of both worlds.
:thinking:

Limit human input.

Think of what they should be allowed to put in, and whitelist that, rather than thinking of what you want to prevent them from putting in.

To this end, make use of selection inputs rather than text boxes, and masked inputs for those where the user can type something in.

You need to validate input at the source.

do it in haskell, it's type system will do the work for you

>:thinking:
Kill yourself.

I could have clarified with "often", but C++ is typically/often used when low-level is a requirement.

There are exceptions.

PostgreSQL is written entirely in C, just to give you an example, you fucking idiot.

t. Rajesh

what kind of stupid are you?

Stop blaming the user.

schneier.com/blog/archives/2016/10/security_design.html

Since when do Pajeets understand advanced software engineering concepts?

>event-driven
>callback and mutable state hell
>advanced

your life must be pathetic

It's actually quite nice.

>callback hell
Only if you use functional trash. Object orientation provides you more sophisticated mechanisms.

>mutable state hell
Have you ever heard of a finite state machine? Wasn't so hard to fix it, see? You're such a rookie.

>58720971
>(you)

FP doesn't use callbacks because they inherently require mutable state. If it's a function that you pass in, is used, and then the higher order function returns, it's not a callback.

OOP however is how you get mutable state hell.

>Have you ever heard of a finite state machine?
What does that have to do with it?

A functional programmer looks at an asynchronous system and thinks in terms of futures and continuations.

>In the real world, we have enough risk that we get insurance against it and that insurance has requirements as a result of statistics e.g. 'you must have a door lock'. There isn't as yet an Internet parallel.

>Take posting on Facebook. Without some sort of operational security (read: thinking before pressing Enter), deciding whether or not to indicate that they're on holiday this next week to the entire world is pretty much up to them, as are the consequences. It's impossible to tailor software to prevent that as a threat model, so the prevention has to be punitive on the user. What's going to be more effective - trying to default posts to only trusted associates, and then trying to figure out who is trusted and prevent the user from trusting random strangers, and... or an insurance company refusing to pay out for theft when the user posted their whereabouts on public media?

>So we do train users all the time. The problem is that we currently try to train them to be computer specialists, and we should train them in managing their risks and exposure.

>Just look at the phrase 'this certificate has expired' to demonstrate that the author of that message is completely and utterly clueless about how to convey risk to a user.

Makes you think.

You're so full of shit.

>passing a function and making use of it is not a callback, okay?
>OOP is to blame for mutable state hell, even though OOP solves it

Please stop, there can be no debate between us. There can be class if you want. But not discussion.

anybody versed in lisp macros here?
I want to write a range macro that mimics python's range function
but I haven't reached the macro chapter yet
can somebody write it for me pls

What should I seek for if I want to read about firmwares on chip and phone cards?

Here's a breadcrumb.

en.wikipedia.org/wiki/MIFARE

>passing a function and making use of it is not a callback, okay?
It's not. Nobody calls map's function parameter a callback.

>OOP solves it
This delusion. OOP restricts how you can mutate state, but it has nothing to do with when and where it is allowed which is the real problem.

I hate all this "language" bullshit. Can I just use typed lambda calculus instead?

make an interpreter for lambda calc

What should I use to learn R?

Brain

use LL grammar to make interpreter

>Can I just use typed lambda calculus instead?
What exactly do you mean by this?

I suspect your goals have been met by multiple modern languages.

Just use the wikibook, man.
en.wikibooks.org/wiki/R_Programming

What should I write it in? I'm only familiar with C and Haskell but I'm still pretty mediocre at them.
And would it be possible to rewrite it in itself later or that's just too hard for me at this point?
I mean exactly that, using lambda calculus instead of all the language nonsense.

//This is a single-line comment!!!
/*HELLOOOOOOOOOO
*This is a delimited comment which may span multiple lines!!!
*/
/*//-->Below is different data types and their usage points!!!
int num01; //variable declaration!!!..int = no decimal places
float decimalpoint = 10.4; //decimal point number!!!
num01 = 20; //initialize variable!!!
double decimalpoint = 10.4 //float but with more precision!!!
bool trueOrFalse = true;//boolean...value/variable that could be true or false!!! --> this value same as 0's and 1's that make up computer but we just call it true or false instead!!!
string sentence = "Hello World!";*/

} //() -->whatever inside here = parameters!!!

Try Haskell

haskell, because its meant to write compilers or whatever

Is that why the Haskell compiler is written in C?

DELTE THIS

>Haskell 82.3%
>C 10.5%

what did he mean by this?

Why did you need 10.5% C? The C compiler is 100% C, it doesn't have 10.5% Haskell in it.

>Why did you need
I didn't, I didn't make GHC

Oh I see, so you only use it? Do you use all of it or only the 82.3% Haskell part?

>The C compiler

GHC comes with some C headers and libraries for platform and FFI stuff.

>Do you use all of it or only the 82.3% Haskell part?
None of it actually

>animu

Good for you then.

It doesn't matter, whatever you find more convenient for you. Do lexical analysis, do syntax analysis and build a parse tree. Having a parse tree, you can translate it into an asm or a bytocode for a vm or another language.

can I hack tinder so I can get some matches? no one likes me ;c

>being a plebbitor

>somebody call me out on my faggotry!
>quick, I gotta imply he came from reddit otherwise my reputation on this anonymous Crimean Matryoshka image board will be ruined forever!

>somebody call me out on my faggotry!
Yes, you are correct. I did call you out on your retarded faggotry since you seem to think there is such a thing as "The C compiler"

go

>can't refute him
>appeal to linguistic pedantism
>be a faggot on top of it by posting pictures of mongolian make-believe drawings
Your rectal shattering is showing.

Refute what? You didn't make any claims

So you got mad over nothing? Whoa, that can't be good for your health!

Do you need a glass of water or something?

>non-arguments

naa

>This is a non argument

Is this for the tutorial you TA or some shit

>Ceci n'est pas un argument