/dpt/ - Daily Programming Thread

What are you working on Sup Forums?


Previous Thread:

Other urls found in this thread:

zorinaq.com/papers/shellcode-amd64.html
en.wikipedia.org/wiki/Design_Patterns
twitter.com/NSFWRedditVideo

first for zig

Still working on my C messageboard.

Usernames and tripcodes are coming, as soon as I rewrite my query search functions, because apparently, I never needed to take empty fields before.

Should I read the original SICP and learn LISP (which I don't know at all) or get the Python version, which I know quite well?

how to make python requests faster ?

i have more than 500 twitter links , and checking one by one takes a long time
r = requests.get(link)
if r.status_code != 404:
do_stuff(link)

really?
I wanted to write a a function that filters all chars found in string1 from string2
my thought was to write one function that filters just one char from a string, and then use that function to help me on my main goal
is it really that bad to create local functions?

Share source code.
Make it concurrent/multithread.

Scheme Lisp is more learning how to think than it is learning the language itself. Don't know about the differences though.

Just put it in a for loop.
You don't even need incrementer variables, just make a copy of the char pointer and increment it with *++c.
It'll stop by itself if it's null-terminated.

I'm not using this until it's freely open sourced under an FSF-approved licence.

How to think in what sense?

You don't have to beg.
I always GPL my software.

It's not feature complete yet.

im not in the pointers chapter yet
but pls, post a code that does what you suggest
I'm interested

>It's not feature complete yet.
Neither all the software created ever.

asyncio

or spawn new process for each request, lol

What's the best books to learn computer programming? Do I start with C, C++ or Game maker?

I want to self teach myself because at college they are teaching visual basic which I've heard is terrible and useless.

start with python, upgrade to c

read SICP

...

On a phone or buy the book?

audio book

static void query_deplus(char *str)
{
do
if (*str == '+') *str = ' ';
while (*++str);
}

This works because of operator precedence.
The indirection operator * is pretty low on the totem pole, so if you wanted to increment the data at the memory location *str, you'd have to do (*str)++

>RWX memory
absolutely disgusting

Serious?

...

>C for web

Why are people retarded?

.

>C is literally all about cluttering the source code and shitting up the namespace. Why would you write C and try to avoid those things?
That should only be happening where the main function is, libraries should be pretty self contained.

Use the proper tool: Golang

Everything is C under the hood anyway you idiot

i would say he shouldn't have a moustache, but then he'd probably look even worse

Solved your puzzle op

2f62696e2f2f7368 = /bin//sh
syscall 0x3b = execve

execve("/bin//sh", ["/bin//sh", NULL], NULL)

Also found it on google later on heh
zorinaq.com/papers/shellcode-amd64.html

Linear capability used to distinguish between unique and shared borrows.
mut : Region → Prop
Copyable reference, i.e. a pointer guaranteed to point to a value.
Ref : Type → Region → !Type
Can be used on any reference.
read : ∀A p ⇒ {Ref A p | ―!mut p} → A
Can only be used on a uniquely borrowed reference.
write : ∀A p ⇒ {Ref A p | mut p} → A → {() | mut p}
A uniquely borrowed reference can temporarily be used as a shared reference.

Example of borrowing from an owned box.
Box : Type → Type
borrow : ∀A B ⇒ Box A → (∀p ⇒ {Ref A p | mut p} → B) → Box A × B

why doesn't this work?
it stays running and using 100% cpu
#include

// supposed to delete all chars found in s2 from s1
void squeeze(char s1[], char s2[]) {
int c,j,k,l; j=0;
for(c = s2[j++]; c!='\0';) {
for(k=l=0; s1[k] != '\0'; k++)
if (s1[k] != c) s1[l++] = s1[k];
s1[l] = '\0';
}
}


int main () {
char str[] = "nigger dicks are so nice, aren't they?";
char f[] = "'?,";
printf("'%s' without chars %s is: ", str, f);
squeeze(str, f);
printf("%s\n", str);
return 0;
}

>for(c = s2[j++]; c!='\0';)
you never alter c in this loop

This is the perfect time for you to learn how to debug. Figure out how to set a breakthrough and step through your code, then do that.

>c = s2[j++]
clearly, c changes to be the th index of j, and j increases
I don't understand

Why not just
while(*str++)
if (*str == '+') *str = ' ';
And your code doesn't really filter.
Something like
char *p = str;
do {
*p = *str;
if (*str != '+')
p++;
} while (*++str);
*p = '\0';
should work.

That only initializes c

but j changes, and so does c
are you a troll?

You need to change your attitude or you're not going to make it, real talk.

You are very clearly wrong here and he's trying to help you. You've been given more advice than you deserve and your response is to call people trolls?

Kids these days man.

That only initializes c
Relearn for loops faggot

> using enums for exceptions
lol my cats

I already did that, it was omitting the first character of every field value.

this pointer stuff is really confusing
until then, I'm not sure I can understand this stuff

The first statement in a for loop header is only executed once ever.

I'm trying to write a recursive descent parser in C, but there's no literature on this.
All that exists is extremely intangible and ambiguous talk and neat little tree diagrams and maybe some pseudocode if I'm lucky.

What does an abstract syntax tree look like in C, and how do you use it?
If there were some full, complete code for me to look at, I could figure out all of this wishy-washy theoretical bullshit in a matter of minutes, but no, they suffer me lectures on the nature of grammars and how to import parser in python.

wikipedia has a page for that

oh I see, how can I make it to somehting that does nothing

The code before the first semicolon is only executed once, before the loop starts, not on every iteration.

Right, I even did it correctly in my second example, I'm retarded.

sorry

that'll skip the first character

for (; *str; ++str) {
if (*str == '+') {
*str = ' ';
}
}

will do the trick

I'm about to try write a script which saves my terminal history on shutdown, and then omits common commands like "pacman" and "screenfetch" and outputs them to a file so I can revise lesser used commands. then I want it to give a count of the uncommon commands and once it reaches 10 of the same command, automatically add that command to the omit list.

Blog post sorry, anyone got any advice before I get started with this thing?

Which is the best GPU for programming? Nvidia or AMD?

Think of a pointer as a variable that holds a number, and that number is the address to a specific area in memory.
Your computer divides all the bytes in memory and gives each one an address.

Please learn more about how a computer works before you attempt learning C.

array (size=23)
32 =>
array (size=1)
0 => int 12
33 =>
array (size=1)
0 => int 12
31 =>
array (size=1)
0 => int 10
13 =>
array (size=1)
0 => int 10
35 =>
array (size=1)
0 => int 9
24 =>
array (size=1)
0 => int 7
28 =>
array (size=1)
0 => int 6
21 =>
array (size=1)
0 => int 5
27 =>
array (size=1)
0 => int 4
26 =>
array (size=1)
0 => int 4
9 =>
array (size=1)
0 => int 3
3 =>
array (size=1)
0 => int 3
8 =>
array (size=1)
0 => int 3
25 =>
array (size=1)
0 => int 3
11 =>
array (size=1)
0 => int 3
18 =>
array (size=1)
0 => int 2
29 =>
array (size=1)
0 => int 1
7 =>
array (size=1)
0 => int 1
30 =>
array (size=1)
0 => int 1
34 =>
array (size=1)
0 => int 1
37 =>
array (size=1)
0 => int 0
6 =>
array (size=1)
0 => int 0
1 =>
array (size=1)
0 => int 0

How do I find the highest value in this array (in this case 12)? In PHP.

Yes I've read it, but that code shows no implementation details, only the general strategy involving recursion.
Now that I understand that, I have to figure out how to implement things like nextsym() which they left out.

what is the return () of c?

The what?

How do you shutdown? If you normally execute shutdown, then you can just execute a script that does yourprogram; shutdown;
If you shutdown using a DE action, find out what script it's running in that action and modify that to call your program first.
Reading from .bash_history and doing whatever it is you want is trivial.

void function?

im come from haskell
return () does nothing
so im wondering if there's something similar in c

oh im sorry user
haskell gave you brain damage

also, return isn't like the typical return in c family langs
return is just a function that promotes a value to a container
return () promotes () to the container thats being used
and it literally does nothing

is there something like that in c?

haskellfags help me out

C++ is ____________

Yes. Write nothing and it will does nothing. It's magical.

It's cool my man.
for ( ; ; )

happens once, before there's any looping.
is checked at the end of every loop, and quits the loop if it's not met.
happens once at the end of every loop.

Are you trying to not return anything? Sorry I don't haskell, but in that case function type should be void and the return statement is just return;

; does nothing...

Great, thanks for the advice, I normally execute shutdown so that should be pretty simple. I'll make a start to it tonight, hopefully all goes well

>is checked at the end of every loop
You mean beginning.

I wrote that but it doesn't help
im using it in the for loop btw
for (; conditional; step) doesn't work

I'm writing my own C library so my AVR can talk to some other hardware. Free as in freedom libraries already exist, but I want to do it to learn something.
It's not easy.

>doesn't work
Be more descriptive.

wow, nevermind, somehow it didn't work
im sorry

No because

for (int i = 0; i < 5; i++) {
print(i); // prints 0, not 1.

>for (; conditional; step)
This should work, so your problem is elsewhere. You can try it with for(;;) if you don't believe me

literally the best programming language for most applications

conditional is checked at the beginning, step is executed at the end
if conditional was checked at the end, what would following code print?
for (int i = 6; i < 5; i++) {print(i);}

>le C is insecure meme

Why are people retarded?

really weird way for saying "a shitty version of C"

>for(;;);
how come that never terminates

Oh you're right my bad, I'm getting sleepy. For some reason I thought we were talking about the step statement which does happen at the end. Of course you're right about the conditional being checked at the start.

as soon as I switched to linux I stopped wanting to shower, anyone else experience this?

Because it's missing the middle part which is normally the condition at which the loop should terminate. It's equivalent to for (; 1 == 0;) which would also run forever because obviously 1 is never gonna equal zero.

I've been trying to improve my activity on Github for potential employers so I've been submitting pull requests to add a license and code of conduct to projects lacking them. Quite often people start flinging shit at me, refuse my pull requests, and/or block me. For a community about tolerance and code sharing I'm surprised these people are refusing 1) a license so that their code can be shared and 2) a CoC so that people behave themselves when contributing.

the conditional is null which is evaluates to false, which is what the conditional is if you leave that field blank. It's basically like typing while(true);

>default sublime theme
faggot

troll

I have done as much as I could learning Java.
Right now I am just thinking about how I can navigate The Java api better.
For an example:
I want to read a textfile that is a gamefield
I want it to refresh itself everytime I am moving one char in that field
How can I look for these functions in the Java API.
How do I excel in that?
Because I have the feeling all I have to do is mostly try to find the right methods in the java APi and make the rest myself as I code further and try to learn more about java in the tutorials.

Technically isn't a license required so people can fork, modify, and make pull request in the first place? Damn githubbers

thinking functionally was a mistake

Your parents said the same thing about you

But, them, they were right.

Now that you've told everyone about it better stop. No reward to gain from here on out all the praise has already been received.

I was working on a homepage the other day.

I started to redo the way it works, changed several things.

Whatcha think, Sup Forumsuys?

>no reward to gain from here on
what about all the satisfaction when your .hex weighs 54 bytes less?

sorry, I meant that thinking functionally in C was a mistake

It's cute :3

nice functionality baka

i already have SICP and i just bought this on a**zon
en.wikipedia.org/wiki/Design_Patterns