/dpt/ - Daily Programming Thread

What are you working on, Sup Forums?

Previous thread:

Other urls found in this thread:

github.com/Akari-chan/brainf/blob/master/main.c
people.cs.clemson.edu/~bcdean/dp_practice/dp_3.swf
hashcrack.org/
msdn.microsoft.com/en-us/library/system.environment.stacktrace(v=vs.110).aspx
reference.wolfram.com/language/CUDALink/guide/CUDALink.html
reference.wolfram.com/language/CUDALink/tutorial/Overview.html
github.com/explore
gnu.org/help/help.en.html
doc.rust-lang.org/std/prelude/)
doc.rust-lang.org/book/error-handling.html
doc.rust-lang.org/src/std/io/stdio.rs.html#205-219
twitter.com/SFWRedditGifs

1.vbs
Set Sapi=Wscript.CreateObject("SAPI.spVoice")
Sapi.speak "Hello world"

document printing layout in html
please somebody kill me

Rate my Brainfuck interpreter

github.com/Akari-chan/brainf/blob/master/main.c

nth for good morning Sup Forums

Looks good to me.
I haven't seen you post in a while.

You're mistaking me for someone else senpai

Fucking C toddler, can't even write the simplest program without a buffer overrun.

>You're mistaking me for someone else senpai
Hmmm...

Now make it compile to LLVM .

Fuck off Rust cancer.

Make it compile to javascript and then maybe it'll be of any use

Trying to memorize all 86 reserved keywords in c++ because my professor is a douche

I don't use Rust, whereas my original statement is correct.

Rust cancer are notorious for calling out C programmers.

bad news for you, there are 92 reserved keywords in C++

>Cniles now have their own boogyman

Shows you how well I'm doing

Good morning Sup Forums !

This is what I come here for, the bickering.

hey /dpt/, its time to play `guess the language` game. i will start:
((((((((((((((((((((((((((((((((((((((((((((((
)))))))))))))))))))))))))))))))))))))))))))))))
((((((((((((((((((((((((((((((((((((((((((((((
AAAAAAAY
)))))))))))))))))))))))))))))))))))))))))))))))
((((((((((((((((((((((((((((((((((((((((((((((
)))))))))))))))))))))))))))))))))))))))))))))))

>Syntax error:
>unknown location: unexpected syntax in form ()

hmm

WOW! I wonder what language that could be?

Employed Arch user and hardcore hacker here

How many GBP(Good Boy Points) do you earn?

Who /freebsd/ here?

I used to, many years ago. I liked writing assembly for *BSD I thought the way they used the stack for system calls was pretty cool. It's been a long time though :-/

>mfw starting first real dev job
>I have barely done any programming in the last year

What programming did you do?

What's the job?

what's the n log(n) way to do it?
people.cs.clemson.edu/~bcdean/dp_practice/dp_3.swf

i already figured out the n^2 way before i watched this, and the whole way through i was thinking "BS this is n^2"

>Try "how to think like a computer scientist" its a great book
I've skimmed through it and it's just some basic stuff, nothing really new from me except python syntax.

>.swf
Wake up, grandpa, no one has Flash installed anymore.

Why did you do this?

c# dev
just fucked with some simple API's during last year of uni and then when I was searching for a job I just relearned some database interactions, SQL, JS, and other pretty basic stuff. Was good enough to pass the programming test and the interviews I guess. But I do spend quite a lot of time reading about programming and software development and I care about how to do it well, I just dont really like programming at home.
had a typo and removed it , shitty extensions just dont remove deleted posts from threads

To correct the grammar?

Trying to write a substitution cipher breaker. Never done anything in this area before but a good first step seemed to be to create a function that would compare the transitional probabilities between characters in an encrypted string given a proposal cipher to that of a large sample of English text.

It seems to be working; the scores of a bunch of encrypted strings given the correct cipher is about one standard deviation lower than a bunch of encrypted strings given the wrong cipher and a bunch of random strings. Does that seem like enough?

Now to think of what to do with it.

Is anyone here familiar with deep learning in Caffe?

I'm generating an LMDB database in C++. Each value is a Datum formatted using SerializeToString. I've verified that they can be successfully parsed back into the same Datum in my program, but when Caffe begins to read the database to initialize the data layer it gives
> Check failed: datum_channels > 0 (0 vs. 0)
and then aborts. At some point between being written to the database and being read back in by Caffe, the number of channels in my datum is going from 2 to 0. Does anyone have any idea what I'm doing wrong?

All I can find on Google is someone who solved their own problem then didn't explain the solution.

what language is that?

Mathematica.

looks like mathematica?

I'm not gonna know the language because it's really expressive and approachable to academics. I will say that you might run into an issue of processing power using it though. If you're trying to crack things quickly you need to use horsepower.

idk of mathematic has any clustering capabilities if it does you should look into a library that can help you put things in parallel. look at some of the SAAS cracking services out there

hashcrack.org/ etc

Currently trying to figure out how to turn on and off bluetooth from the windows command line.

I want to run an autohotkey script that will turn BT on and off on a certain hotkey so that I don't waste battery when I don't need to. Anyone have any suggestions, because the search has been less than fruitful so far.

Wanna hear a joke?
C walks into a bar.
SIGSEGV

Omg guise I compiled my first Jawa App!

Essentially gonna make a simple to do list sorted by deadline

Programming is fun!

it's probably managed by a windows service right? make your script stop/start that service file--i'm talking out my ass though I know nothing about windows

Wanna hear a joke?
Rust walks into a bar.
... compiling ...
Bar closes.

My other car is a cdr.

>not using dark theme
don't call yourself a programmer

You can probably query device manager with PowerShell and disable any returned devices that have "Bluetooth" in the name.

Yea I''ve been doing research on how to manage the bluetooth driver. So far the Microsoft bluetooth stack can't be managed from comand line, but I have the Intel drivers for bluetooth so maybe there is still hope.

I was able to find 2 services that deal with bluetooth, but I wasn't able to connect when I started them, so maybe thats not it...?

I'll look into that. I was thinking MCMC methods could help, I'll see if there's a way to parallelize them. Mathematica has nice wrappers for parallelism like ParallelTable and also CUDA capabilities so it shouldn't be too hard to write my own I think.

how do code in jevva?

You don't. You mentally torture yourself in jevva.

ipconfig doesn't show any bluetooth devices when it looks like it should. I have the bluetooth device turned on in the device manager so I feel like there should be SOME way too see if it's active or not, apart from looking at GUI's

Just OOP in LOO

methods will probably help to a certain point with optimization if there are CUDA libraries that is fantastic, I didn't know that. That actually raises my opinion of Mathematica quite a bit--I'd assumed they were sorta ivory tower not considering hardware.

Doing my homework on Javafx.
Trying to make a traffic light with some buttons to mash and cross the lights :^).

here my current code:
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package autismus_maximus;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

/**
*
* @author you wish you knew my name.
*
*/
public class TrafficLights extends Application {

Group Ampel = new Group();

Circle makeLight(int x, int y, Color lightcolor) {
Circle light = new Circle(x, y, 25);
light.setFill(lightcolor);
light.setStroke(lightcolor);
light.setFill(null);

return light;
}

Rectangle Ampelkasten(int x, int y, int w, int h, Color farbe) {
Rectangle ampelkasten = new Rectangle(x, y, w, h);
ampelkasten.setStroke(farbe);
ampelkasten.strokeProperty();


return ampelkasten;
}

Group Ampel() {
Circle red = makeLight(200, 80, Color.RED);
Circle yellow = makeLight(200,140, Color.YELLOW);
Circle green = makeLight(200, 200, Color.GREEN);
Rectangle kasten = Ampelkasten(145, 25, 110, 220, Color.GREY);
return new Group(kasten,red, yellow, green);
}

@Override
public void start(Stage primaryStage) {
Scene Streets = new Scene(Ampel(), 480, 360, Color.WHITE);
primaryStage.setTitle("willkommen in den Straßen");
primaryStage.setScene(Streets);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}

}

I could be wrong (again I don't know much about windows) but I don't think you'd see bluetooth from your ipconfig. Bluetooth is a lower level protocol than TCP/IP. You'd use TCP/IP over ethernet, bluetooth is like ethernet if that makes sense. There is probably another method you would use to fetch it's data. Is there anything for it in the registry? (sorry for taking shots in the dark)

is there a way that one method can use a switch where the case is a calling method or anything similar in c#?

What are you actually trying to do?

You can probably use the new "when" syntax for this.

>you wish you knew my name
Hans

You're definitely doing something terrible wrong, but here's how you can check it: msdn.microsoft.com/en-us/library/system.environment.stacktrace(v=vs.110).aspx .

:^)

Yeah I haven't done much with it before but it's definitely there.

Looking through the documentation now and it seems pretty comprehensive. Looks like they have a bunch of built-in functions as well as the means to write your own kernels and stuff. There's also some symbolic functions that might be interesting for automatic code generation.
reference.wolfram.com/language/CUDALink/guide/CUDALink.html
reference.wolfram.com/language/CUDALink/tutorial/Overview.html

Fixed it. Just in case anyone is ever struggling with the same issue: LMDB keys must be less than 8 characters long.

#include

r.i.p. in pepperoni

(^:

^^

>Error: addComponentAsRefTo(...): Only a ReactOwner can have refs.

...

So, something I'm currently fooling with
>Have Quickbooks
>Quickbooks can write up a report and export it into Excel
>Excel has an addin from Quickbooks that queries the program and updates data
>All data about said report is saved in the Excel file, but data strings I've found so far aren't going to be easy to screw with
>Want one option to be editable instead of set in stone on export
If I were to take the add-in .dll (Or some other method?), could I glean anything useful out of it? If I could figure out how the call is made I could re purpose instead of going full trial-and-error with that part of the API that isn't documented great

...

but i gotta hustle that $weet android dough..
milk that $weet 88% market share user base.. punch that sweet clueless botnet pussy.. i gotta git that money, nam sayin'?

Oops, forgot we had that one. Cheers m8

was more curious if it could be done. Just messing around with a form that takes user input and validates it before putting it into a database.

I have a class that has a method to validate each field and methods that accept the input for each type of person. Was thinking of ways to do the validation depending on the person type being validated, if that makes sense

well I'll be. thats pretty neat. lots of my pals in data science (most of them U of M grad or industry in the area) swear by CUDA for their simulations. pretty cool that mathematica does that. keep those in your back pocket for sure

switch (muhPerson)
{
case Person p when ValidatePhone(p.PhoneNumber):
// phone number is valid
// maybe set a flag saying the number is fine
// or throw exception here if it's not valid
break;

}

// when you get here, if any of the validation flags are wrong, do something about it
// otherwise, return the validated person

Where do you guys find github projects to contribute to?

>using github

Gitlab* (?)

Either see if any project that I'm using that I'd like to contribute to has a repo hosted on Github or github.com/explore

Why not contribute to GNU? gnu.org/help/help.en.html

Can someone explain
1. What Ok() does
2. What unwrap() does and
3. Why exactly Stdin() is a function in Rust?

Getting used to Rust for the last two days, it's pretty nice I suppose.


Are you microsound?

finished, but I do not know how to use buttons...


package autismus_maximus;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class TrafficLights extends Application {

Group Ampel = new Group();

Circle makeLight(int x, int y, Color lightcolor) {
Circle light = new Circle(x, y, 25);
light.setFill(lightcolor);
light.setStroke(lightcolor);
light.setFill(lightcolor);

return light;
}

Button halteknopf(int x, int y, int w, int h,String name){
Button stop = new Button("STOP");

return stop;
}

Rectangle Ampelkasten(int x, int y, int w, int h, Color farbe) {
Rectangle ampelkasten = new Rectangle(x, y, w, h);
ampelkasten.setStroke(farbe);
ampelkasten.strokeProperty();


return ampelkasten;
}

Group Ampel() {
Circle red = makeLight(200, 80, Color.RED);
Circle yellow = makeLight(200,140, Color.YELLOW);
Circle green = makeLight(200, 200, Color.GREEN);
Rectangle kasten = Ampelkasten(147, 25, 105, 220, Color.GREY);
Rectangle stange = Ampelkasten(195, 245, 10, 300, Color.GREY);
Button halt= halteknopf(30, 30, 100, 100, STYLESHEET_CASPIAN);
return new Group(kasten,red, yellow, green, stange, halt);
}

@Override
public void start(Stage primaryStage) {
Scene Streets = new Scene(Ampel(), 480, 360, Color.WHITE);
primaryStage.setTitle("willkommen in den Straßen");
primaryStage.setScene(Streets);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}

}

>GNU
>a place notorious for their elitist manchildren and chronically female attention dependant neckbeards.

...

Finally I have made an IO-less programming language. I call it "nio", short for "no io"
Each nio program consists of a single statement, either true or false.
true indicating the program terminates, and false indicating that it doesn't terminate.
So far the compiler only outputs C code and doesn't automatically call the C compiler yet.

Compiler source code here:
use std::fs::File;
use std::io::{Read, Write};
use std::process::exit;

fn main() {
let args: Vec = std::env::args().collect();

if args.len() < 2 {
println!("Expected filename");
exit(1);
}

let file = match File::open(&args[1]) {
Ok(file) => file,

Err(e) => {
println!("Unable to open source file: {}", e);
exit(1);
}
};

let src: String = file.bytes().filter_map(|b| b.ok().map(|b| b as char)).take_while(|c| !c.is_whitespace()).collect();

compile(&src);
}

fn compile(src: &str) {
let program = match src {
"true" => true,
"false" => false,
_ => {
println!("Parse error: expected either a `true` program or a `false` program");
exit(1);
}
};

let mut out = match File::create("out.c") {
Ok(file) => file,

Err(e) => {
println!("Failed to open out.c for writing: {}", e);
exit(1);
}
};

out.write_all(b"int main() {\n").unwrap();

match program {
true => out.write_all(b"\treturn 0;\n").unwrap(),
false => out.write_all(b"\twhile (1);\n").unwrap(),
}

out.write_all(b"}\n").unwrap();
}

An example of a nio program:
[@arch ioless]$ cat main.nio
true
[@arch ioless]$ ./target/debug/ioless main.nio
[@arch ioless]$ cat out.c
int main() {
return 0;
}
[@arch ioless]$ gcc out.c
[@arch ioless]$ ./a.out
[@arch ioless]$

>"\treturn 0;\n"
that's output right there

also, technically,
hardcoding is input too.

1. The Result type has two Variants, i.e. enum Result {
Ok(T),
Err(E),
}
Normally, you would have to write Result::Ok(foo), however both Result::Ok and Result::Err are imported by default by the prelude(doc.rust-lang.org/std/prelude/) so you can just write Ok(foo) and Err(foo).
In case you haven't read it yet, the chapter on error handling is pretty good: doc.rust-lang.org/book/error-handling.html
2. Result and Option are error types that wrap the value of a computation in Ok(val) or Some(val) on success or return a Err(err_val) or None on failure. To handle these you would usually do some pattern-matching. However, if you don't care about error handling (e.g. when prototyping), you can call .unwrap() and get the contained value and simply panic!() in case of failure. Obviously, when writing a library, you shouldn't have any .unwrap() in it.
3. Looking at the source code of stdin(), it does some initialization under the hood: doc.rust-lang.org/src/std/io/stdio.rs.html#205-219

I have no idea what exactly is happening, though

Yeah, that line is pretty questionable, but it's just an implementation detail really.
The actual language itself has no concept of IO.
I've just simplified the language down while still keeping all the functionality of an IO-less language, that's why they're such simple single-word programs.

Trash.

No shit.

>Lazy
Rust was a mistake.

What's the matter, can't handle generics?

I see nothing wrong there, m8

i wonder what the next language to top Rust's meme status will look like.

>start high level CS class for my major
>work more than 3/4's of the semester on developing a specific compiler for x programming language
>the assignments are fun and interesting to figure out
>last 1/4 of the semester professor completely drops finishing the compiler and gives us guidelines to make our own game in java
>can't understand how to make anything in java with graphics, don't find this interesting or fun at all, can't even figure out simple math for rotating players, bullet trajectory, or object collision detection

WHY THE CLASS WAS SO FUN WHEN WE WERE DOING PRACTICAL SHIT I FUCKING HATE MAKING GAMES AND ESPECIALLY IN JAVA

this shit will literally make me fail this class when i had a 100% before starting it.

1. So, Ok(fn_returned_value) will generate Result that can either be of or ?

2. unwrap() checks if the fn_returned_value is of type and panics if it isn't?

Am I wrong?

See Jai