/dpt/ - Daily Programming Thread

fuck off trap fags

prev:

Other urls found in this thread:

youtube.com/watch?v=OrR1TGQY20Y
youtube.com/watch?v=CU5ByOf9eP0
github.com/davexunit/gnumaku
pkgs.racket-lang.org
dthompson.us/pages/software/sly.html
davexunit.itch.io/lisparuga
pastebin.com/YPrZ4jnK
msdn.microsoft.com/en-us/library/xwtb73ad.aspx
stackoverflow.com/a/9903262/6283490
a.pomf.cat/vbrtpq.c
glot.io/snippets/eeufyni56l
eldpack.com/
gnu.org/software/gsl/
pastebin.com/login'
pastebin.com/u/MYNAME',headers={'User-Agent':
twitter.com/SFWRedditVideos

...

music to shitpost to

youtube.com/watch?v=OrR1TGQY20Y

youtube.com/watch?v=CU5ByOf9eP0

>C++

Take the module system problems I described above and augment them with insane compilation times due to template metaprogramming complexity as well as extremely unreliable ABI. Templates are pretty sweet but the language is simply not productive enough for me, especially since the end result is endless linkage pain, even more so than C programs.

It gets to the point where the only sane way to do C++ libraries is to effectively wrap the C++ implementation with a C ABI. Otherwise, you might as well assume everyone is using the exact same compiler and build environment as you.

>Java

I've done a fair share of Java and while it's much nicer nowadays, both in terms of language features and stdlib support, I've come to realize that there are better actual languages available out there to program in. The JVM is solid, Java, not so much. And libraries/classpath are still awkward. Hellish JarInJar loader bugs are something I don't want to run into again.

That's nice, which Scheme? Guile?

I remember Scheme used to have actual papers written about the fragmentation of implementations and the lack of a real standard library and module systems. Standard Schemes simply weren't practical.

Racket seems to have branched off into its own thing. That's probably for the best. Every implementation was an island as far as my understanding goes.

Does it have a lot of libraries? FFI support?

What about Guile? Last time I ran into it was in the context of GNU Makefiles as an extension language. If someone made a game with it, it can't be restricted to just embedded, in-application scripting.

>gnumaku

Well I'm gonna browse his code for a bit. I have more experience now, maybe I can figure out his trick this time

4th for forth

Working with java, can someone explain how to print a string the same amount of times as a value in an array?

So if array[0] = 3, I need to print 3 "X"s in a row and store it in a list as 1 string.

>gnumaku
>check this thing out
>github.com/davexunit/gnumaku
>Latest commit 881836c on May 4, 2014
>on May 4, 2014
>May 4, 2014
>2014
>Sup Forums
>ever finishing a project
>ever

Where do I start with bash scripting?

how do you know it's not already finished

>Does it have a lot of libraries?
They can be found on pkgs.racket-lang.org

>FFI support?
It surely does!

I can't say anything about Guile because I have never used it myself.

try collecting all the files on your desktop and moving them to an archive. then launch your workspace and any programs you want to open

better yet, assign these programs names and ask for which specific ones you want to open

how difficult would it be to make a ping pong in openGL (C / C++)?

It was going to be a full-fledged game, but then he decided to turn it into a library. As far as I can tell he finished what he set out to do and then moved on.

Nothing's ever finished m8

...

It depends on you. Since you're asking here instead of making it, I'm going to guess it will be very difficult.

for you

i just had this idea and thought i would ask /dpt/

not difficult at all if you're talking about pong, it's just some rectangles

For literally any library lol, it really is a lifetime of work

I bet 99% chance he just lost interest, ran out of steam

>what method you used to store the tags

Categorical hypergraph database.

rolling alskdjf;alsjdfa;lj

I couldn't understand why it hurts a lot when you bite your tongue accidentally but it doesn't hurt when you bite it intentionally, and what I couldn't understand most is why you're biting your tongue right now ?!

Has anybody really been far even as decided ?

for (int i = 0; i < array[0]; ++i) {
System.out.print("X");
}

I'm not really sure what you're asking.

>lispy
>guile
>gnu
Instantly dropped.

nvm I figured it out.

in python 3 is there a way to append letters to single list variable?

like lets say I ask the user to input 1 letter at a time. instead of putting it in a list like

list = ['i', 'n', 'p', 'u', 't']

can i just save it like

list = ['input']

list = ['in']
list[0] = list[0] + 'put'

?

??

He made a game engine
dthompson.us/pages/software/sly.html
He recently used it in a recent lisp game jam
davexunit.itch.io/lisparuga

pytards everyone

python is horrible, especially for beginners

>in python 3 is there a way to append letters to single list variable?
yes
"+"

???

Whats the quickest way to set up a windows VM? I have reason to believe that running this could fuck my shit up.

Install VirtualBox, plug in a Windows ISO, and press enter a bunch of times.

Anyone have any clue what this could possibly do? Just got a .js file in the mail that is very similar, sharing quite a few functions, and Im curious what it could do.

It also came with a clearly fake bitcoin wallet .exe, so theres that.
pastebin.com/YPrZ4jnK

Gonna take forever to download a windows iso. Might as well start now.

Is there a difference between these two?

that just adds another item to the list instead of appending it to the first item

Finished a year long piece of work, nothing to do now.

Is this what retirement feels like??

strings are not lists in python, they are strings
+ is the concatenation operator for strings
to add something to the end of a string, use +

In this C++ code msdn.microsoft.com/en-us/library/xwtb73ad.aspx

what is that static int function?
static int smf();

what the fuck is going on in this code?

static int (*array_1[])() = {smf,}; // C2712

never mind I missed the paragraph above "a static array of pointers-to-functions in a __try block."

roll

list[0] += next_letter


What's your intention here anyway?

O shit waddup

i'm making a basic hangman game for practice because I'm still new

so I want to save the secret word into a variable and then save the user's guesses into a list. When the list == variable, it'll tell the user they've won or whatever. But when I use list + userGuess, it just adds another list item instead of adding the guess into the string contained within the first list item. There's probably a better/easier way to do this but I'm still new.

Is this Java???

Looks like C++ to me.

split the word into an array of characters. when a user guesses a letter, see if any of the characters in the "secret word" array are a match for the guess. you can figure out the rest. good luck.

To me too (though I don't know much Java). But why tf would you make an ArrayList class?? a) that's a name from Java and b) there are more than enough array-ish classes out there.

Anyways, yes, when the parameter is non-POD, the behaviour is different using an initialization list. In the second scenario, itemCount is initialized with it's default constructor, then set to be 0... To confirm this, try passing in an object without a default constructor the second way. It won't compile or my name isn't

stackoverflow.com/a/9903262/6283490

nice trips

What is the easiest way to email in C without any external libraries, i.e. Curl.

Why would you program anything in C without using external libraries?

Doesn't really sound like hangman tbf, you might be making things more complicated for yourself that way

Here's a simple one. Definitely could be implemented better, but you get the idea
import string
import sys

word = 'hangman' # you can set word based on user input too
letters = list(string.ascii_lowercase)

# game
guess = [' '] * len(word) # separated, so you can use it for easily displaying
correct_guess = list(word)

while guess != ' ' * correct_guess:
guessed_letter = input("Choose a letter: ")

if guessed_letter not in letters:
print("Letter chosen already.\n")
continue

if guessed_letter in word:
for i in range(len(word)):
if word[i] == guessed_letter:
guess[i] = guessed_letter
print("Correct character chosen.\n")

print("You win. The word was {}".format(word)

It's an array of function pointers being initialized with a pointer to one of the static member functions of the struct S1 using a C++11 initializer list. The definition of smf is missing.

It results in C2712 because that's an initializer list on the right hand side, which has a destructor.

#include
#include

int main ()
{
char *command = "curl --url \"smtps://smtp.gmail.com:465\" --ssl-reqd --mail-from \"[email protected]\" --mail-rcpt [email protected] --upload-file my_fucking_email --user \"[email protected]:password\" --insecure";

system(command);

return(0);
}

Just suck it up and use libcurl. It's not hard.

Oops, was meant for

Oh wait, sys isn't needed.

An alternative to using string for initializing letters is
letters = [chr(ord_letter) for ord_letter in range(ord('a'), ord('z') + 1)]

>mfw working on my Android app
>mfw it was posted on AndroidPolice the other day

Now I can't figure out how to advertise it and shit isn't moving from 150 current installs

Shit you need to add
letters = letters.replace(guess_letter, '')

when you correctly guess a letter

Disregard much of what I'm doing in the program I just have a couple questions.

1. How do I get the array passed from main to the function
2. How do I return a new array "value" back to main?

I know it would be using * and &, but I'm just not sure how to implement it and where they would be placed.

Thank you

>this algorithm and tab space
lad why

Bruh its an assignment forcing us to use c-strings only. It's going to look retarded atm. Besides the point I'm not looking for comments regarding the nature of anything I'm doing.

roll

None of the pastebin sites seem to like my C program.

Pls rate my dumb music program~
unsigned char b[], r1[], r2[];/* run: 'gcc -o pcm pcm.c && ./pcm | aplay' */
main(p,c,m){p=0,c=1;while(1){for(m=0;m2){p=0;c=!c;}}}
a.pomf.cat/vbrtpq.c

ITT we do OOP without classes:
module type StateObj = sig (* interface StateObj { *)
val get : unit -> int (* int get(); *)
val set : int -> unit (* void set(int); *)
end (* } *)

let state x = (* class State implements StateObj { *)
(module (* public State(int x) { this.x = x; } *)
struct
let x = ref x (* private int x; *)
let get () = !x (* public int get() { return x; } *)
let set x' = x := x' (* public void set(int x) { this.x = x; } *)
end : StateObj) (* } *)

let () = (* public static void main(String[] args) { *)
let module X = (val (state 100)) in (* State X = new State(100); *)
X.get () |> string_of_int |> print_endline; (* System.out.println(X.get().toString()); *)
X.set 5; (* X.set(5); *)
X.get () |> string_of_int |> print_endline (* System.out.println(X.get().toString()); } *)

run here: glot.io/snippets/eeufyni56l

ugh. i almost threw up

>tfw so much nofap that this vid is making you sweat

how many hours would you say that you anons program per day?

4-5 when i have time, 1-2 when i dont

Been working on my minecraft clone.

Got some mouse picking action going on, and hooked up some simple left click = turn block to air.

The mouse picking isn't quite fully-featured yet because I don't have a mechanism for knowing which side of a block is picked.

It ended up being more tricky than I thought since I made some poor assumptions about how the scene should recompile after a block is changed.

Basically changes to one chunk didn't affect neighboring chunks so at the boundaries of chunks, when a block was changed to air the sides of its neighbors didn't become visible. So I had to fix some broken code that went unnoticed... maybe I should do unit testing. Yeah I should.


Some of y'all yesterday asked if I have a github for this. Not yet, I would probably want to remove the copyrighted material (the texture file) before I do that. Version control will definitely be important when I start doing optimization though. And unit tests will be important for that too...

i'm a noob so forgive me for the retarded questions but how do you choose what you want to program? For me it's easy because I still need to learn everything, but once you already know all of the fundamentals how do you choose what projects you want to tackle?

About 1-2 at work. Rest of work is spent reading about things I see in job postings so that I can get a better job,.

nice, keep it up.

git?

use this texture pack. Guy gives anyone permission to use it. That one 3ds minecraft clone has it and plenty others.
eldpack.com/

git it up nigga

most of the time, i find something that i need to be more productive in programming in general. like recently i made a tool to scaffold new projects i create and configure all my tooling from one master file. another thing i do is when im out of projects to work on ill just throw around hundreds of shitty ideas, right like 10-15 lines of code for them, and then realize how stupid they are. in the process i usually come up with a better idea like "even _____ would be better than this shit" and stick with it.
also, just try to find something you or your friends might use. if you're into ricing, make a tool for backing up config files or sharing them with friends, for example. if you're on IRC a lot then make a script to generate statistics about how you use it (avg. word length, lines per day, etc.). or say you have a big music collection, make a program to sort your music somehow. things don't have to be elaborate, the most fun projects are those that take a few days to get a working prototype out because you can go back and rewrite them or make them better without much work.
and im not gonna lie, coming up with ideas is still one of the hardest parts of programming because even when i do think of something good, im often too lazy to stick through with it and just keep looking for something else to do

wouldn't mind forking this actually, you should make it open source

Depends on the day. Over the past two days, I spent a total of 16 hours (7.5 yesteday, 8.5 today) writing about 1200+ lines of C and YACC, just to get ASTs working for an assignment.

And no, that is not including breaks. I want to think that that's an accomplishment, but then I remembered that a typical working day is 8 hours.

Unless you have something you need to be doing, just go ahead and fap. There are 0 negative side effects (except if you fap so much you neglect your normal responsibilities), and there are some positive side effects, such as alleviating headaches.

If one wanted to create a matrix in C, which would be the better way?
A multidimensional array.
int matrix[3][3];
// Access (2,2)
matrix[1][1];

or a single dimension array
int matrix[3 * 3];
// Access (2,2)
matrix[1 * 3 + 1];

I think that it wouldn't matter in terms of performance because accessing arrays is simply adding to memory address.

roolling

The first is more literally what a matrix is. People are going to look at you weird if you're only using a single-dimension array for a 3x3 matrix.

What about an arbitrarily large matrix?

ROLL

You mean in a language without classes right? Because OO is just an abstraction. What you're doing is just abstracting as well, they are classes

gnu.org/software/gsl/
gsl_matrx *mat = gsl_matrix_alloc(3,3);
// access (2,2)
*gsl_matrix_ptr(mat, 1,1) = 1.0;

no, it has classes too. this is just using non-OOP language features to implement OOP

Ah sounds fun

I remember a guy in an old /dpt/ thread months ago who used macros in C to closely emulate C++ templates

Success!

import requests
import re
from bs4 import BeautifulSoup

def gettoken(data):
soup=BeautifulSoup(data, 'html.parser')
i=0
for element in soup.find_all(name=True, value=True, type=True):
if i == 2:
print(element['value'])
out=element['value']
i+=1
return(out)

with requests.Session() as c:
url='pastebin.com/login'

headers='Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'

out = c.get(url, headers={ 'User-Agent': headers})
csrf_token_login=gettoken(out.text.replace('\n',''))
submit_hidden='submit_hidden'
user_name='MYNAME'
user_password='MYPASSWORD'
submit='Login'
print(csrf_token_login)

login_data=dict(csrf_token_login=csrf_token_login, submit_hidden=submit_hidden, user_name=user_name, user_password=user_password, submit=submit)
c.post(url, data=login_data, headers={"Referer":url, 'User-Agent': headers})
page=c.get('pastebin.com/u/MYNAME',headers={'User-Agent': headers})
html=page.content
print(html)
file=open('finished.txt','w+')
file.write((str)(html))
file.close()

The better way is to use the "syntactic sugar" of C.

Consider if you're accessing an array as array[y][x]. That works. What about using the first version and array[y*3+x]. What if you get mixed up and write array[x*3+y]?

Granted, the same thing can happen if you mix up the x,y order of array[y][x] for array[x][y]? Both are possible, but I'd wager that the array[y*3+x] form is easier to mix up.

Just use the same dimensions that the matrix has. Don't be a goober.

Does the latest version of python3 handle html parsing well without BeautifulSoup? It should be the default imo

I have no idea, I always use beautifulsoup which works smoothly
Didn't even know python could parse html by default

for reference, the direct translation to class syntax:
(* Strictly unnecessary, since interfaces can be anonymous*)
class type state_obj = object
method get : int
method set : int -> unit
end

class state (x) : state_obj = object
val mutable x = x
method get = x
method set x' = x

Ikaruga?

HTMLParser in python2 (you need beautifulsoup iirc because it truncates past special html symbols beginning in & like £)

html.parser in python3, haven't used it yet