[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
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: 29
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

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

Filesharing and chat: https://volafile.io/r/kUFzLJ

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

wat r u working on, anon-chan ?
>>
1st for python
>>
>>51258434
>wat r u working on, anon-chan ?

A programming language designed for women.
>>
File: Capture.png (34 KB, 817x564) Image search: [Google]
Capture.png
34 KB, 817x564
>>
>>51258434
>wat r u working on, anon-chan ?
A general utility C library for /dpt/
>>
>wat r u working on, anon-chan ?

ur mum :-DDD
>>
>>51258517

Future plans for this library?
>>
just looking at gba.js & IodineGBA
when did writing emulators in JS become feasible?
superstar saga is running at near full speed, in my browser, on my shitty netbook
I'm impressed
>>
>>51258467
>no gender discrimination
please leave!
>>
>>51258641
Designing towards an specific is not discrimination.
>>
>>51258578
benchmarking against c++'s std
>>
Thoughts on gathering various programming resources and putting them in OP?
>>
File: 1431818584216.jpg (14 KB, 372x351) Image search: [Google]
1431818584216.jpg
14 KB, 372x351
>>51258434
>no racism
>no insult
>no sexual harassment
>no gender discrimination
>>
>>51258681
I like it.

another idea - /dpt/ should put together a private git server for community projects
>>
can anyone explain this minint and maxint boundary stuff to me?
>>
File: asd.jpg (25 KB, 480x404) Image search: [Google]
asd.jpg
25 KB, 480x404
>>51258787

oops forgot pic
>>
>>51258799
i would say
2 (because x * 2 must not underflow)
2 (because x * 2 must no overflow)
0 (because division by zero)
>>
>>51258863
0 is not between 2 and 2, dumbo
>>
>>51258863
0 is not between 2 and 2.
Also there is nothing between 2 and 2.
>>
>>51258871
>>51258876
if minvalue is -10 and maxvalue is 10 then lower bound is -5 (-10 / 2) and upper bound is 5 (10 / 2)
what's between -5 and 5 ? 0
>>
>rewriting major component for a project at work
>nearing completion
>one-fifth the amount of code compared the the original mess they created
>clean, elegant, and easily the best code I've ever written in my career
>questioning whether I really want to tell my coworkers

Now that I'm almost done, I have a sick feeling in my stomach about telling my coworkers about it. I know they are going to swoop in and absolutely rape the living shit out of it.

In particular, there are a couple people I'm thinking of whom I fear more than others. One is just plain incompetent. He takes months to finish tasks that should only take a couple days and his code is always buggy as shit. Half of our team's bugs come just from him. The other is someone I call the "complexity queen". She gives long winded speeches about good OO design and always name drops Martin Fowler. She's known for taking perfectly readable code and then exploding it into a dozen classes or even entire sub-projects and then using insane amounts of indirection to try to tie them back together. I say that as someone who isn't even as anti-OOP as the normal /g/ user. She's very stubborn about doing it her way. I can't blame her too much since I'm stubborn about doing it my way. I just wish she took a more pragmatic approach and would ask herself "Is this code really better?" rather than producing an unmaintainable mess and using "But Martin Fowler says..." as an excuse.
>>
>>51258891
you can't just make up two values for min/max
I don't even understand the question, f(x) exists for all values of x (except 0) and all values of y...there is no min/max, apart from infinite and negative infinity
>>
does anyone else feel like they have the power a of god when discovering new libraries/engines/tools?
Like everything that was developed before by impersonal people far away is now right at your fingertips, and with enough time you could build something bigger and better
maybe it's just me though
>>
>>51258799
You're using int so the upper bound should be [Place holder for biggest number you can fit in an int(google it)]
>>51258891
He didn't say -2 also the min value is 1, so no negatives.
>>
>>51258910
wtf dude. the lower bound of x must be minvalue / 2 because f does 2 * x
for example, if min value is -10 then f(-7) would result 2 * -7 which is -14, an underflow.
same for upper bound.

type for answers 2, 2, 0 then check if correct.
>>
>>51258787
>>51258799
This shit is calculus not CS
>>
>>51258978
f does 1 on 2*x, are you blind?
>>
I really need to study math again, haven't seen this shit since I got a 5 on the AP Calc test junior year
>>
>>51258997
i don't care, replace 1 with 2.
>type for answers 2, 2, 0 then check if correct.
>>
>>51258681
No. This isn't a thread for absolute beginners to learn programming.
>>
You stupid inept shits

-2
2
0
>>
>>51258679

What all features of the C++ standard library are you duplicating?
>>
>>51259075
Memes and bloat
>>
>>51258799
0
0
0
>>
File: HntlKcy.jpg (56 KB, 599x607) Image search: [Google]
HntlKcy.jpg
56 KB, 599x607
i have a linked list with the operations

addFirst(element)
addLast(element)
add(position, element)

when add(position, _) where position is higher than the list's length, should an error be throw or the element added as new last element ?
>>
>>51259121
any fraction below 1 will be truncated to zero


for fractions above or equal to one
(1/(2x)) >= 1, hence 1 >= 2x, hence 0.5 >= x
x is an int, so 0.5 would round down to 0

the only answer is 0
>>
>>51259135
Error.
>>
>>51259135
That's entirely up to you. Both options seem valid.
>>
hello friends I would like to build an app (just for practicing/funsies)
any ideas? needs to be relatively simple, preferably string based
>>
>>51259161
>build an app
>preferably string based
???????
>>
>>51259161
>string based
>>
>>51259135
My gut feeling says to throw an error. It's better to be explicit than implicit. If you use implicit behavior to try to avoid errors, it can come back to bite you or the user in surprising ways. Suppose your linked list allows arbitrary access.

LinkedList<String> list = new LinkedList();
int index = 69;
list.add("penis", index);
list.getElementAt(index); // uh-oh


The "add" method succeeded so I might assume that I have a valid element at the index. You were implicit and tried to save me from an error by doing something different. As reasonable as your alternative solution might be, I'm now stand a good chance of having unexpected behavior or a different kind of error later on in the code.
>>
>>51259195
>>51259205
well a game like tetris is object-based
if I wanted to store a book in an app it'd be more based on manipulating strings
yes you'd have to organize it and that sort of thing but it doesn't require fucking around with arrays and update intervals
>>
File: z.png (46 KB, 1143x501) Image search: [Google]
z.png
46 KB, 1143x501
zero is error & both bounds
>>
File: umarusee.jpg (113 KB, 1280x720) Image search: [Google]
umarusee.jpg
113 KB, 1280x720
>>51259161
csv terminal printer.

https://en.wikipedia.org/wiki/Comma-separated_values

example of use

sample.csv
Sex, Age, Name
F, 8, Layla
M, 44, John
M, 28, Barry


csvprinter --columns "Sex,Name" sample.csv

would output
+-------------+
| Sex | Name |
+-------------+
| F| Layla|
| M| John|
| M| Barry|
+--------------


Gambatte, anon.
>>
>>51258915
Ships in the night my brother.
>>
File: mov.png (2 KB, 316x144) Image search: [Google]
mov.png
2 KB, 316x144
currently doing some navigation in runescape, since jagex added some shit to fuck over botters

holy shit a* completely shits on BFS
top number is a*, bottom number is BFS
>>
UNDEFINED BEHAVIOR
>>
>>51259238
This triggered me. It's a great idea for a beginner project, but it brought back some horrible memories. I do work for a company and one of our projects has CSV files for input. The problem is that other fucking retards in our company and many of our clients can't figure out how CSV files work. They always send us total garbage. We had to write our own CSV parser which checks for some really backwards ass errors specific to just their files in order to get them to go through. Apparently, it was unreasonable to ask them to fix their export utility. Our main client is the government. So as the saying goes, "It's good enough for government work".
>>
>>51259300
>>51259238
>CSV
Fucking shit. Use a real serialisation format.
>>
>>51258434
int a = 3, b;
b = ++a + ++a + ++a + ++a + ++a + ++a + ++a + ++a + ++a + ++a + ++a + ++a;


How much is b?
>>
File: 1445511667448.gif (1 MB, 320x180) Image search: [Google]
1445511667448.gif
1 MB, 320x180
>>51259300
>but it brought back some horrible memories
amen
>>
>>51259318
114 normally, but 115 on gcc
or, as >>51259275 says, running this could format your disk.
>>
>>51259238
hmm ok so use comma as deliminator
store them in classes or arrays
then call them at a value or referencing a class
am I understanding this correctly?

>>51259318
we aren't doing this again
fuck off
>>
>>51259318
Don't bring this shit up again.
The answer is undefined and anyone who says otherwise is a fucking idiot.
>>
>>51259338
He didn't even mention the language. This expression is very well defined in java, for instance.
>>
>>51259330
>>51259337
>>51259338

Still there.
>>
why isnt this working? Im getting an unspecified type for the thrown exception. Please help

float calculaterate(int term, int score)

{

float rate = 0;

if (term == 10)

rate = 0.03f;

else if (term == 30)

rate = 0.045f;

if (score >= 800)

return rate - 0.005f;

else if (score >= 700)

return rate;

else if (score >= 300)

return rate + 0.02f;

throw new ArgumentOutOfRangeException();

}
>>
>>51258434
Umaru sucks.
>>
>>51259274
So when I played rs I always wanted to know how to get into creating bots. Fast forward 10 years and now I'm a junior in college cs program. I'm assuming java would be used because from what I remember rs is written in java. Think you could point me in the right direction for a starting point? Honestly haven't dealt with writing scripts to control other pieces of software so that is pretty foreign to me
>>
trying to get back into C++ again
why do i have to use virtual destructors?
is it because only the destructor of the base object is executed if you delete a derived object through a pointer to base object?
>>
>>51259402
Yep.
>>
>>51259398
there's basically two ways
one is to have your program completely external to the target, which means using functions like ReadProcessMemory to retrieve info about the program and then using functions to simulate keyboard/mouse input in order to execute actions
the other is to inject your program directly and have it execute in the targets virtual memory space, reverse engineer the games engine to find functions like MovePlayerToLocation() and then execute these functions with the values you want
the latter method is more robust but requires a FUCKTON of work since reverse engineering is a very complicated and labour heavy process
>>
>>51259415
I haven't really dealt with c++ too much but it's this kind of little shot that turns me off of it, I feel I should know it better though.
>>
>>51259370

pls halp
>>
>>51259437
Hmm, what would something like read process memory return with though? Seems like piecing together incoherent information would be just as weird to handle. And for the latter, java would be needed yes? I'm assuming there are multiple high level languages able to read process me so the former would seem to be pretty universal as far as language confines go
>>
>>51259370
>>51259466
I don't know much about your meme language, but you probably forgot to import/include ArgumentOutOfRangeException or something.
>>
>>51259370
do you have
using System;

if not, add it
>>
Here's an idea for people who need a project: a proper emulator for 16-bit Windows applications. Although users of 32-bit Windows are capable of running 16-bit applications, as an x86 CPU in protected mode is capable of entering a "virtual 8086 mode", the same cannot be said of users of 64-bit Windows, as an x86-64 CPU, once in long mode, stays in long mode. While this restriction doesn't affect too many people, it does affect people who want to play some old games that somehow have yet to be updated to 32-bit mode, and yet also do not run in DosBox, due to being Windows applications.

Since emulating an entire OS can be taxing on a CPU, a proper 16-bit to 64-bit emulator might just-in-time compile real mode 8086 code to x86-64 code, and use the built in Windows system calls. Alternatively, it might act as a proper CPU emulator, providing some sort of trap to 16-bit Windows system calls, and calling the 64-bit system calls instead. In either case, the goal should be to avoid emulating an OS, only the user code.
>>
>>51259506
>Memedows
No thanks.
>>
>>51259470
>what would something like read process memory return with though?
a number of bytes specified by you, its up to you how to interpret these

>Seems like piecing together incoherent information would be just as weird to handle
its a lot easier than the alternative

>And for the latter, java would be needed yes? I'm assuming there are multiple high level languages able to read process
pretty sure java cant do that since it runs in the JVM
i know C# can do it in unsafe mode but you need to import several unsafe functions from the windows API
C++ is probably your best bet
>>
File: a smile for you.jpg (156 KB, 1024x640) Image search: [Google]
a smile for you.jpg
156 KB, 1024x640
>>51259398

You'd want to create a script for a botting client like RuneMate. It's far easier than doing what >>51259437 described, which involves creating your own program to read memory and send input in the first example he described, which I've done for ffxiv.
>>
>>51259161
>>51259238
here a sample csv
http://benchmarksgame.alioth.debian.org/u64q/summarydata.php
>>
>>51259535
>>51259578
Thank you both so much, I honestly think some part of me got into coding because my 10 year old self said botting rs would be cool. Fun to actually get into it now
>>
>>51259506
DOSBox can run Windows 3.1.

If you have programs which use the Win16 API, there's no alternative to either installing a 16-bit version of Windows or writing your own implementation. You can't just "map" Win16 calls to "equivalent" Win32 or Win64 calls.

And there's really no point in using JIT for an 8086/80286 emulator. The fastest 286 systems ran at 25 MHz; even naive interpretation of opcodes could emulate such systems at full speed using a fraction of the available CPU cycles.
>>
File: 3.png (1 MB, 1024x640) Image search: [Google]
3.png
1 MB, 1024x640
>>51259609

RuneScape actually got me into programming.
>>
>>51258904
>one-fifth the amount of code compared the the original mess they created
Well done, you thought of a method they didn't.
Also jerking it over "muh less code" isn't always good, I don't know the code either of you wrote so this may not apply (probably doesn't apply), readability is important.
>>
>>51259614

Wine could translate win32 and win64 calls (i.e. CreateProcess) to equivalent *nix system calls (i.e. fork and exec). Why can one not translate win16 system calls to equivalent win32/win64 calls?
>>
File: 200_s.gif (42 KB, 280x200) Image search: [Google]
200_s.gif
42 KB, 280x200
hello family

what's the best way to sort a json file? let's say i have a json file filled with {"id": integer, "name": char[50]} and i want to sort in lexicographical order by "name" values.

i have large json files (smallest one is 500 MB, largest one is around 15 GB) that i need to sort.

thank you in advance. love you.
>>
>>51259219
Make a Logo app, that's always a fun one.
>>
Why does this feel like such a mess just to keep from going out of bounds?

while(array[i].checkStuff() < 5){
if(i >= total){
i = 0;
}
else{
array[i].doStuff();
if(i+1 == total){
i = 0;
}
else{
++i;
}
}
}


I'm over thinking this shit. I have to be. Is there a cleaner way to operate on array members in a while loop without dicking around with the iterator variable so much?
>>
>>51259639
honestly, i would just parse it into a script langauge of choice, sort it, write it back to the file and call it a day
>>
>>51259639
>thank you in advance

Don't help lazy ungrateful assholes like this.
>>
>>51259639
>>51259659
i should note im using python.

should i just code up some sorting algorithm in data structures 101 like merge sort?
>>
>>51259639

https://en.wikipedia.org/wiki/External_sorting

>>51259659

Problem is he's handling big data. One's approach to sorting has to change somewhat.
>>
>>51259658
It's because you didn't put the braces on a new line
>>
Does anybody have that "roll a project" image?
>>
>>51259732
No. Go away.
>>
>>51258904
Talk to her about good OOP design patterns and the necessity of avoiding anti-patterns like object orgies
>>
File: imnotgunnachangemystyle.gif (1 MB, 720x720) Image search: [Google]
imnotgunnachangemystyle.gif
1 MB, 720x720
>>51259713
>>
>>51259639
>rip the values out and append them to files based on their names (all Ls go into the L file, all Bs go into the B file, etc)
>sort those
>place them in order
>???
>hope you don't have 15gb of As
This is probably a pretty shitty method.
>>
>>51259633
The issue isn't whether you can translate them, just that a translation is likely to be significantly more work than writing Windows 3.1 from scratch.

The main reason to translate (rather than emulate) is for interoperability (e.g. being able to access the PC's native filesystem directly rather than implementing a virtual disk which can only be accessed within the emulator), not because it will reduce the effort.
>>
>>51258467
So Python+JS+Java?
>>
>>51259693
First thing that came to my mind, but you might want to consider sorting it into an avl tree
>>
is there some easy way of retrieveing the address of a memory segment in C++?
i have the asm:
mov ebx, fs:[0x30]

but id rather do it in C++ if possible
>>
>>51259818

I wasn't saying it would take less time to program. If an emulator was all I wanted, I'd just run 32-bit Windows XP inside virtual box and call it a day.

I'm suggesting that such a system would allow applications to run faster (and thus use less power), and possibly fit in with other Win32 applications (as they would be using the Win32 functions for creating graphics, etc...). The point you make about using the actual filesystem might also be relevant.
>>
no racism
no insult
no sexual harassment
no gender discrimination
>>
>>51259849
>"a memory segment"
What?

You can get the PEB through WinAPI functions if that's what you're trying to
>>
>>51259888
register segment*
im new to this stuff and been reading about it for hours, shit's getting mixed up
but alright, thanks
>>
>>51259872
Suck my dick you fucking retarded nigger dyke
>>
>>51259872
>Python, equally shit for everyone
>>
Thank you for including a code of conduct.
>>
>>51259849

https://en.wikipedia.org/wiki/Intel_8086#Segmentation
https://en.wikipedia.org/wiki/X86_memory_segmentation
>>
>>51259639
Convert JSON to CSV
Import CSV into PostgreSQL database
SELECT row_to_json(table) FROM table ORDER BY NAME;
>>
>tfw working with objective c

Someone wake me up.
>>
>>51259979

No, but seriously, if he is dealing with JSON files that are larger than his available memory, he is going to need external sorting.
>>
>>51259639
> 15 GB of id-name pairs
jesus christ how horrifying
>>
>>51259776
design patterns are an anti pattern
>>
is perl still relevant?
>>
>>51260046

No.
>>
>https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52015

>2012
>4.7
>current release of mingw is 4.9.2(or greater)
>still can't use to_string over 3 years later

Why is this allowed?
>>
>>51260066
Yes I didn't really think so, I just finished a second year cs subject where more than half of it was learning perl
and
>cgi
>2015
>>
>tfw you fell for the Ruby on Rails meme
>>
>>51260118
idk about now but it used to be a pretty good meme. Scaffolding method popularized by it was copied everywhere else for example.
>>
>>51260099
You should learn theory in core, and learn languages(aside from intros) in elective and then be able to code algorithms in all of them.

>not having 3 years of experience and a BS for your internship
>>
>>51259860
>windows 3.1 applications
>applications to run faster
>use less power
>fit in with other Win32 applications
>other Win32
>imagining stuff
>>
>>51260188
>>51260188
Thanks mate but I am a double major in maths and stats. I use my electives for computing subjects. It was a pretty fun course though we did a lot of regex and shell tools and wrote some web-scrapers.
>>
Trying to make a cube in opengl, it's gonna be ready in 15 minutes and want to turn it into a cube generator where you can enter values and create your own cube ! Also later I will probably code the ability to use your own textures etc.
>>
>>51260485
edgy
>>
>learn vim basics during summer
>only been using matlab between then and now
>now a course is using java
>forgot all of vim that's not in [hjklo]
great
>>
File: ugly.png (30 KB, 1169x458) Image search: [Google]
ugly.png
30 KB, 1169x458
>>51258434
Are you ready to see some real dirty shit? I am trying to find a way to limit the max quantity of shopping items. Please laugh at my pathetic mind.
if(mysqli_num_rows($res) == 0) {
$query ="INSERT INTO cart (sid,id_item,quantity) VALUES ('".$_SESSION['username']."',".$id.",".$q.")";
}
else {
$query = "UPDATE cart SET quantity=quantity+".$q." WHERE sid='".$_SESSION['username']."' AND id_item=".$id;
}
>>
>>51258726
underrated post,

i'll host a mirror if we work this out
>>
I'm working on a digital piano. It's based on some interesting new tech I stitched together. I got sick of sampled pianos, so I switched to PianoTEQ, but it didn't sound right either, so I've spent the past 5 years creating my own digital piano. It's KIND of physically modeled? KIND of a sampler? Both? Neither?

Features so far:
Kind of infinite round robin
Fully continuous pedaling
Modeled hammer, damper, and pedal action
Extensive sympathetic resonance and body singing engine, including wood and soundboard resonance
Sound mostly synthesized. No need for release samples or velocity layers when fully implemented
Passes entire DPBSD (With bugs)
>>
>>51260747
>>51258726
lel, k tards
>>
Why hasn't anyone made a programming language that just does everything? Every language has so many negatives.
>>
>>51260747
just use https://gitgud.io
or if you aren't a sped, gitlab.com
>>
>>51259693
Sorted Dict + json.dumps
>>
File: standards.png (24 KB, 500x283) Image search: [Google]
standards.png
24 KB, 500x283
>>51260768
>>
>>51260768
>why hasn't anyone made a tool that just does everything? every tool has so many negatives
>>
>>51256449
how can you be this retarded and arrogant

everyone is telling you that what GCC is doing is valid because the code contains undefined behavior

fucking listen, fucking idiot
>>
>>51260768
kekeles
>>
>>51260754
Post it, I'd like to try it out
>>
>>51260607
>java
>vim
Good thing you'll be using eclipse then.
>>
>>51260872
so why gcc is the only one doing that except being retarded ?
>>
>>51260910
>eclipse
pls no
>>
>>51260922
Well you sure as fuck aren't using netbeans.
>>
Working on some weird bit level math.
Question is, if I have two 16-bit numbers and add them together, can a perform a check that the addition was > 0xFFFF, or will the overflow fuck it up???
>>
>>51261107
I assume you're talking about C or C++.
Overflowing a signed integer is undefined behaviour, so it will definitely fuck it up. You want to check that it won't overflow before you actually compute it.
>>
>>51261121
These are unsigned integers we're dealing with. Sorry forgot to mention. Will it still fuck up the check? How would I actually check if it'll overflow? Sorry for the mind-numbingly simple questions, it's the first time I've encountered a problem like this..
>>
>>51261144
>>51261121
Oh and sorry, here's an example of what I'm talking about

    if((Registers.HL.word + Registers.BC.word) > 0xFFFF)
SET_FLAG_BIT(CARRY_BIT);
else
UNSET_FLAG_BIT(CARRY_BIT);
>>
>>51260920
GCC is better than other compilers at optimizing code most of the time
>>
>>51260922
>vim
toppity kek
>>
>>51260513

Well I don't know I really want to be an expert in graphics so I guess you have to start somewhere.
>>
>>51261152
>>51261144
Unsigned overflow will wrap around to zero, so it will fuck up the check. Due to integer promotion (google it if you want to know), it may actually work, but is not guaranteed to be portable.
You can check that something will overflow by comparing it to the max value of the type. Something like:
if (a > USHRT_MAX - b) {
/* Handle overflow */
}

or whatever the macro for the max size of the type is.
>>
>>51260754
do you know about SuperCollider?
>>
>>51261165
?optimizing code
even with -O0 it's still wrong
>>
>>51261198
Okay thank you very much.
>>
>>51261216
IT'S NOT WRONG

https://en.wikipedia.org/wiki/Undefined_behavior
>>
First attempt at doing anything in haskell really, I will probably parse the thread URL if I can be fucked later. Took way more effort than I thought it would.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as B
import Data.Attoparsec.ByteString.Char8
import Network.HTTP.Conduit (simpleHttp)
import Data.Aeson
import Data.Text
import Control.Monad
import Data.Maybe
import System.Posix
import Control.Concurrent (forkIO)
import System.Environment

---------------------------
-- Settings ---------------
---------------------------

--jsonURL :: String
--jsonURL = "http://a.4cdn.org/g/thread/51246213.json"
jsonRoot = "http://a.4cdn.org/"
imageRoot = "http://i.4cdn.org/"


----------------
-- Types -------
----------------

newtype Posts = Posts
{ posts :: [Post]
} deriving (Show)

type ImgURL = String

data Post = Post
{ tim :: !(Maybe Int)
, ext :: !(Maybe Text)
} deriving (Show)


---------------------------
-- Instance Declarations --
---------------------------

instance FromJSON Post where
parseJSON (Object v) =
Post <$> v .:? "tim"
<*> v .:? "ext"
parseJSON _ = mzero

instance ToJSON Post where
toJSON (Post tim ext) =
object [ "tim" .= tim
, "ext" .= ext
]

instance FromJSON Posts where
parseJSON (Object v) =
Posts <$> v .: "posts"
parseJSON _ = mzero

ran out of room.
>>
>>51260754
>>51260887
It's too big, but you can give me an opinion,

http://vocaroo.com/i/s1gXNgPXJCQt

I have a physical model driving the dynamic release system, but the problem I'm using an ASDR system to modulate it.
The problem is, if you adjust the power of the attack curve it adds a needless delay because of the nearly-silent volume at the beginning of the curve, so in real-time the releases can either be too short or too late.

Are these releases too short?
>>
>>51261281
continued
--------------------
-- Pure Functions --
--------------------

listPics :: Posts -> [ImgURL] -- [(Int, Text)]
listPics p = fmap urlify $ Prelude.filter realImg $ cleanPosts <$> posts p
where
urlify (x,y) = show x ++ unpack y
realImg (x,y) = not (x == 0 || y == "0")
cleanPosts b = (fromMaybe 0 $ tim b, fromMaybe "0" $ ext b)

fileInfoBuilder :: String -> String -> [ImgURL] -> [(ImgURL, FilePath)]
fileInfoBuilder root board imgList = (\x -> ((root ++ board) ++ x, x)) <$> imgList


------------------
-- IO Functions --
------------------

getJSON :: String -> String -> String -> IO B.ByteString
getJSON jsonRoot board threadID = simpleHttp jsonURL
where
jsonURL = jsonRoot ++ board ++ "thread/" ++ threadID ++ ".json"

getFile :: String -> IO B.ByteString
getFile = simpleHttp

fileList :: String -> String -> String -> IO [(ImgURL, FilePath)]
fileList root board threadID = do
d <- (eitherDecode <$> getJSON jsonRoot board threadID) :: IO (Either String Posts)
case d of
Left err -> fail err
Right ps -> return (fileInfoBuilder imageRoot board $ listPics ps)

downloadImage :: (ImgURL, FilePath) -> IO ()
downloadImage (url, file) = do
exist <- fileExist file
if exist then putStrLn $ file ++ " is already downloaded"
else do
forkIO $ putStr $ file ++ " downloading..."
bits <- getFile url
forkIO $ B.writeFile file bits
putStrLn " done"


------------
--- Main ---
------------

main :: IO ()
main = do
args <- getArgs
let board = args!!0
let threadID = args!!1
print $ "Board: " ++ board
print $ "Thread: " ++ threadID
files <- fileList jsonRoot board threadID
sit <- mapM downloadImage files
print sit
>>
>>51261243
that being undefined behavior does mean that gcc could have done it right in the mathematically sense but still choose to fuck up contrary to intel, clang, java, c#, dmd, tcc, javascript, ...
>>
>>51261315
Stop with your shitty bait.
>>
File: 18211.png (98 KB, 400x300) Image search: [Google]
18211.png
98 KB, 400x300
>>51261315
>java, c#, dmd, javascript
>>
>>51261372
>tfw firefox's javascript > gcc
>>
File: Shutter 2015-11-06 21:20:45.png (291 KB, 1424x1176) Image search: [Google]
Shutter 2015-11-06 21:20:45.png
291 KB, 1424x1176
Scrollbars
>>
are there loops in sql queries? like
i have 'a' and 'b' to both of them we add 1-4
 insert into mytable values('a', 1),('a',2),('a',3),('a',4); 
insert into mytable values('b', 1),('b',2),('b',3),('b',4); [\code]
>>
>>51261421
In SQL loops are called joins.

Here's postgresql code:

with
l as (values ('a'),('b')),
r as (values (1),(2),(3),(4))
-- insert into mytable
select * from l cross join r
>>
>>51261413
wow
>>
>>51261283
I like that, how do you use it?
>>
File: keepcalm.png (1 MB, 900x1000) Image search: [Google]
keepcalm.png
1 MB, 900x1000
hello guys
>>
>>51261407
we're talking about C/C++ you absolute mongrel. of course the result is predictable in certain other languages
>>
trying to implement a memory scanner-ish in C++ using only the windows API
when im trying to enumerate the entire address space i get a lot of read errors from ReadProcessMemory, i assume this is because that region/page/whatever-the-fuck of memory isn't allocated, or has been allocated but isn't in use
is there a way to get information about a memory region/page/whatever and check if its accessible/in use/allocated before trying to read from it?
>>
>>51260641
Ugly or not, this is bad because it opens a situation where there are two requests from same session at the same time, and mysqli_num_rows($res) is 0 for both of them, and you'll end up adding two rows into cart.
>>
>>51261560
i don't see any mention of c or c++ >>51259318
>>
>>51261565
yes
you need to get the list of loaded modules
that will contain the base address of the module, and also the size of the module.
>>
>>51261589
>this much autism
the discussion is carried over from the two previous threads. the anon saying that GCC is "wrong" is fucking retarded
>>
>>51261625
Does that include heap stuff? Not the poster you're replying to.

Wouldn't it be easier to like use VirtualProtect or something similar?

>>51261631
It's you who is for no reason assuming others are talking about C++.
>>
>>51261645
Assuming C/C++ as gcc only compiles two languages that fit the syntax: C and C++.
>>
>>51261631
this is the original reply >>51254265
no c or c++ mentioned.
>>
>>51261645
virtualprotect is for writing, not reading
you can read the PE header to find location of .rdata etc
>>
File: 1424476065145.gif (21 KB, 255x150) Image search: [Google]
1424476065145.gif
21 KB, 255x150
>>51261645
>>51261663
>>
>>51261315
>mathematically
You keep saying this, but your issue revolves around the behaviour of the "increment operator", which is not a traditional mathematical operator.
>>
>>51261673
>you can read the PE header to find location of .rdata etc
Oh. Yes. Now I remember. That's what I've been doing.
But VirtualProtect returns existing flags so you can undo the change.
That's why I said something similar - maybe there's a call that returns current flags without changing them.
If you're writing a memory viewer, I imagine you'd be more interested in a way to figure out what current page is instead of retrieving the map of all memory.

>>51261662
It's you who is for no reason assuming others are talking about GCC.
>>
Ignoring the basics, what was your first actual program that you wrote and what did it do?
>>
>>51260641
you should be using PDO, but mysqli also has prepared statements so if you're stuck with the procedural api
$rows = mysqli_num_rows($res);
if(max($q+$rows,$q,$rows) >= MAX_QUANTITY_OF_SHOPPING_ITEMS_OR_SOMETHING) {
echo "Too many of this item or some descriptive error message to that effect";
throw new AnExceptionPerhaps();
return false;
// you get the idea
}
if($rows == 0) {
$stmt = mysqli_prepare($dbconn, 'INSERT INTO `cart` (`sid`,`id_item`,`quantity`) VALUES (?,?,?)');
mysqli_bind_param($stmt, 'sii', $_SESSION['username'], $id, $q);
} else {
$stmt = mysqli_prepare($dbconn, 'UPDATE `cart` SET `quantity` = `quantity`+? WHERE `sid` = ? AND `id_item` = ?');
mysqli_bind_param($stmt, 'isi', $q, $_SESSION['username'], $id)
}
mysqli_stmt_execute($stmt) or die(mysqli_stmt_error($stmt));


I always find it really difficult to answer these sort of out-of-context snippet questions, particularly when it comes to webstuff since there are a lot of unknowns and the bigger picture often reveals more insights than what was said.
>>
>>51261709
my actual first program: creating a 'play' button in actionscript (flash). this introduced me to programming
first C program: created 10,000 .txt files on a hard drive. it took a few minutes
>>
>>51261700
n = ++a + ++a + ++a + ++a ... is a triangular number.
https://en.wikipedia.org/wiki/Triangular_number
>>
I have a question about creating charts in C# Projects in Visual Studio 2015.
I want to make a universal app that can use charts, but it seems the chart data tool is strictly for form applications?

I've read up briefly on free external solutions such as syncfusion or following this: https://code.msdn.microsoft.com/windowsapps/Charts-Windows-Phone-48d5bf2e
Although that one seems to focus on windows phone 8 apps, I'd assume it would work on windows 10 universal apps.

Anyone have any input into how I should approach it? I feel like I might be missing a super obvious tool to put them in apps.
>>
>>51261709
It's been so long ago. The earlier memory is a game in visual basic where you specify and angle and force by clicking and it launches a thing for you. You have to collide the thing with a bunch of building to make them explode. Kinda like angry birds only without all physics. I'd say it was in about 1997.
>>
>>51261709
It was an application in Visual Basic which contained all the formulas from my science textbook.
You put in some numbers and it gave the result back. Later I wrote a smaller version in BASIC so I could use it on my TI-83 with some equations I needed for maths.
>>
>>51261709
A lottery numbers generator in Visual Basic 6. Also a text adventure game in Turbo Pascal, I don't remember which one was the first.
>>
Okay can someone tell me why this doesn't work?

println (rounded-square) pro integro duo de sexto


I'm trying to make a rounded square appear.
>>
>>51261734
And as you'll notice, there's no "increment operator" in use. You may be able to use such an operator in some programming language for lack of higher-level concepts, but the point is "++" has no "correct" or "incorrect" behaviour "mathematically".
>>
>>51261805
why are you faggots still falling for the bait? are you seriously this autist?

the other faggot is either a dumb kid or trolling you. either way, ignore him/her and stop shitposting, retards.
>>
>>51261781
You need to use a programming language and a compiler or interpreter for that language, you can't just type text into 4chan code tags and expect something to happen.
>>
>>51261735
https://github.com/xyzzer/WinRTXamlToolkit
I would use this.
>>
   
struct node *root;
struct node *temp;
int i;

// initialize root
root->parent = NULL;
root->leftChild = NULL;
root->rightChild = NULL;


Remember kids, compiler warnings are for noobs.
>>
>>51261852
Certainly seems more cut and dry than other options. I'll look into it, thanks for the input.
>>
>>51259370
Add "throws ArgumentOutOfRange" after the declaration of parameters
>>
>>51261885
I wouldn't try using Windows Phone libraries with Windows applications, the libraries don't mix at all.
>>
>>51261877
you mean if you get compiler warning, you dont know shit about language?
>>
>>51261919
To add to this, using libraries from windows phone or something else might not give an error in Visual Studio,
but it will fuck you over when you try to put your application on the store.
>>
>>51261943
>>51261919
Oh that is not good. The search continues, I suppose.
>>
help the newbie, c

#include <stdio.h>
int atoi(char s[]);
main()
{
char lolo[150], c, index = 0;
while((c = getchar()) != EOF)
lolo[index++] = c;
>>printf(atoi(lolo[]));
return 0;
}
/* atoi: convert s to integer */
int atoi(char s[])
{
int i, n;
n = 0;
for (i = 0; s[i] >= '0' && s[i] <= '9'; ++i)
n = 10 * n + (s[i] - '0');
return n;
}


pointer or smt missing on >> line, dunno what
>>
How does cache indexing work between different sized L1 and L2 with 32 bit addresses? I can't wrap my head around it. Do they share index bits is the tag the same?
>>
>>51259300
>They always send us total garbage
Sounds like PayPal. My boss had to deal with PayPal transaction CSVs for over a month for an audit thing — so many of them had invisible unicode characters in column names, etc.
>>
>>51262049
printf(atoi(lolo));
>>
>>51262049
printf("%d\n", atoi(lolo));
>>
Anyone can help me find this paper somewhere for free?

Factors Influencing the Appearance of CRT Colors
Authors: Brainard, David H.; Ishigami, Koichiro

pls respond
>>
>>51262208
>googles 'Factors Influencing the Appearance of CRT Colors'
>second result
>http://color.psych.upenn.edu/brainard/papers/Brainard29.pdf
>>
>>51262261
lmao okay im retarded thanks anon
>>
>>51262095
thanks mate, yours is true
>>51262061
thanks
>>
So what is DPT's opinion on rust?
Getting pretty comfy with this language now.
>>
>>51262426
SJW ridden, more verbose than C++, learn D instead.
>>
File: 1443317393088.jpg (601 KB, 2048x1363) Image search: [Google]
1443317393088.jpg
601 KB, 2048x1363
>>51262426
https://www.rust-lang.org/conduct.html
>>
>>51258434
I'm learning Python 3 and I'm getting a SyntaxError: "keyword can't be an expression" for the last 2 tests.

import sys

def test(did_pass): ... #This is correct, it works for other tests

def remove_letter(letter, word):
new_word = ""
for x in word:
if x != letter:
new_word += x
return new_word

def test_suite():
test(remove_letter("b", "") = "")
test(remove_letter("b", "c") = "c")


When I test print(remove_letter("b", "") it gives me the right results so wtf is going on with the test that its giving me errors for just those 2?
>>
>>51262464
Also note, i did call test_suite() at the end
>>
>>51262444
While I hate sjws, I don't think their antics really matter; isn't technology agnostic of social justice anyways?

And besides rust isn't the worst one out there, the one from the retards from node.js is absolutely bonkers
>>
>>51262464
equals equals, not equals.
>>
>>51262464
I don't know but aren't you suppsed to use == instead of = when testing.
>>
>>51262492
>the one from the retards from node.js is absolutely bonkers
>https://www.rust-lang.org/conduct.html - bottom of page
>"Adapted from the Node.js Policy on Trolling"
>>
>>51262493

God damnit, I see it now. I copy pasta'd from the online guide I'm using. The author's typo. I need to be better at finding these small things either way. Thanks
>>
>>51262426
>native code
Deprecated. There's no point in new languages that use native code as plenty of well tested alternatives exist. If you want fast low-level code, use C or C++11, if you want higher level code, learn a JIT-based language like Scala or C#.
>>
>>51262492
just use a man's language like C++
>>
>>51262507
Milded down from node, but still problematic
>>
>>51262514
why bother to bait someone if you aren't going to go the full mile?
you should've said javascript, not scala/C#.
>>
>>51259829
Loool
>>
>>51262527
Not b8 m8. If you believe native code should be used for everything you're retarded btw.
>>
>>51258434
we /pedophiles/ now?
>>
>>51262550
[Citation Needed]
>>
>>51262584
manchildren
>>
>>51262523
>problematic

I'm triggered by this word.
>>
>>51258799
The function must return an integer.

1 / (any number > 1) will always be zero when doing integer division.

So the question is totally nonsensical.
>>
I failed.
Started reading Real World Haskell, but I'm about halfway through the book and it has become way too difficult for me to follow. The fact that they are talking about things before introducing them (ie Monads) doesn't help one bit.

Is Learn You A Haskell better for an introduction before tackling RWH again?
>>
>>51258799
i don't really understand what they're asking for in the first two
>>
>>51262727
get naked, get half boner, shake your ass as on the direction as i said; right, up, left, down. and make it faster and scream im a mancopter.
>>
>>51258799
2
2
0

2 because the denominator multiplied by 2 so the min and max have to be min/2 and max/2

0 because you can't divide by 0
>>
>>51262698
>The function must return an integer.

That's not true at all! If you call it with 0, you get a free SIGFPE instead.
>>
>>51262698
It's designed to return an integer.

Who is to say that a "0" obtained from x = 2 as input is "correct" but a "0" obtained from x = MAXINT + 1 is "incorrect"?
>>
ok guys, what kind of math do I need to know to be able to code games?
>>
>>51263056
http://www.opengl-tutorial.org/miscellaneous/math-cheatsheet/
>>
>>51263056
basic
>>
>>51263056
depends on what kind of game and if you're going to use a babby engine/framework or build it from scratch
>>
>>51263065
>>51263068
what part of linear algebra do I need to know.

what else besides a basic understanding of sin-cos-tan do I need to know in trigo?
>>
File: bitshift.gif (595 KB, 200x228) Image search: [Google]
bitshift.gif
595 KB, 200x228
What data structure would be ideal for a really long sequence of int32?

I'm working on a glitchart program for my final's project. I want to look at images as sequences of bits, which I then want to manipulate in a style similar to how you make glitchart with an audio editor.

Packed integers is a neat way of getting a 32bit word, so that's what we're going with.

Images with dimensions of, say, 5000x5000, you end up with a total of 25000000 pixels. An ARGB image will have a bit-depth of 32. That means 25000000 packed integers.

What would be the best way of storing these in memory? I'm currently just using an array, and it works no problem. I'm just thinking, is there something better? Like a linked-list or some shit. But a linked list of integers, seems overkill.

Pic related is what bitshifting does to an image, 1 bit at a time.
>>
>>51263056
linear algebra, game theory, applied mathematics, trig, graph theory, discrete mathematics, lie theory, number theory, differential geometry, topology, and combinatorics for starters
>>
>>51262796
I thought you were supposed to sing along to "He's a Pirate"?
>>
>>51263090
Why don't you simply build a VBO and upload them to the GPU then use a fragment shader to make the glitches?
>>
>>51263098
>https://en.wikipedia.org/wiki/Lie_theory
>contact of spheres
https://www.youtube.com/watch?v=YaG5SAw1n0c
>>
>>51263118
>VBO
I have zero experience with OpenGL
>>
>>51263090
an array obviously
>>
>>51263151
That's what I was thinking, but maybe someone more experienced than me could tell me otherwise.
>>
>>51263146
Eh, in which case, I guess you should resort to an array but I'm convinced that simply loading a texture and using a fragment shader would yield way better performance for that and you wouldn't be clogging the system memory. Besides you only need very basic understanding of OpenGL to achieve that so you could give it a shot and learn about it in a single evening.
>>
Why can't I
size_t x = vector.size();

?
>>
>>51263090
no matter what structure you use you will use the same amount of memory
you might have to implement some sort of segmented buffer to avoid running out of memory though
>>
>>51263188
>>51263182
Thanks!
>>
>>51263183
Because vector<int>::size_type
>>
>>51263183
How so?
>>
>>51261735
Still here, anon?

In what way do you want to use your charts? What visual framework are you using?

Could your charts come from 3rd party solution and be embedded in your GUI?

I've done these things, but I need more details on your situation.
>>
>>51263090
Since even 25000000 int32 are only ~24 MiB I wouldn't worry too much about memory exhaustion.
Once you reach GB regions you might look into file backed memory maps, which are managed by the kernel and lazily loaded into your address space on demand (=access).
>>
>>51262492
>isn't technology agnostic of social justice anyways?
The tech itself is, yes.

The problem is if SJWs tend to lean towards Rust due to these things, if you get a job or work on a project in Rust, you're more likely to have to work with these undesirables.
>>
Im trying to learn Fortran so i made this neat program
program me
implicit none
integer :: i, j
i = 5
j = fact(10)
print *, j

end program

recursive function fact (n) result (fac)
implicit none

integer :: fac
integer, intent (in) :: n

if (n == 1 .or. n == 0) then
fac = 1;
else
fac = n * fact(n-1)
end if

end function fact


but i get this error
Error: Return type mismatch of function 'fact' at (1) (UNKNOWN/INTEGER(4))


what's causing it?
>>
So I have two static arrays of different sizes. For every element in the first array it has to go through each element of the second array and with each call a function with as parameters the value of the element of the first array and the element of the second array. How do I go about this with CUDA C.
>>
What does /g/ think about Go? It seems pretty neat.
>>
>>51263387
Fuck Go, fuck Pike, fuck Google.
Thread replies: 255
Thread images: 29

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.