[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 30
File: timetocode.webm (2 MB, 1152x648) Image search: [Google]
timetocode.webm
2 MB, 1152x648
This is /dpt/, the best subreddit of /g/

Umaru-chan edition, the best of all editions.

In this thread:
r/programming
r/compsci
r/ReverseEngineering
r/softwaredevelopment

code of conduct:
no racism
no insult
no sexual harassment
no gender discrimination

wat r u working on, anon-chan ?
>>
Daily reminder that if your language of choice is not on this list you should probably give up and kill yourself:
- C++
- C#
- Lua
- Python
- Elixir
- Haskell
- Bash
- Clojure
- D
>>
>>52103864
First lads lmfao
>>
A cropped image finder.
Working like shit so far.
>>
>>52103864
first for C#
>>
File: opcodes.jpg (60 KB, 529x417) Image search: [Google]
opcodes.jpg
60 KB, 529x417
>>52103864
first for virtual machine implementations

you can't tell me there's a hotter meme on the market than this
>>
Threadly reminder, if you can't write A* in C you aren't a real programmer.
>>
>>52103884
>posting languages with wildly different domains
>why
>>
>>52103834
>you can't do much better than this with just char-aligned text
You could if you used bresenhams lad
>>
>>52103900
What's an A*?
>>
>>52103923
It's a meme desu
>>
>>52103915
Why am I C++-illiterate?
>>
>>52103923
It's a graph search/pathfinding algorithm.
>>
File: fe.png (45 KB, 1152x1148) Image search: [Google]
fe.png
45 KB, 1152x1148
>>52103852
>>52103852
>>52103852

See what I mean, anon. Shouldn't these be the same length?
>>
>>52103957
So a meme then?
>>
If you call a virtual method from the base destructor, it will call the derived implementation.
>>
>>52103984
It's not a meme, it's quite useful especially in tile-based games when you're coding pathfinding for NPCs and monsters.
>>
>>52103978
the faggot is using expensive trigonometric functions, there is no saving him
>>
>>52103992
Thanks, anon. I was just about to ask about this.

NOT

haha nerd
>>
>>52104010
I'm telling the guy who's claiming people don't know C++ when he can't even figure out a solution to his problem that he's a retard.
>>
>>52104003
So a meme then?
>>
>>52103992
no, it will not
>>
File: 1451148605227.png (303 KB, 405x692) Image search: [Google]
1451148605227.png
303 KB, 405x692
>not using the comfiest language

>>52104003
>games
So a meme then?
>>
>>52104030
you're life a meme
>>
>>52104030
You're a meme.
>>
>>52104003
>using games as an example
>not traffic routing algorithms
/agdg/ is that way >>>>>>>>>>
>>
>>52103884
Daily reminder not to trust the mememeister.
If your language of choice is not on the following list, you should probably breathe helium:
- ATS
- OCaml
- Bash
- That's it, folks.
>>
Can someone collate the the number of posts with the word "meme" in them in /dpt/ threads for one week using a language of their choice, and with that information, calculate how many years it'd take for the chance of not seeing the shitty word to reach at least 50%?
>>
>>52104047
>>52104049
All around me are familiar memes
Worn out places, worn out memes
>>
File: what_the_fuck_shatner.gif (1 MB, 170x180) Image search: [Google]
what_the_fuck_shatner.gif
1 MB, 170x180
>>52103893
why adding a level of indirection and not just

{ 0: Halt,
1: Set,
...


(•_• ?)
>>
>>52103978
>what is geometry
no because i'm calculating the points of the circle to sub-pixel accuracy.
>>
>>52104087
aw shit

you just gave me an idea anan
>>
>>52104076
fite me nerd
>>
File: 1448940022844.jpg (42 KB, 512x288) Image search: [Google]
1448940022844.jpg
42 KB, 512x288
>>52104083
>ATS
>>
>>52104007
yeah i really should have approximated it with integers for performance reasons... idiot
>>
>>52104097
>>52103893
In fact he could just do
[ Halt,
Set,
....
>>
>>52104097
what the fuck shatner indeed

how will it call those functions?
>>
>>52104087
Daily reminder to not do that unless your language of choice is on this list >>52103884
>>
>>52104098
I know you're autistic and it's hard for you to take criticism, but anon, listen to me, the circles should all be the exact same.
>>
>>52104131
>I'm using lambdas without understanding eta reduction
Alternatively
>my language is too shit for eta reduction
>>
I'm about to do something no one has ever attempted: implement BFS in C++.
Watch out, I ain't joking around here.
>>
>>52104125
You should have approximated it with integers also because it'd actually look like circles you absolute poop
>>
>>52103893
Can't
lambda x, y : Set(x,y)
be replaced with just Set? Functions are objects you know?
>>
>>52104131
def a(x, y):
print(x, y)

def b(x):
print(x)

lookup = {
0: a,
1: b,
}

lookup.get(0)(5, 10)
lookup.get(1)(5)


>>52104130
Nah since the opcodes don't always have to go sequentially.
>>
Rethinking my package/struct naming. The package name is called config and the variable name is called config too. So
config.ExportedVar
results in an error. REEEEEEEEEEEEEEEEEEE
I hate making up names.
    config, err := config.New(file)
>>
>>52104143
I've never really studied lambdas, but I've just tried it and it works in python

Holy shit, I feel so alive

>>52104161
Thanks to you as well
>>
>>52104139
no they shouldn't you fucking assburger, your circles won't be positioned correctly

why don't you do it yourself them mr. know it all

>>52104146
it looks fine. you're clearly just jealous because you couldn't figure it out yourself.
>>
>>52104136
I'm going to do something like it and my language is on that list.
>>
>>52103900
Come back when you can write it in APL :^)
>>
>>52104161
 [opcode1, opcode2, None, None, opcode5] 

You're welcome.
>>
>>52104179
>jealous
nigga I implemented bresenham's in Java fucking 4 years ago in uni and it was simple as shit then, and they actually look like circles lmfao the fucking people ITT
>>
>>52103864
>code of conduct:
>no racism
>no insult
>no sexual harassment
>no gender discrimination
oh boy, I'm triggered
>>
>>52104191
>opcodes jump from e.g. 15 to 70
>just fill in none 55 times anon
>>
>>52104191
why not a tuple then
>>
>>52104191

this, for versatility
>>52104161
>Nah since the opcodes don't always have to go sequentially.

but also because it helps me refer to the opcode being run when I debug

If I read shit like 16 32768 32769, I don't want to go into my instructions file every time just to see 16 refers to WMEM
>>
>>52104204
>tfw OP is an ugly black trans woman
>>
>>52104161
>Nah since the opcodes don't always have to go sequentially.
Why wouldn't they?
>>
>>52104149
yes, although technically the lambda setup specifically only accepts 2 arguments, whereas returning the set function (if that's the intent, I don't think Set is the same as set) would accept an arbitrary number of arguments.

Actually, just looked at the docs. this is all fucked up. You can't give set (or
sets.Set
) multiple arguments; you have to give an iterable, so you'd need to be like

lambda x,y:set([x,y])


but this is all retarded. if you want to ensure that no more than two elements ever get passed to a set constructor, just make the intent of that logic clear.
>>
>>52104255
I don't know, they usually are, but there's no guarantee to a VM design that they have to be.
>>
>>52104255
I'm the guy with the code

The opcodes go sequentially ONLY because it's specified in that particular instruction file, and they are important to refer to exactly because those are the numbers being read from the little-endian 16-bit pairs in the binary file I run the virtual machine on.

If I wanted to make my code portable for similar projects, I can't rely on it always being sequential
>>
File: hellohuman.webm (2 MB, 640x360) Image search: [Google]
hellohuman.webm
2 MB, 640x360
Ask your beloved programming literate anything.
>>
File: assburgers.png (68 KB, 993x1133) Image search: [Google]
assburgers.png
68 KB, 993x1133
>>52104195
kill yourself retard

look at the intersections in this pic, the circles are not aligned because the geometry doesn't add up. kill yourself.
>>
>>52104308
What do you think about this list >>52103884

What would you add? What would you remove?
>>
>>52104290
I see that, but last time you posted them they were function defined by you right above???
>>
>>52104308
I would have jumped off and rode it desu
>>
>>52104312
Kill yourself if you actually think sin and cos functions are going to be more accurate than bresenham's in indicating which parts are filled when it knows which squares it occupies most
>>
>>52104343
i don't even give a shit about rasterizing circles you fucking idiot. you're acting like drawing a fucking circle was the biggest achievement in your life.
>>
anyone know anything about the demoscene or demoing or whatever the fuck like to call it? how do I get started with this
>>
File: lispbest.jpg (253 KB, 840x412) Image search: [Google]
lispbest.jpg
253 KB, 840x412
>>52104332
would keep clojure
>>
>>52103990

Well. What I would have done is created a recursion until out of range.
def makecircle(pixel_x, pixel_y):
#make a circle

degree = 0
for _ in range(6):
new_x = pixel_x + cos(degree)*R
new_y = pixel_y + sin(degree)*R
degree += PI/3
if (abs(new_x) > limit_x or abs(new_y) > limit_y)
continue
makecircle(new_x,new_y)


Of course adding in silent exceptions when the circle goes out of range. But it should just fill up the screen desu. Why leave it at 7 circles? Make it keep going until it finishes.
>>
>>52104336
sorry I'm just a random person who noticed your comment. I only saw the crazy code block with a dictionary pointing integer keys to various operations, and apparently missed the definitions of Set and whatnot.

When python code looks like that, it tends to scream to developers that the person who wrote it lost perspective at some point, but I don't have time to go digging up their intent and helping them reason through it. they should take a big step back and think about this stuff more carefully.

python maximizes how easy it is to just write code, so the barrier to writing code based on faulty or incomplete logic is much lower.
>>
File: wq.jpg (479 KB, 1280x720) Image search: [Google]
wq.jpg
479 KB, 1280x720
>>52104365
I love how butthurt you're getting, anon. It's as if someone is insulting your child.

I can't wait until someone shows us what it's supposed to look like.
>>
>>52104336
we are not the same people, I don't know what he's going on about with sets.Set
>>
>>52104365
lmao can't even meme properly, come back when your circles look like circles fucking idiot
>>
>>52104402
>I can't wait until someone shows us what it's supposed to look like.
you literally can't wait until it happens because no one will ever do it. these fegs can't even draw a golden spiral.
>>
>>52104424
you can't even meme at all because you haven't done neither a golden spiral, tilted swastika nor a flower of life
>>
File: opcodes.jpg (105 KB, 669x681) Image search: [Google]
opcodes.jpg
105 KB, 669x681
Just look at this sexy beast

Yes I kept the autistic indenting

Now to make the bottom block shorter as it's needlessly verbose imo
>>
>>52104445
I'm busy making real programs faggot

fight me I dare you
>>
>>52104527
Happy flow programmer detected. tbqh you should add an else statement senpai.
>>
>>52104545
clearly not busy enough not to be shitposting on 4chins

1v1 fite me lvl 50 wildy no armor
>>
Is "new" in C++ slower than malloc in C?
>>
>>52104527
Wouldn't something like this work:
while pc < len(adds):
data = opcodes.get(adds[pc], None)
if data is None:
print('Unknown opcode, skipping...')
continue

data[0](*adds[pc+1::])
>>
>>52104554
>tbqh you should add an else statement senpai.
Well I've put it under all my other if blocks, printing errors, so will do
>>
>>52104564
They're not comparable. new is malloc + constructor(s).
>>
>>52104183
I'm calling the project MemeChan.
>>
>>52104564
Do you even have to ask?
>>
>>52104564
>is MemeLang++ slower than MemeLang?
Does it even matter?
>>
>>52104568
insI (instruction index) is my name for pc (program counter), and you can't just loop through it, as it can jump all over the place, return from places, or skip a number of 16-bit values based on the opcode called and its arguments
>>
>>52104607
look at this fucking turbo dork. leave this website now
>>
>>52104564
Custom memory manager > *
>>
>>52104616
To clarify what I'm doing a bit more, what is in adds is all of the 16-bit little-endian pairs in the challenge's included binary file. A number between 0 and 21 might not even be an opcode, it might just be a value referenced by another opcode (most commonly 0, as a few opcodes check if a register is equal to 0)

I'll try to post the instruction file:
== Synacor Challenge ==
In this challenge, your job is to use this architecture spec to create a
virtual machine capable of running the included binary. Along the way,
you will find codes; submit these to the challenge website to track
your progress. Good luck!


== architecture ==
- three storage regions
- memory with 15-bit address space storing 16-bit values
- eight registers
- an unbounded stack which holds individual 16-bit values
- all numbers are unsigned integers 0..32767 (15-bit)
- all math is modulo 32768; 32758 + 15 => 5

== binary format ==
- each number is stored as a 16-bit little-endian pair (low byte, high byte)
- numbers 0..32767 mean a literal value
- numbers 32768..32775 instead mean registers 0..7
- numbers 32776..65535 are invalid
- programs are loaded into memory starting at address 0
- address 0 is the first 16-bit value, address 1 is the second 16-bit value, etc

== execution ==
- After an operation is executed, the next instruction to read is immediately after the last argument of the current operation. If a jump was performed, the next operation is instead the exact destination of the jump.
- Encountering a register as an operation argument should be taken as reading from the register or setting into the register as appropriate.

contd
>>
>>52104704
== hints ==
- Start with operations 0, 19, and 21.
- Here's a code for the challenge website: zIgwptBaKabr
- The program "9,32768,32769,4,19,32768" occupies six memory addresses and should:
- Store into register 0 the sum of 4 and the value contained in register 1.
- Output to the terminal the character with the ascii code contained in register 0.

== opcode listing ==
halt: 0
stop execution and terminate the program
set: 1 a b
set register <a> to the value of <b>
push: 2 a
push <a> onto the stack
pop: 3 a
remove the top element from the stack and write it into <a>; empty stack = error
eq: 4 a b c
set <a> to 1 if <b> is equal to <c>; set it to 0 otherwise
gt: 5 a b c
set <a> to 1 if <b> is greater than <c>; set it to 0 otherwise
jmp: 6 a
jump to <a>
jt: 7 a b
if <a> is nonzero, jump to <b>
jf: 8 a b
if <a> is zero, jump to <b>
add: 9 a b c
assign into <a> the sum of <b> and <c> (modulo 32768)
mult: 10 a b c
store into <a> the product of <b> and <c> (modulo 32768)
mod: 11 a b c
store into <a> the remainder of <b> divided by <c>
and: 12 a b c
stores into <a> the bitwise and of <b> and <c>
or: 13 a b c
stores into <a> the bitwise or of <b> and <c>
not: 14 a b
stores 15-bit bitwise inverse of <b> in <a>
rmem: 15 a b
read memory at address <b> and write it to <a>
wmem: 16 a b
write the value from <b> into memory at address <a>
call: 17 a
write the address of the next instruction to the stack and jump to <a>
ret: 18
remove the top element from the stack and jump to it; empty stack = halt
out: 19 a
write the character represented by ascii code <a> to the terminal
in: 20 a
read a character from the terminal and write its ascii code to <a>; it can be assumed that once input starts, it will continue until a newline is encountered; this means that you can safely read whole lines from the keyboard and trust that they will be fully read
noop: 21
no operation
>>
>>52104704
>>52104725
What kind of challenge is this? It's just "write a VM for this architecture".
>>
>>52104560
faggot I'm still in the wildy, fucking fite me

but for real, I admired the golden spiral and especially the tilted swastika in flag
>>
>>52104378
bump
>>
>>52104752
Pretty much. That main part may be simple if you've done it before, but it's my first time with it, and I was stuck for a long time figuring out how to read from the file. I've heard of little-endian and big-endian, but really had to dig to understand what it meant
https://challenge.synacor.com/
>>
Who's Eclipse programing language here?
>>
>>52104798
Nobody I hope
>>
/agdg/ was no help.
How do I compress my game files (art, music, ect.), so no one can mess with them? I have zlib installed, but I don't really know how to use it, could it work?
>>
File: opcodes.jpg (72 KB, 667x701) Image search: [Google]
opcodes.jpg
72 KB, 667x701
>>52104787
Also when your vm implementation is successful, it turns that 59kb file into an adventure game, with inventory, room state, puzzle state, item state and exploration functionality.
>>
>>52104892
That's security through obscurity. In the end people will find a way to extract your game data if they really want to no matter how hard you protect it.
>>
>>52104925
Isn't encryption basically security through obscurity?

By your logic we shouldn't be using encryption.
>>
>>52104925
So I should just have all my art available for them to fuck around with? Let them edit their save files as they please? I don't know any other games that do that.
>>
>>52104892
You shouldn't compress assets for the sake of security.
If you're anal about gaymers stealing your assets, encrypt them en decrypt at runtime.
>>
>>52104982
Plenty of games use compression for, well, compression, but it's pretty easy to modify things, yeah.

Why would you want to stop modders? Save files don't matter.
>>
File: opcodes.jpg (97 KB, 665x699) Image search: [Google]
opcodes.jpg
97 KB, 665x699
>>52104905
The entire game works on just those 22 op codes and opening the binary file will only show the text before the self-test finishes, meaning a lot of data was manipulated to the ascii values of those letters. I thought that was pretty tight
>>
>>52104892
rtfm
>>
>>52104975
The problem is that to decrypt the files on the client side he'd have to supply the private key in which case yes encryption is security through obscurity if you're going to "hide" the private key.

>>52104982
These games usually have some sort of proprietary binary format but as I said, it can be easily reversed if you know what you're doing, so people will find a way sooner or later if there's a demand. Sure you can pack them up into your binary format, you can scramble the data, then unscramble it on load, but these procedures for extracting and unscrambling are all imbued into the binary, someone with intermediate skill in reverse engineering could hack it in no time.
>>
>>52103864
i like her, who is she?
>>
>>52105061
Umaru and she's an annoying cunt, do not watch that shit show.
>>
>>52104975
With encryption you typically don't give away your key to everyone; that would make it worthless. In the case of a game the player needs the key so the encryption becomes moot.
>>
>>52104975
>Isn't encryption basically security through obscurity?
No, 'security by obscurity' refers to keeping the design secret (i.e implementation details, which algorithm was used, etc).
Encryption is 'security by design' meaning it's only the key which need to be secret, all other details can be in the open.
>>
I'm not sure if this is the right thread, but someone might be able to help me. I'm trying to edit a .db file using a script and I don't know anything about SQL. My question is how can I make it apply several values for title_id, like 2, 5, and 6.

update tbl_t_flag set 
time_unlocked=printf('2015-0%s-%sT%s:%s:%s.00Z',
(abs(random() % 4) + 9),
(abs(random() % 16) + 11) ,
(abs(random() % 10) + 11) ,
(abs(random() % 40) + 11) ,
(abs(random() % 40) + 11) )
where unlocked=0 and title_id=2 ;
>>
>>52105124
You mean something like this:
update tbl_t_flag set 
time_unlocked=printf('2015-0%s-%sT%s:%s:%s.00Z',
(abs(random() % 4) + 9),
(abs(random() % 16) + 11) ,
(abs(random() % 10) + 11) ,
(abs(random() % 40) + 11) ,
(abs(random() % 40) + 11) )
where unlocked=0 and title_id in (2, 5, 6) ;
>>
>>52104982
>Let them edit their save files as they please? I don't know any other games that do that.
Every game which runs locally 'allows' you to do that (or to be in another way: there's nothing anyone can do to prevent someone from modifying local files on their computer).
Encrypting, compressing or scrambling local data with a local key (or a key you retrieve from a server) does nothing - at the end of the day my graphics and audio card need raw, uncompressed data so somewhere in your game asset pipeline this data will be available and I can always alter it at that point.
>>
>>52104760
hehe ty men
>>
>>52105147
Yes, thanks.
>>
Goddamn it, Floens, your code is hard to follow.

Can't figure out how you're parsing out comments into plain text.
>>
>>52105160
That being said, if you're a stubborn fuckwit you can make the process so painful that nobody bothers.
>>
>>52105098
What if I had a website with my admin control panel on a random page, for example:

example.com/sd231jZX321DmemeFSDEOIRJK23admin.php

Would that be security through obscurity? Or is the page classed as a key?
>>
>>52103864
>no racism
>no insult
>no sexual harassment
>no gender discrimination
It's like it's reddit and not 4chan.
>>
>>52105215
The admin page will use an authentication system on the server side where the end user doesn't have the authentication procedures done on their side (they just supply a username and a password) so it's not really comparable. Unless you mean the admin page wouldn't use any authentication whatsoever and just rely on the random link, then yes.
>>
>>52105252
>Unless you mean the admin page wouldn't use any authentication whatsoever and just rely on the random link, then yes.
Yeah, that's what I meant.

And how is it different to encryption? The only way someone will find it is if they brute force it or I give them the key. If that is security through obscurity encryption is too.
>>
>>52105310
publicly accessible webpages can be found
>>
File: opcodes.jpg (99 KB, 669x569) Image search: [Google]
opcodes.jpg
99 KB, 669x569
>>52104527
We did it lads. Only toyed around with the concept of *args in a few toy programs, so no idea it would work in this instance, even for a function requiring no arguments
>>
>>52105346
So can keys, by brute forcing.
>>
>>52105378
>brute forcing
Something that could potentially take years, or more, depending on the hardware.

The consideration being that brute-forcing is irrelevant at a certain level of encryption.
>>
>>52105378
Not if it's a one-time pad.
>>
Can /dpt/ average two ints in C?
>>
>>52105408
Does this not also apply to a sufficiently obscure program?
>>
>>52105464
We already did. Go away.
>>
>>52105408
Try millenia or more.
>>
>>52105408
>Something that could potentially take years, or more, depending on the hardware.
It would be the exact same with my webpage example.

>>52105412
One-time pad encryption can be brute forced.
>>
>>52105529
>One-time pad encryption can be brute forced.
I laughed. Good joke, 4/10 because people thought you were serious for a while.
>>
I want to learn Python, but every recommended tutorial uses Python 2. I'm about halfway through LPTHW. Do I just continue with 2 and learn the differences with 3 after?
>>
>>52105560
>python 3
Completely different, and the meme (read: shitty) version of python 2
>>
>>52105548
takes a long time != impossible
>>
>>52105215
>>52105529
You should consider whether allowing access to your source code gives an attacker and easy way to crack your site. With encryption, the attacker will need to spend years brute forcing your password even if he accesses your source code and database of passwords. With a hidden link, he simply goes to the URL.
>>
>>52105579
>the meme (read: shitty) version of python 2

Rude.

t. van Rossum
>>
>>52105529
>One-time pad encryption can be brute forced.
Nah, they key is the same length as the data so you don't even have anything to bruteforce 'towards', how would you ever know you got the correct key?
A one-time-pad encrypted file is essentially pure random data, there's zero information to be gained at any step of the brute forcing process.
>>
>>52105615
0/10, there's no point in trying to pursue it when you're found out.
>>
How do I start systems programming?
Would LFS be a good start? Can I LFS a raspberry pi 0?
>>
>>52105638
>how would you ever know you got the correct key?

It doesn't return gibberish.

You try a, then, b, then c, and you keep going for infinity until it returns something that isn't gibberish. That's what brute forcing is.
>>
>>52105638
In particular, there is no way to know if the value you're trying for the key is really the key or the message: hello ^ dogs ^ hello = dogs; hello ^ dogs ^ dogs = hello.
>>
1) What do you think about React.js? Is it gay like Angular?

2)I'm making simple startpage for my browser but how do I make something like that default "speed dial" you get on Chrome for example?(the square fields that auto add websites you recently visited).
Basically I need to know how to extract links from history and add them to my custom page?.
>>
File: anime avatar pics.jpg (28 KB, 562x375) Image search: [Google]
anime avatar pics.jpg
28 KB, 562x375
Friendly reminder that if you github avatar is anything but the default or a selfie of you, you're not getting the job.
>>
>>52105492
I'm calling bullshit
>>
>>52105776
1) JavaScript in general is gay.
2) You're gay.
>>
>>52105778
>1/3
bit generous imhof (in my honest opinion franku)
>>
>>52105778
>tfw fluttershy avatar
>>
>>52105776
>Angular
>gay
let's beat 'im up lads
>>
>>52105789
Look at the archives.
>>
>>52105729
>It doesn't return gibberish

You have no way of knowing the ``non-gibberish'' you generated is the encrypted message. Similarly, what if the message was doubly encrypted?
>>
>>52105310
Links get stored in browser history, bookmarks, and possibly by the OS. If the page itself contains any off-site links (a-href, img-src, link-rel, script-src, etc), accessing the link will leak the URL via the Referrer: header. URLs may get leaked via browser extensions.

URLs aren't generally considered to be as "sensitive" as HTTP authentication credentials (and to a lesser extent, cookies), and their handling reflects that.
>>
>>52105729
>It doesn't return gibberish.
>You try a, then, b, then c, and you keep going for infinity until it returns something that isn't gibberish.
There's no way to define 'not gibberish' for pure random data.
Lets say you got the 5 encrypted characters "y80kj" to "hello" with they key "aftih", how would you know that was the actual message? There are (practically speaking) infinitely many 5 letter words and there's no cryptanalysis which can be done since the key is the same length as the data, so all statistical models go out the window.
>>
File: VfcYNyC.png (119 KB, 813x1873) Image search: [Google]
VfcYNyC.png
119 KB, 813x1873
>>52104087
>>52104183
>>52104574
Soonâ„¢
>>
>>52104402
>>52104426
see, no one is even trying at this point. bresenham's may look slightly better when it comes to each individual circle, but the geometry for the flower of life is such that identical integer-based symmetric circles won't align correctly.
>>
>>52105863
>what if the message was doubly encrypted?
After 100,000 years or so, you try doubly decrypting it.

You try a, then a again, after that you try a, then b again, and so on.
>>
>>52105797
1) yeah...
2)why?
>>
>>52105923
did we ever believe 4chan would devolve/evolve into this?
>>
>>52105464
there are several solutions but this is my favorite

int avg(int a, int b)
{
return b != 0 ? a / 2 + b / 2 + (a % b % 2) : a / 2;
}
>>
>>52105778
Does Gentoo logo count?
>>
Right, it's decided.

Encryption is officially a meme.
>>
>>52105968
missing a half
>>
>>52105968
this is a really shit implementation

stop perpetuating this meme
>>
>>52106003
epic meme

>>52106017
how is it shit? show a better one
>>
>>52105998
what isn't on this general?
>>
>>52105886
It would generally be more than one word.
>>
>>52106029
((a^b)>>1) + a&b
>>
>>52103884
b-but javascript is a valid language
>>
>>52106095
not this meme again
>>
>>52106067
^ and & are undefined for negative integers.
>>
File: ew.png (272 KB, 470x624) Image search: [Google]
ew.png
272 KB, 470x624
What books does /dpt/ recommend?
>>
>>52106067
we want truncation (rounding halves toward zero)
>>
>>52106121
So is >>
>>
>>52106142
It does truncate, but this
>>52106121
>>
File: 2015-12-28_13-28-49.webm (215 KB, 280x372) Image search: [Google]
2015-12-28_13-28-49.webm
215 KB, 280x372
>>52105923
>>52105953
SOON
>>
>>52106135
S I C P
I
C
P
>>
File: 1315907201.92635185.jpg (105 KB, 1280x720) Image search: [Google]
1315907201.92635185.jpg
105 KB, 1280x720
I'm worried that normies will steal our calling everything a meme meme.
>>
>>52106067
1~0^0>>1 = 01~0 + 1~0&0=0 = MAX_INT - MAX_INT>>1.
>>
>>52105464
This meme is so goddamn retarded. For pretty much every area where averaging two ints is required a simple a/2+b/2 will suffice.
>>
>>52106039
It doesn't matter how many words you have when key length = key data.
Normally you could do statistical analysis when keylen < datalen because it's likely you have to correct key if you get sensible English text out (since there are comparatively few keys that would give legible text given the problem space)
But when keylen >= datalen you could make ANY sensible English text out of essentially any key you want.

1000 character long encrypted text XOR 1000 character long key = any text you want by picking a suitable key.
So what exactly are you brute forcing, what is the test that will stop you trying new keys?
You would have to already know the entire plaintext, in which case there's no need to brute force anything.
>>
>>52106198
>consistently 1 or 1.5 away from the answer
>>
>>52106155
>It does truncate
http://ideone.com/wCzOpI
>>
>>52106121
No they aren't.
>>
>>52106175
The devs should make the .deadlink elements display as normal text tbqh.
>>
>>52106233
Or you could wrap that in the code tag.
>>
File: uui9.png (481 KB, 626x988) Image search: [Google]
uui9.png
481 KB, 626x988
>>52106161
What non-meme books does /g/ recommend?
>>
>>52106228
Not him, I think he's saying they have undefined behavior for negative numbers, which is true. They return the wrong answers because of how negative numbers are stored in bits
>>
>>52106247
1~0^0>>1 = 01~0 + 1~0&0=0 = MAX_INT - MAX_INT>>1.


Still the same problem senpai. The devs aren't very smart.
>>
>>52106255
C11 Standard

We need someone who can solve this averaging dilemma
>>
>>52106255
your entire existence is a meme
>>
>>52103864
>animcuck
>>
>>52106267
That would be implementation defined behavior, not undefined.
>>
>>52106255
Real-world OCaml.
>>
>>52106319
the behavior isn't defined you absolute meme
>>
>>52105968
I'm very new to programming so please correct/disregard me if I'm wrong or misunderstood the question.

But wouldn't it be better to just cast it as int to begin with? That way it'd be truncated and no need for long fancy code. Like this:

int avg(int a, int b) {
return (int) (a+b) / 2;
}
>>
>>52106281
.prettyprint .deadlink {
text-decoration: none !important;
}


There you go, devs.

Put this in 4chan's CSS.
>>
File: Untitled.png (5 KB, 503x164) Image search: [Google]
Untitled.png
5 KB, 503x164
>>52106281
LGTM
>>
>>52106350
>I'm very new to programming
The first thing you need to realize about programming is that the majority of time is spent debugging things you didn't realize were causing issues

>a+b
What if a and b were the maximum values you can store in an int?
>>
>>52106343
>>52106319
>>52106267
The implementation is implementation defined. The actual behaviour isn't. It's still the same combination of bitwise operations.


>>52106350
Averaging two integers isn't as easy as (a+b)/2
>>
>>52106350
the problem is that (a+b) might be too large to fit in an int. the max is 2^31-1 (2147483647) for a 32-bit twos-complement signed integer.
>>
>>52106384
You're using custom CSS.
>>
>>52106363
Fuck, it worked lad

I don't know anything about CSS, but what do I add to get these fancy colours?:
>>52106384
>>
>>52106428
fuck it, I'd like to change the whole layout, try something new, if you're open to posting the whole custom css you have
>>
>>52106387
>What if a and b were the maximum values you can store in an int?
I hadn't thought of that. Would it be possible to get around that issue by using base 2 instead?
>>
>>52106363
Ideally though, they should sort it out on the back-end.

Using CSS to fix it is a hacky solution.
>>
>>52106343
Yes it is.
The implementation has to specify a consistent choice and document it (for example the size of int, it's not undefined behavior to store 0x10001 in an int on a platform with a 32 bit int)
Undefined behavior in C is where the standard imposes no restrictions and are considered an erroneous program.
>>
>>52105968
This seems to actually be incorrect as it averages MAX_INT and MAX_INT as MAX_INT - 1.
>>
Seriously, just use the bitwise trick

Test it here:
https://ideone.com/PHPqU0
>>
>>52106487
Actually it's worse than that. For a lot of values, it is 1 off, including MAX_INT and MAX_INT, MAX_INT/2 and MAX_INT/2, 3 and 4, and more.
>>
File: 1437947762287.png (34 KB, 809x808) Image search: [Google]
1437947762287.png
34 KB, 809x808
>>52106487
well fuck
>>
>>52106503
Negative values you KEK
>>
>>52106525
Yes, it works for negative values without over/under flow.
>>
You could just average 2 ints in python. No overflow and it's ALWAYS accurate (except when it truncates negative numbers down, but you can just do +1 if it would otherwise be a 0.5)
>>
>>52106539
except it's about 100 times slower
>>
>>52106539
>>52106551
and it's in python
>>
>>52106551
well it would lessen our memeing by 100 times

>>52106556
he implied that you bully
>>
>>52106534
No it fucking doesn't you fucking inbred, holy fuck you're retarded!
>>
File: 5kZAnuQ.png (41 KB, 778x1881) Image search: [Google]
5kZAnuQ.png
41 KB, 778x1881
>>52103864
>>52104087

ATTENTION

'meme' is the 6th most-used word in this goddamn thread
>>
>>52106577
top kek

meme
>>
>>52106577
Meme meme meme meme meme!
Meme about meme? Is it meme yet? Or meme it first?
>>
File: 1412501174344.jpg (18 KB, 240x251) Image search: [Google]
1412501174344.jpg
18 KB, 240x251
>>52106577
>MAX_INT
>>
Just scrolling through this thread and the only programming we did was my virtual machine implementation code refinement, meme flower of life, some dude's database script issue and memechan, and half of these are meme-related

meme meme meme meme meme
let's make it number 1 lads
>>
>>52106572
Give two numbers for which it doesn't work.
>>
File: wJ72QX3.png (10 KB, 715x204) Image search: [Google]
wJ72QX3.png
10 KB, 715x204
>>52106577
Also, here's the wad of LINQ BABE used to grab everything out of the thread
>>
>>52106577
Can you concat these words into a single sentence and post it here? Thx.
>>
>>52106029
i prefer literate-kun version
>>
>>52106637
jesus christ, that's sexy, but also intimidating with all of those dot operators
>>
>>52106635
MIN_INT and 0
Or in general, LITERALLY ANY 2 NUMBERS such that one is on one < 0 and the other is >= 0.
>>
File: QPc5lCl.png (13 KB, 291x654) Image search: [Google]
QPc5lCl.png
13 KB, 291x654
>>52106595
>>52106597
>>52106627
it's happening

>>52106642
it'd be too long
>>
>>52106637
If only you'd programmed that in F#, you could use the query workflow computation expression and they'd be actual keywords without chaining all those dots and needing all those parentheses.
>>
>>52106681
I like my dot operators.

It's like a string of anal beads just waiting for anus.
>>
that is incredible, thanks for posting it in this thread, without that we may not have known tru peace in this world

that we are able to view such beauty is a testament to this board's success
>>
>>52106668
>it'd be too long
Pastebin?
>>
>>52106665
https://ideone.com/ESuIBx

Average of (-2147483648) and (0) is [-1073741824]
>>
>>52106668
You can post it as an image, baka.
>>
>>52106710
this post is meant to link to this post:
>>52106668
showing the info that describes the number of times we've posted words like this or that
>>
>>52106720
>Average of (-2147483648) and (2147483647) is [-1]
should be 0
>>
>>52106720
(edit/fork & change INT_MAX back to 0)
>>
>>52106039
> what is example
>>
>>52106577
>JUST
>>
>>52106751
Nope.
Rounds down every time because it's consistent.
>>
>>52106551
but it is correct
>>
File: tEJgJ7f.png (187 KB, 1918x996) Image search: [Google]
tEJgJ7f.png
187 KB, 1918x996
>>52106716
>>52106723
http://pastebin.com/1Vxujsg9
>>
>>52106751
>>52106778
In case you missed that:
https://www.google.co.uk/search?q=(-2147483648+%2B+2147483647)+%2F+2
>>
>>52106720
It isn't at fucking all you fucking tard, it gives MIN_INT >> 1. I fucking tried it.
>>
>>52106795

if you average a number with 0 you get half of the original number

INT_MIN >> 1
>>
>>52106790
>string beads waiting anus, all the way at the end
at least this general isn't that gay
>>
>>52106822
MIN_INT >> 1 is near MAX_INT YOU FUCKING CHEESE FOR BRAIN!!!!!!!!!!!!!!!!!!!!!!!
>>
>>52106778
>>52106793
the most commonly desired result for this meme is truncation (halves rounted toward zero) just like with integer division. the difficulty of achieving this result is why this meme is still alive to this day.
>>
>>52106789
you can use GMP in C. part of the challenge is doing it with plain ints only.
>>
>>52106858
Why would you want to round towards 0 rather than round in a consistent direction? (like in maths)
>>
>>52106846
what ?
>>
>>52105886
>>52106209
You would have to find every single possibility and see which one made the most sense.

Difficult, but not impossible.
>>
>>52106846
right shift usually fills the gap with the 32nd bit when it comes to signed ints. it's why java has both >> and >>> (fills with zero).
Thread replies: 255
Thread images: 30

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.