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

/dpt/ daily programming thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 299
Thread images: 39

File: dpt.png (389KB, 934x1000px) Image search: [Google]
dpt.png
389KB, 934x1000px
What are you working on, /g/?
old thread >>58244274
>>
First for Hitler

https://www.youtube.com/watch?v=G1fFCnjThCQ
>>
>>58251812
Second for decentralized TV
>>
Third for bunnies
>>
>>58251812
Reading a book about preparing for an interview.
>>58252458
I really miss my belier bunny, she was the more affectionate pet I ever had. ;_;
>>
>>58252482
Oh no anon, I'm very sorry ;_;
>>
>>58252482
>she was the more affectionate pet I ever had

Did you have sex with it?
>>
>>58252502
;_; she was that same color btw
>>58252505
furfags bls go
>>
File: 1110946823813.gif (164KB, 160x120px) Image search: [Google]
1110946823813.gif
164KB, 160x120px
What is the most efficient way to check if a proxy is alive using python?
This is what I use to check:
            s = requests.Session()
req = s.get("http://www.example.com",timeout=15.0,
proxies={'http': 'http://{}:{}'.format(IP,port)})
if "<title>Example Domain</title>" in req.text:
works.append(IP+":"+str(port))
else:
questions.append(IP+":"+str(port))

I am trying to scan IP ranges for them, here are the ports I check:
[80,800,3128,8080,8888,6588,3124,1080]


Suggestions? Doing anything wrong? Socks proxies going to get fucked the way I do it, right?
>>
File: Untitled.png (3MB, 1920x1080px) Image search: [Google]
Untitled.png
3MB, 1920x1080px
just imagine how much better things would be if everything was coded in assembly.
>>
>>58252768
Not much better because people suck at assembly?
>>
>>58252795
>people suck at assembly
exactly.
less shitty stuff.
quality of code & programs improve.
>>
>>58251812
  stuff = 'CONNECT : GET https:// HTTP/1.1\r\n'.encode('utf-8')
27 a, b = 0, 1
28 l = []
29 while b <= len(data):
30 if s in data[a:b]:
31 l.append(data[a:b])
32 a = b
33 b += 1
34 get = l[0]
35 url = get.strip(stuff)
36 url = url.decode('utf-8')


working on a proxy server because why not?
>>
Does anybody see a problem with this code for making a WAV file? It looks fine, but SDL_mixer keeps saying "Error reading from datastream".
    std::vector<uint8_t> retval;
tv_audio_wave(&retval, "RIFF");
tv_audio_wave(&retval, (uint32_t)frame->get_data().size());
tv_audio_wave(&retval, "WAVE");
tv_audio_wave(&retval, "fmt ");
tv_audio_wave(&retval, (uint32_t)16); // length of data section
tv_audio_wave(&retval, (uint16_t)1); // uncompressed PCM
tv_audio_wave(&retval, (uint16_t)1); // channel count
tv_audio_wave(&retval, (uint32_t)frame->get_sampling_freq());
tv_audio_wave(&retval, (uint32_t)frame->get_sampling_freq()*1*frame->get_bit_depth()/8);
tv_audio_wave(&retval, (uint16_t)(1*frame->get_bit_depth()/8)); // block aligh
tv_audio_wave(&retval, (uint16_t)frame->get_bit_depth());
tv_audio_wave(&retval, "data");
std::vector<uint8_t> frame_data =
frame->get_data();
tv_audio_wave(&retval, (uint32_t)frame_data.size());
retval.insert(
retval.end(),
frame_data.begin(),
frame_data.end());
return retval;


I'll go over it again
>>
>>58252839
tv_audio_wave is defined here
static void tv_audio_wave(std::vector<uint8_t> *retval, const char *data){
retval->insert(retval->end(), data, data+strlen(data));
}

static void tv_audio_wave(std::vector<uint8_t> *retval, uint32_t data){
// reverse byte order, but little endian bits
std::vector<uint8_t> data_tmp(&data, &data+sizeof(data));
retval->insert(retval->end(), data_tmp.begin(), data_tmp.end());
}

static void tv_audio_wave(std::vector<uint8_t> *retval, uint16_t data){
std::vector<uint8_t> data_tmp(&data, &data+sizeof(data));
retval->insert(retval->end(), data_tmp.begin(), data_tmp.end());
}


I know it is pretty ugly and redundant, but i'm going to clean that up soon
>>
>>58252839
It's written in C++.
>>
File: FB_IMG_1483130391221.jpg (38KB, 500x457px) Image search: [Google]
FB_IMG_1483130391221.jpg
38KB, 500x457px
Someone convince me to write my compiler
>>
>>58252768
You know what, you're right.
>>
>>58252768
actually I don't think that'd necessarily be better.

but just imagine if all programs were magically made as performant as possible. less wasted cpu cycles. less wasted energy. maybe we wouldn't need as much GHz and RAM anymore.
>>
>>58252839
>>58252850
Why would you turn PCM into WAV to load with SDL_mixer when you can send PCM directly to SDL_audio?
>>
>>58252855
Write it, faggot.
>>
Is there a way to code directly in LLVM bytecode?
>>
File: why.png (163KB, 1366x768px) Image search: [Google]
why.png
163KB, 1366x768px
>>58252813
anyone know why on my proxy server i can get the response from the browser but then when i close the socket, get the data, and try to connect to the website through a newly opened socket i get an error.

pic is related

the first string is the binary response, then i strip the url which is in this case water.usgs.gov:443

as you can see the code in the thing but it won't connect?
>>
>>58252895
SDL_Mixer code was already layed down, and it code is structured to import WAV files already. Might change that later though.
>>
>>58252969
Hell, I would be surprised if there wasn't a way to use PCM directly with SDL_mixer.
>>
>>58252962
http://llvm.org/docs/CommandGuide/llc.html
>>
>>58252979
I can't seem to find a way to do that. You can write directly to Mix_Chunk, but using WAV formatting looks more convenient
>>
File: 1393208963344.jpg (75KB, 706x350px) Image search: [Google]
1393208963344.jpg
75KB, 706x350px
>>58253009
>using WAV formatting looks more convenient
Clearly not, though.
>>
>>58253017
*looked
I hope I can make it work
>>
I can't believe Rust still doesn't fucking have HKTs.
>>
LLVM IR is the future.
@.str = private constant [13 x i8] c"Hello World!\00", align 1 ;

define i32 @main() ssp {
entry:
%retval = alloca i32
%0 = alloca i32
%"alloca point" = bitcast i32 0 to i32
%1 = call i32 @puts(i8* getelementptr inbounds ([13 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %0, align 4
%2 = load i32* %0, align 4
store i32 %2, i32* %retval, align 4
br label %return
return:
%retval1 = load i32* %retval
ret i32 %retval1
}

declare i32 @puts(i8*)
>>
>>58252850
>>58252839
The problem is in frame_data, not in the loader itself.
>>
>>58253132
I take that back, calling QuickLoad_RAW works, but the RWops and LoadWAV didn't, weird
>>
>>58253161
>>58253132
>>58253017
Got it to work, but it sounds terrible.
>>
how can i disable auto saving in visual studio?
>>
>>58253100
Youre the reason 90% of other programming languages are shit
>>
Nice, rite?
import requests
useragent = {'User-Agent': "Mozilla/5.0 (Linux; U; Android 4.0.3; de-ch; HTC Sensation Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/5334.30."}

google = requests.get("https://www.google.com/search?q=%22%49%43%41%43%54%61%73%6B%66%6F%72%63%65%2E%6F%72%67%22+filetype:pdf&num=100&biw=1920&bih=978&filter=0", headers=useragent)
##print(google.text)
lol = str(google.text).split("href=\"")
lol = [x.split("\" onmousedown=\"") for x in lol]
for x in lol:
if len(x) == 2:
## print(x[0])
if "pdf" in x[0] and "google.com" not in x[0]:
print(x[0])
response = requests.get(x[0])
with open(str(x[0].split("/")[-1]).split("?")[0], 'wb') as f:
f.write(response.content)

>>
File: WhyWouldTheyDoThat.png (26KB, 531x391px) Image search: [Google]
WhyWouldTheyDoThat.png
26KB, 531x391px
So, I'm reading a book on C Programming, got to typedef, and I found out this.

Why the fuck did Microsoft do this?
Like... I never really knew what those were, and I just edited them as I needed, but what the fuck? Why did they rename unsigned long to DWORD. It doesn't make sense
(also, since most of these are like... at most, like, the number 3 or 5 or something, why didn't they use short?)
>>
>>58253337
I remember hearing that Windows was in the UTF-16 train, so double that word length would be 32, which might have been the min length of unsigned long at the time
>>
>>58253327
So, it opens any non-google results from a Google search and saves them to a text file?

Sorry, I've kinda only used Python for a Discord Bot so far, so I may have missed something in there.
Mine currently returns the search result for an animelyrics page:
matches = re.findall(r'href=\"http:\/\/www.animelyrics.com\/[^\"]+\/[^\"]+\"',
str(urllib.request.urlopen("https://www.bing.com/search?q=anime+lyrics+" +
re.sub(r'[ ]', "+",
re.sub(r'[\$][\.](animeLyrics|al)', "", message.content)).strip()).read()))

count = 0
if len(matches) > 0:
for match in matches:
if not re.search(r'\.jis', match):
count += 1
match = re.sub(r'(href=\"|\")', '', match)
await client.send_message(message.channel,
match)
if count == 0:
await client.send_message(message.channel,
"I'm sorry! I couldn't find that song! :cry:")
else:
await client.send_message(message.channel,
"Those are all the matches I found (" + str(count) + ")")

Wanted to get it to return the lyrics, themselves, but different pages were formatted differently, so I wasn't sure how to go about it.

>>58253374
hmmm
But my question is why did they rename it? Just to fuck with people trying to edit their preferences for system functionality, so people don't actually know what it is?
>>
>>58253406
It saves the PDFs but I guess it could be modified to do whatever you want with the links.
>>
>>58253432
Ah, ok.

Yeah, that makes sense now.
I didn't really use Python for any kind of file handling yet.
Was thinking of making a help file and getting it to read that, b/c Discord only has a max of 2K characters per message, so it'll eventually exceed that.

little curious about the "split" function. Is that equivalent to PHP's explode function? Converts a string into an array on a delimiter?
>>
>>58253406
>>58253337
They renamed it for the following reason.
Unsigned long is type defined by C and C++ standards.
It is defined as something along the lines of "whatever the fuck platform/compiler decides it to be".
Unsigned long can be 32 bits on some platforms and 16 bits on others.
Microsoft wanted a type that is strictly defined to be 32 bit unsigned integer.
On x86 Windows, DWORD is aliased to unsigned long. On some other platform where unsigned long is 16 bit, DWORD might be aliased to unsigned long long, or whatever else.
Hope this helps.
>>
>>58253468
Hmmm, ok.
I guess that makes some sense.

Also, I never knew there was an "unsigned long long". Interesting
>>
>>58253462
Just looked it up. Nvm.

Interesting.
>>
>>58253462
>little curious about the "split" function. Is that equivalent to PHP's explode function? Converts a string into an array on a delimiter?
Yeah, I think so.
If you split "some;thing" it would return ["some","thing"]
>>
>>58253506
Ok, cool. That could be helpful for my bot actually
>>
>>58253287
I don't understand are you implying I should watch more anime?
>>
>>58253374

It's still 32 bits on 64-bit Windows.
>>
File: tacos_2hu.jpg (28KB, 424x424px) Image search: [Google]
tacos_2hu.jpg
28KB, 424x424px
>>58251812
Please (you) me.
>>
>>58253573
#include <stdio.h>
#define FAGGOT "(You)"

int main(int argc, char** argv){
printf("Here's your %s\n", FAGGOT);
return 0;
}
>>
>>58253622
T-thanks. Btw, why not a const string instead of that macro?.
>>
>>58253644
That coulda worked, too.
I just figured it's more in your face to straight-up #define you to be a faggot.
>>
>>58253658
Wow, rude.
>>
File: 1467342437812.png (500KB, 987x766px) Image search: [Google]
1467342437812.png
500KB, 987x766px
>>58253658
GENTLEMEN!

Let us not sully this board with such foul language.
>>
>>58253548
Precisely.
>>
File: 1465344167062.jpg (19KB, 441x415px) Image search: [Google]
1465344167062.jpg
19KB, 441x415px
>>58253658
r u d e
>>
>>58253622
>>58253658
>Not using string literal concatenation
#include <stdio.h>
#define FAGGOT "(You)"

int main(void){
puts("Here's your "FAGGOT);
}
>>
File: 1465311958563.jpg (46KB, 960x540px) Image search: [Google]
1465311958563.jpg
46KB, 960x540px
Input required
>>58254553
>>
Hey /dpt/, book I'm reading says I can do this.
But, when I run it, it crashes when it tries to reassign the variable.
int main(int argc, char** argv){
union measure{
float cm;
int inch;
};

union measure you;
union measure paul;

paul.inch = 70;
printf("Paul is %d inches tall\n", paul);
printf("How tall are you in inches? ");
scanf("%d", you.inch);
you.cm = (CENT_PER_INCH * (float)you.inch);
paul.cm = (CENT_PER_INCH * (float)paul.inch);
//paul.cm = 2.00; //Tried to assign an immediate variable... didn't work either

printf("You are %.1f centimeters tall\n", you.cm);
printf("Paul is %.1f centimeters tall\n", paul.cm);
return 0;
}

Am I doing something wrong? Or was the book wrong in saying you can reassign unions?
>>
>>58254746
>scanf("%d", you.inch);
You forgot your '&'.
scanf("%d", &you.inch);


Your example is a pretty pointless use of a union though.
>>
>>58254764
oh fuck, I'm an idiot!
Thanks.
I didn't even see that.

Works now.

>Your example is a pretty pointless use of a union though.
It's just a thing my book was showing me.
I never even learned about unions in the classes I took; didn't even know it existed until this.

They have a better example, though, where there were 3 people, and each has a different hobby struct in the union, with different things like music, sports, or TV.

It's all just practice, though. I doubt they expect us to use the examples in real code, just showing us how it works.
>>
>>58254785
>I never even learned about unions in the classes I took; didn't even know it existed until this.
Unions are a pretty niche thing, but they can sometimes be useful.
The two main uses for a union are probably tagged-unions (a value that can be one of multiple types at runtime) or type punning (interpreting a value as a different type directly, without conversion).
struct my_tagged_union {
int type;
union {
int i;
float f;
char *s;
}; // Note: Having no name here is a C11 feature
};

I would give a type-punning example, but I've yet to come up with a valid reason to use it that isn't hacky as fuck.
>>
>>58254831
Hmm, interesting

How would you refer to that union, though, without a name?
>>
>>58254862
As if it was a member of the parent struct.
struct my_tagged_union value;

value.i = 10;
>>
>>58254873
oh that's pretty cool.
>>
>>58254831
in Haskell you use tagged unions all of the time
>>
>>58254877
I'm pretty sure they added that feature to specifically make tagged unions nicer to use.

>>58254878
Lots of languages used tagged unions all of the time. In C, it's just not as common.
>>
>>58254896
That's because C programmers can't program

>should my library return some kind of meaningful error?
>naa, int
>>
>>58254896
>>58255009
>should i use an enum?
>nope, #define is perfectly good
>>
>>58255009
That's because C doesn't really have a continent way to "unbox" those errors.
It's really just a sign from when C was designed.

>>58255019
What does that have to do with anything?
C enums are weakly typed, so there isn't any actual practical difference.
I do prefer to use enums myself, though.
>>
>>58255041
>continent
convenient*
I guess I picked the wrong correction.
>>
>>58251812
I asked on SQT but got no answer:

What's the "classic" page on HN? IT doesn't always show on the navbar either https://news.ycombinator.com/classic
>>
Which C-like should I learn

I understand imperative programming fairly well but I still haven't learned a 'proper' language (I can fluently code in Lua, JS, Py, Pascal and VB)
>>
>>58255618
C
>>
>>58255618
C
>>
>>58255674
Absolutely disgusting.
>>
>>58255674
How do you compile a Rust project?
>>
>>58253468
Why didn't they just use uint32_t?
>>
>>58255698
I presume you would use the Rust compiler.

The important question is why you would compile a Rust project, truth to be told there are no useful projects written in Rust.
>>
>>58252855
Describes the very fundamental way computers operate

Some people say that you don't even deserve to call yourself a programmer if you don't understand how compilers work
>>
>>58255704
<stdint.h> didn't exist back then, but that doesn't make what they did any less retarded.
>>
>>58255714
Someone's making an operating system
>>
>>58255735
Someone's making an OS in any language
>>
>>58255735
Be sure to congratulate them on another useless project written in Rust.
>>
>>58255714
I presume you can bind practically anything to OGL these days and I want to write a like a backend engine in some low level language and then bind it through to LuaJit
>>
>>58255725

What they should have done was make their own fixed width types (like Linux did), and call them by an appropriate name like, u32 or u64.
>>
>>58255715
Anywhere I can read the process step by step specifically? Google is failing me
>>
>>58255826
>>58255725
>>58255704
>>58253468
CHAR, WORD, DWORD and QWORD are for some given architecture known fixed sizes in computer science. The nomenclature predates both W32, Windows and Microsoft by a couple of decades.

It's exactly equivalent to naming them u8, u16 and u32.
>>
>>58252967
First of all that can be done with a single line of curl.
Second why are you running the script as root
Third don't overcomplicate easy things.
>>
>>58255875
But far less descriptive.
>>
>>58255887

Alright, thanks!
>>
>>58255875
>CHAR, WORD, DWORD and QWORD
"word" is not synonymous with 16 bits. What they're done is tie it to x86 even more.
>>
>>58255875

I have heard the term "word" refer both to 16 bits and 32 bits depending on architecture. On Intel, a word is 16 bits. On ARM and MIPS, a word is 32 bits. In using terms like WORD, you are tying the size of the type to a specific architecture. More descriptive would be to explicitly state the number of bits in the type. A name like u32 is simple. It's an unsigned 32-bit integer, no matter what platform it's on. There is no possibility for confusion when porting the OS to a different architecture.
>>
>>58255966
>his name is ruby
>he only talks about low level stuff
>>
>>58256121
>XD
>>
>>58256092

Though my primary interests are in low level shit, not everything I program is low level. Ruby is basically my swiss army knife for anything that doesn't need to either be low level or run fast. I even wrote a compiler in Ruby.

>>58256121

He and His are correct pronouns, Anon.
>>
>>58256238
>doesn't need to either be low level or run fast
Haskell
>>
>>58256238
>His
You are not God, Ruby.

Plus I thought your name had 'nothing to do with the language'. Given how often you claim to use it, I find that very unlikely.
>>
>>58256245

I don't have to think much about types in Ruby.
>>
>>58256282
You don't in Haskell either
>>
>>58256280

I didn't come up with it because of the language, but I do sort of keep it around for a number of reasons, one of which being that I am a Rubyist. So the language is part of it, I suppose.

>>58256304

Looks nice, but it's in alpha still. Not something I'd invest a ton of time into at the moment.
>>
>>58256282
>>58256319
Well, I mean you don't need to worry about type signatures.
>>
>>58256319

>Have to understand type theory to understand the language
>Don't have to think about types much
>>
>>58256338
>>1 + 1
>2

not worrying about types
>>
>>58256353

Send an object a message, get an object back.
>>
>>58256394
almost all types do is eliminate classes of errors
>>
>>58256426

Well yes. A completely typeless system is a mess. But you don't always need a wholly sophisticated type system. I learned when programming Ada that that can be fucking hell. Sometimes a simple type system can be acceptable, as long as it's consistent.
>>
>>58256444
Haskell's type system seldom gets in the way
>>
>>58256451

Nah, but the need for purity probably will.
>>
>>58256451
I would tend to agree with this.

While people seem to get the impression they're fighting the type system, the case is actually that what they're trying to do is semantically ill-formed, and errors are just expressed via the type system.

>>58256479
Heresy.
>>
>>58256479
Not really, the only pain is that we don't have iodiom brackets (yet?)
You can make everything IO if you really want.
>>
>>58256499
*idiom brackets
or that prefix thing

anyway, what I basically mean is rather than:

a <- ma
f a

you can do something like

f !ma!

this would give Haskell syntax much closer to imperative languages, i.e.

print (!readLn! + 3)
>>
>>58256499
>>58256509

oh, and you could avoid this by making your own library that takes monadic parameters for everything
>>
>>58256523

Or I could avoid all of this and keep programming in Ruby.
>>
File: ruby irl.png (266KB, 339x589px) Image search: [Google]
ruby irl.png
266KB, 339x589px
>>58256566
Haskell is objectively better than Ruby
>>
>>58256573

I have better cat ears than this plebian.
>>
>>58256599
yet another image for the ruby wall of shame
i knew you were a brony, but a furry too?
>>
>>58256631
> what is sarcasm
>>
File: ruby developer.jpg (126KB, 1920x1080px) Image search: [Google]
ruby developer.jpg
126KB, 1920x1080px
>>58256566
>>
>>58256631

Not a furry really. There's a pair of cat ears with some little gadget that can read brainwaves and move the ears about depending on your mood. Bought a pair at Sakura Con a few years back. Had some fun with friends seeing if we could get the ears to flip the fuck out.
>>
>>58256738
Those are meant for women
>>
>>58256744

Psh, anyone can wear 'em.
>>
>>58256761
Do you own a strap on too?
>>
>>58256631
That's a lot of (You)s, bro.

Maybe he'd shitpost less if you responded to him less.
>>
>>58256765

Nope!
>>
>>58253337
typedef doesn't use the pre-processor so wouldn't it have to be global to be implemented from a header file? Someone answer this.
>>
>>58252855
I am writing it right now and it's a fucking nightmare
>>
>>58252855
>>58257203
That's funny, I'm writing your compiler, too.

It's glorious.
>>
>>58257149

Yes. Typedefs are usually global.
>>
how do you backup/restore docker named volumes?

When I google it, all I can find is the process for volume containers
>>
>>58257295
you put them on a usb stick and stick it up your ass, you fucking homosexual piece of shit!
>>
>>58257307
I feel like /dpt/ has dropped in quality slightly over the holidays.
>>
>>58257325
I'm lonely, forgive me anon.
>>
File: 1476811327277.jpg (38KB, 640x480px) Image search: [Google]
1476811327277.jpg
38KB, 640x480px
>>58257307
>>
File: sniffle.gif (380KB, 500x280px) Image search: [Google]
sniffle.gif
380KB, 500x280px
>>58257307
>>
>>58257334
me too friend, me too
>>
First for Python
>>
>>58257240
are you by any chance from certain university somewhere in Central-Eastern Europe?
>>
>>58257572
Nah, I'm just messing with you.

But if you've been asked implement a compiler as part of your course, I solidly approve of your university.
>>
>>58257636
Indeed we were.
We are given a BNF grammar and a specification of a register machine. Everything has to be done using Flex and Bison, kinda cool but also difficult.
>>
>>58257651
That is bad-ASS.

Though I would have just cheated and used Haskell/Parsec.
>>
>>58257240
>>58257656 is right
Haskell is easily the best language for writing your own compiler.
>>
Rust has stepped up their game: https://www.reddit.com/r/rust/
>>
>>58257651
Do you get extra points for making it go fast?

If I happened to be a CS professor, I'd grade it like so:

51% correctness (0% if it doesn't work; 51% if bug-free even against heavy fuzzing).
20% elegance of implementation/openness to extensibility (semantics, not coding style).
20% execution speed.
9% coding style; variable names, etc.

What other things should be taken into consideration when assessing quality of software?
Alternatively, how
>>
>not bootstraping your compiler in your own language
>>
>>58257704
*how would you balance the marks between various desirable traits?
>>
>>58257705
You've gotta write it in someone else's language first
>>
I need to convert a total number of seconds to the format of hours, minutes and seconds (HH:mm:ss).
The code bellow does the job as intended, but it's a fucking mess.

updatePopup is tied to timerSeek, which fires 40 times a second while the user moves the mouse pointer over the seek bar, so it would be nice if this function were 'more elegant'.

double cPos;//postion of the mouse over the video's actual lenght
double spanTSec;//total lenght of the video in seconds
double seekBW;//seekBar actual width
double tempS;//temporary double
short tSecond;//total in seconds
short tMinute;//total in minutes
short tHour;//total in hours
Point mCPos = new Point();//current postion of the mouse over the seekBar
DispatcherTimer timerSeek = new DispatcherTimer();
bool isGetpos = false;

private void updatePopup (object sender, EventArgs e)
{
isGetpos = (isGetpos) ? isGetpos = false : isGetpos = true;
fTT.HorizontalOffset = (mCPos.X < seekBW / 2) ? fTT.HorizontalOffset = mCPos.X : fTT.HorizontalOffset = mCPos.X - 50;

cPos = spanTSec * (mCPos.X - 5) / seekBW;//conversion to get the current position in the video based on the current mouse postion over the seek bar
tempS = cPos / 60;
tHour = (short)(tempS / 60);
tSecond = (short)(((tempS - Math.Truncate(tempS)) * 60));
tempS = tempS / 60;
tMinute = (short)(((tempS - Math.Truncate(tempS)) * 60));

fText.Text = tHour.ToString("D2") + ":" + tMinute.ToString("D2") + ":" + tSecond.ToString("D2");
}
>>
>>58257725
Is that still felt to be true if you write it in machine code?
>>
>>58257704
Actually the grading system of this assignment is pretty funny.

It's a contest.

Top 5 compilers get 5.5
Next 5 get 5.0
Next 10 get 4.5
Next 10 get 4.0
Next 10 get 3.5

Everyone else get 3.0 provided their compilers work.

(In Europe 5.5 is highest, 3.0 lowest, 2.0 is an F)

The only thing taken under consideration is speed.

Each instruction (INC, ADD, COPY, LOAD) has its computing time, e.g INC has 1 or LOAD has 10. The best compiler has the lowest speed obviously.

So yeah, it works like that
>>
>>58257756
Cont.
Obviously these are not all instructions.

And the compiler also have to point out errors and warnings, the more precise the information the better
>>
I'm having some trouble with SDL_RWops. This code always fails and says "Error reading from datastream" (through SDL_GetError() and Mix_GetError())
Mix_Chunk *chunk =
Mix_LoadWAV_RW(
SDL_RWFromMem(
wav_data.data(),
wav_data.size()),
1);


I got it to work using QuickLoad_RAW, but I need it to always be in the output spec (which it isn't). Any ideas?
>>
>>58257781
wav_data is local if that helps (but the 1 at the end should destroy the SDL_RWops)
>>
>>58257859
>gcc
>c++
No, most of it is C.
>>
>>58257849
>>58257849
Look up Linux on an 8-bit, that guy made an ARM emulator that ran Linux from an atmega, so maybe you can do something like that
>>
>>58258007
Just like cancer
>>
int int_sum(int a, int b) {
return a + b;
}

long long_sum(long a, long b) {
return a + b;
}

float float_sum(float a, float b) {
return a + b;
}

double double_sum(double a, double b) {
return a + b;
}


"Wow, so simple and beautiful." -- /dpt/

template <class T>
T sum(T a, T b) {
return a + b;
}


"ugh why is C++ so bloated lmao." -- /dpt/
>>
I just started using jj as escape in vim
why haven't I done this before

I always used caps-lock as escape, but this is amazing
>>
>B...but Go is as fast as C
Ok, kid.
http://blog.burntsushi.net/ripgrep/#code-search-benchmarks
>>
>>58258007
Most of the code can be built with a c compiler (or a GNU c compiler to be precise).
>>
>>58258228
>Most
But not all.
>>
When are you guys going to accept Go
>>
>>58258162
Some people use 'jk' and 'kj'.

>>58258250
I was going to say
>when it ... embraces FP and the last 30 years of PL theory in general.

But this guy beat me to it: >>58258391
>>
>>58258250
Never, the only thing that Go's got going for it are goroutines.
>>
How important/used are nested classes in Java?
>>
File: 12.png (1MB, 1600x900px) Image search: [Google]
12.png
1MB, 1600x900px
>Futaba can't be improved
>>
>>58258676
You made it worse you sick bastard
>>
File: Capture.png (43KB, 634x548px) Image search: [Google]
Capture.png
43KB, 634x548px
>>58258391
>>58258460
>>58258514
So is all this Go shilling I'm seeing just Google bribing people to make their language popular?

I agree with the embrace FP, hell even C# is embracing some FP features. But I don't see how it's deviating from 30 years of PL theory.

Because there are some pretty cool things that are
>>
>>58258921
too autistic to finish my post.

There are some pretty cool things built in go like
https://github.com/ipfs/go-ipfs

https://github.com/tidwall/tile38

https://github.com/alexflint/gallium
https://github.com/simeji/jid
>>
>>58258921
>OOP
>PL theory
>>
>>58258921
Go is just a shitty ALGOL-67 with coroutines.
>>
>>58251812
>haven't fapped in 4 months, stopped getting urges long ago
>see /dpt/ thread and decide to start a programming project after 11 months of no programming
>start gb emulator project to learn Rust
>3 hours in sudden urge to masturbate
Will it go away if i ignore it?
>>
>>58259119
Perhaps it's just my CS freshman showing then. I don't know why the go language is so attractive to me.

I think google is just shilling their language hard.
>>
>>58259231
Only if you dress up like the little girl.
>>
>>58259248
I'm pretty sure the vast majority of the language's use is just internal at Google.
>>
>>58259231
>stopped getting urges long ago
did you penis get damaged?
>>
>>58258921
Go is like a shit sundae combining the worst of both C and Java with a goroutine cherry on top.
>>
File: 14.webm (588KB, 1280x800px) Image search: [Google]
14.webm
588KB, 1280x800px
>>58258801
It can always be worse
>>
>>58259381
actually i don't see anything wrong with this one
>>
>>58259381
cute
>>
File: Untitled.png (907KB, 960x810px) Image search: [Google]
Untitled.png
907KB, 960x810px
>>58259381
I like the band of text over the images. I think I'll try to code something like that.
>>
>>58259434
Expect the catalog to become a beautiful giffy fest after a while. Though it would be ok if the community stays small and nobody abuses this for attention.
>>
File: 1402242508454.png (6KB, 419x249px) Image search: [Google]
1402242508454.png
6KB, 419x249px
Do you think it's possible to shift in and out data with the same 3 pins and an attiny13?
Should I try this tonight?
>>
>>58259643
Not unless you can handle 1GB of garbage per second.
>>
Why do you have to realloc from the first address in allocated memory? Why can't you just append memory to the end of the memory you allocated in the first place?
>>
File: what.png (68KB, 1127x473px) Image search: [Google]
what.png
68KB, 1127x473px
>>58259671
No i want to use 74HCT595 shiftout and 74HCT165 shift in registers

>be me
>know that I have done shift out on attiny13 already somewhere
>look into folder
>WHAT IS THIS SHIT?
REEEEEEEEEEEEEEEEEEEEEEee

I have no backup of this. I really should rethink my backup strategy. FUck me.
>>
File: 1472746453140.jpg (49KB, 600x488px) Image search: [Google]
1472746453140.jpg
49KB, 600x488px
>>58259697
>it's all in German
Found your problem.
>>
>>58259724
>He is not using masterrace language
wat
>>
>>58259731
Just informed the Chancellor about this.
>>
>>58259731
I am not a stronk Aryan overlord :(
>>
>>58259738
I did this sometime, but somehow stopped using it. Maybe I should start again.
>>
File: 7777908287973903.jpg (133KB, 700x700px) Image search: [Google]
7777908287973903.jpg
133KB, 700x700px
>>58259731
>masterrace language
kek
You misspelled polish.
>>
>>58259955
>polaks
Ew groce.
>>
File: 76.png (17KB, 900x900px) Image search: [Google]
76.png
17KB, 900x900px
What does /dpt/ think of p5.js?
>>
What if we started from a premise that features such as higher-kinded types are mandatory in any new programming language?
>>
>>58260223
As cancerous as frogposters.
>>
>>58260223
Fuck off, redditor.
>>
>>58260236
I'd like that.
>>
>>58260236
Dynamists would commit suicide en masse
>>
>>58260275
New dynamically typed languages simply wouldn't be allowed.
>>
>>58260275
There wouldn't be any
>>
>>58260236
It would be difficult to reach a consensus on what the mandatory features should be.

However, I think this would be a good start:
Sum types (not just product)
A REPL
Type inference (if statically typed and not undecidable)
First class functions
A working package/library manager
>>
>>58260313
I mostly agree.

>Type inference (if statically typed and not undecidable)
A static type system should be mandatory.

>Sum types (not just product)
Generic programming functionality for sum and product types, too.

I would also add a good cross-compilation story, the absence of null, higher-kinded and higher-rank types, and opt-in totality and purity checking, e.g. being able to mark a function as total and/or pure and it be a compilation failure if the function does not satisfy those properties.
>>
>>58260313
>Sum types (not just product)
Shouldn't be mandatory, as sum types can be implemented with product types. Unless you're talking about dependent types, in which case you need some extra mechanism for dependent pattern matching (the simplest would be an enum with dependent elimination, which can be used with sigma).

>>58260330
Yes, template templates are HKTs.
>>
>>58260364
>sum types can be implemented with product types
I hope you're not talking about e.g. representing
Maybe a
as

forall b. (a -> b) -> b -> b
>>
>>58260330
>depressingly small
Just think of all the terrible languages you'd never have to use, anon.
>>
ITT


>what if we started from the premise that all languages were Haskell?
>>
>>58260408
Haskell isn't the only language with a usable type system.
>>
>>58260398
Sure, why not?
>>
>>58260411
>
>>
>>58260436
Don't worry, you'd still be able to use Java, JavaScript and Python, they just wouldn't get any updates or fixes ever again.
>>
>>58260408
You realise that Python meets all of those requirements, right?

It's just that its 'sum types' (enums) are shitty.
>>
File: 1482164713193.gif (178KB, 281x484px) Image search: [Google]
1482164713193.gif
178KB, 281x484px
>>58260485
> Python meets all of those requirements
>Python meets ANY of those requirements
>>
>>58260506
>Sum types (not just product)
Enums.
>A REPL
Enter 'python' into your terminal. It defaults to REPL.
>Type inference (if statically typed and not undecidable)
Not statically typed, so not applicable.
>First class functions
Yup.
>A working package/library manager
Pip.

I *wrote* the damn list. Did you even read it?
>>
File: 1479605643910.gif (3MB, 445x247px) Image search: [Google]
1479605643910.gif
3MB, 445x247px
>>58260541
>Not statically typed, so not applicable.
>>
>>58260576
Yup. I put that in because it's not applicable to dynamically typed languages.

>Python meets ANY of those requirements
So you've backed off from claiming Python meets none of the requirements to desperately pretending that it's statically typed? Job done.
>>
word up, god

check it:

4d cellular automata
>>
File: 1482611332506.gif (371KB, 500x281px) Image search: [Google]
1482611332506.gif
371KB, 500x281px
>>58260615
>Yup. I put that in because it's not applicable to dynamically typed languages.
>>
>>58260628
>I've realised that it does actually meet requirements, so I'm going to ignore PLT and post reaction faces and greentext
>>
File: 1471719526619 (1).gif (844KB, 800x786px) Image search: [Google]
1471719526619 (1).gif
844KB, 800x786px
>>58260645
>my language doesn't meet the requirements
>therefore the requirements are not applicable
>therefore my language meets the requirements
>>
Happy New Year, /dpt/.

Guys, how can i replace all whitespaces or comma-whitespace combinations between two other combinations using regexp? An example here (Javascript):
myString = "function(bla, bla, bla), function(bla, bla, bla) function(bla, bla, bla);

I tried this:
result = myString.replace(/,?\s/g, "X");

It works fine, but it applies to all combinations, into brackets too. How can i show to my pattern ")" and "function"?
Sorry for my bad english.
>>
>>58258228
*GNU Compiler Collection
>>
File: 1474386509445.jpg (181KB, 1031x965px) Image search: [Google]
1474386509445.jpg
181KB, 1031x965px
>>58260677
>I've already been proven wrong in my claim that it meets none of the requirements, now I'm trying to misinterpret them to claw back some credibility
>>
>>58260645
>I'm desperate for Python to be allowed because it's the only language I can use
>>
>>58260738
You're right that I was wrong.
Python doesn't meet NONE of the requirements.
Python has a REPL
>>
There is no reason to use a dynamic language any more.
>>
>>58260742
Ha, I'm a Haskellfag. I was just saying >>58260485
because people seemed to think Haskell was the only language that met them.

>>58260750
See >>58260541
>>
>>58260762
Ok, so the first requirement:
Where are the HKTs in Python?
>>
>>58260762
If Haskell were the only language to meet them then it would be the fault of the authors of other languages for making such shitty languages.

I'm tired of being told that features I use every day are "not that important" or "not practical".
>>
>>58260786
The problem is people don't know how to quit OOP, and how to drop old languages
>>
>>58260777
I never said anything about HKTs, bra.

>>58260786
That's my opinion, too. I see that list as pretty sane and basic.

Lack of sum types in particular is just madness, IMO.
>>
>>58260807
>I never said anything about HKTs, bra.
That was literally the first fucking requirement you fucking dumbass.
>>
>>58260814
Not on my list, you angry, angry, dude.

I'm not going to defend someone else's requirements; too much effort.
>>
>>58260831
Yeah, I would definitely be swayed into including pattern matching, too.

Something Python doesn't have, for all you Python-lovers out there :)
>>
Hey remember when anon made this post? >>58260236

Oh wait, that post wasn't made by the snakefag, and it's something Python doesn't have, so it doesn't count, even if it literally started the conversation and everyone else agreed
>>
Why is web dev so convoluted? It's worse than systems programming, not because you're actually doing anything difficult but because you're stacking dozens of frameworks one on top of the other and forced to learn all these arbitrary APIs and nuances for each one.
>>
File: 1480553702624.jpg (112KB, 625x600px) Image search: [Google]
1480553702624.jpg
112KB, 625x600px
>>58260803
The problem is people don't realize than ASM is enough.
>>
File: 1466867038185.jpg (25KB, 800x609px) Image search: [Google]
1466867038185.jpg
25KB, 800x609px
>>58260876
>ASM is enough
BUT THAT'S WRONG
>>
>>58260876
>*that
w/e happy new year anonymous!
>>
File: 1475664033489.jpg (68KB, 633x758px) Image search: [Google]
1475664033489.jpg
68KB, 633x758px
>>58260876
>tfw modern OSs don't offer assembly APIs so you're forced to defile your beautiful assembly code with ugly calls to C functions
>>
>>58260918
>>58260876
>>tfw 16 and think ASM is cool
>>
>>58260876
>implying ASM is enough
ASM can still be slow and bloated if people are morons
>>
>>58260876
>ASM
>not pure binary
I didn't realize this board was full of amateurs
>>
>>58260851
I'm not going to defend your opinions for you, bro; too much effort.
>>
>>58260950
>pure binary
>not butterflies
ISHYGDDT
>>
>>58260876
ASM is fucking horrendous and you should feel fucking horrendous.
>>
>>58260968
>referencing that webcomic
>>>/reddit/
>>
>>58260930
Human-written assembly is almost guaranteed to be slower than what your compiler shits out. Even the idea of using assembly to optimize a specific section of code is pretty much dead these days. The only time you should realistically drop down to assembly is to bypass a bug in your compiler, which isn't likely to happen in normal usage...
>>
>>58260960
>my favourite language is literally the perfect language when you only pay attention to a list of my favourite features bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro bro
>>
>>58260968
>le xkcd redd*t meme
>>
>>58260883
>>58260928
Just imagine everything made as simple as possible and actually having to think thoroughly about your algorithm. Hell it would finally bring back programming on paper.
>>
>>58260988
Haha, but I'm a Haskellfag! I don't use Python...

And I'm still not going to defend your list for you, bro :)
>>
>>58261000
>everything made as simple as possible
Like Haskell.
>>
>>58260979
>>58260993
>implying that isn't actually built into Emacs
M-x butterfly

>>58260987
I'm talking slow and bloated compared to say Haskell, Lisp, and other interpreted languages. Completely agree that, except for some tight loops, handwritten assembly is slower or unneeded
>>
>>58261028
>hey guise i'm so cool i implemented this basic algorithm in assembly!!1 lol u dont need a high-level language
>>
>>58261053
Except for web development and mobile, I don't see a need for anything higher level than C++
>>
>>58261074
http://paulgraham.com/avg.html
>>
>>58255618
C then perl.
>>
>>58261075
Good luck creating a X11 window.
>>
>>58255618
C.

Rust in a few years if:
1) It actually becomes widely used
2) It transpires not, in fact, to be shit
3) The SJWs emigrate from its culture
>>
What's the best way to pick up haskell or perl?
>>
File: karen haskell.png (818KB, 1280x719px) Image search: [Google]
karen haskell.png
818KB, 1280x719px
>>58261188
(HASKELL)

Check out /fpt/
>>58244769

The links there are good.
The book pdf linked is apparently excellent, and wikibooks is really good.

Ask there if you have questions.
>>
Enhance image post-processing using WebGL via three.js.
>>
>>58261184
>2017 - 20 minutes
Go back to your vodka, Ivan
>>
>>58261188
I'm going to try and avoid pointing out there are more than two languages to choose from, but fail miserably.

Perl is dead and yet somehow getting deader fast.

With Haskell, you'll probably need to start slowly (particularly if coming from imperative languages).
Install GHC and spend a lot of time playing around in the REPL while reading introductory texts.
Try 'Learn You a Haskell For Great Good', or the links in /fpt/.
If you get stuck, come to /fpt/ and ask. Pretty much everyone there is a Haskeller.
Soon you'll be writing illegibly terse monadic nonsense and producing 1GB of garbage per second like the rest of us.
>>
>>58261420
Happy new year.
>>
>>58261420
>>58261480
It's 9 o'clock
>>
>>58261524
It's 4pm where I am anon. The other anon is currently in GMT+3
>>
>>58261553
You can't add to GMT.
GMT is perfect.
>>
>>58258921
>So is all this Go shilling I'm seeing just Google bribing people to make their language popular?

Well yes, Google made Go just so they could have a simple language for their interns to grasp. Cheap labor with low entry barrier.
>>
>>58261571
GMT+10 is perfect, mate.
>>
>>58261623
GMT is about 10 hours off.
>>
Should I wear the free hoodie I got from my employer which has their company logo on it?
>>
>>58261623
Please write UTC+10 next time.
>>
C Hoвым гoдoм, /dpt/!
>>
>>58261780
No, Pajeet. I won't.
>>
>>58261176
Rust has too many fundamental design flaws to ever replace C. The safety checks make it slower than Go even though Ada has superior safety and security features and runs faster than Java.
>>
>>58261695
Unless you really really like the company, then no, that's just trashy.

Put it this way.
If you would go out of your way to buy it with your own money, then sure, go ahead and wear it.
>>
>>58261695
What's the company?
>>
>>58261803
Happy GNU Year
>>
>>58261910
ATS will consume them all.
>>
>>58261910
How does Ada handle memory management?
>>
>>58261910
I'm glad the Ada shilling has continued in my absence
>>
>>58262104
Ada is cute. Cute!
>>
File: Untitled.png (3MB, 1920x1080px) Image search: [Google]
Untitled.png
3MB, 1920x1080px
>>58259496
this'll be way easier than I thought. just need to add a text background now.
>>
what if i say i want to build somethihng and i do btu teh solutions are always far from elegant. should i feel bad?

s 8 c 10
c A c 9
{'h': [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], 'c': [2, 3, 4, 5, 6, 7, 8, 11, 12, 13], 's': [2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 14], 'd': [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]}


this is the output to some code i wrote fro a texas hold em game i'm making. it works, there's like a few errors that can be fixed, but to get this output my code is so bad.
>>
>>58262082
Don't forget:
+ ADTs magnify the memory consumption of any data structure and using them for "exception handling" completely nullifies branch prediction
+ Rust devs harp on the value of generics but the design they went with is not compatible with the native array type because they can't have a number as a template argument
+ No inheritance and no way to fake it, which upset the Servo devs because it prevents them from making a fast DOM implementation

I'm sure the smart people here can name a few more
>>
>>58262075
You got a few options, depending on what you need. Best choice is scoped dynamic memory pools. You can also do C style allocate and free, but calling free isn't exactly a good practice. You can also use the myriad of bounded data structures to keep everything 'mostly' on the stack.
>>
new thread when?
>>
new thread: >>58262347
>>
>>58262301
+ No HKTs
+ Limited higher-kinded polymorphism
>>
>>58262301
>magnify memory consumption
Because of the compiler.
There's no theoretical reason your compiler can't see

data MyType = Left Bool | Right Bool


and store it in a single byte

>branch prediction
How?
>>
>>58261695
dont spend money on clothes
i like to pretend i live in star trek
all my clothes (except undies) were free!
>>
>>58262344
>>58262350
Are you guys retarded?
>>
>>58264098
About 16 posts have been deleted from this thread.
I made that at 311.
>>
>>58264098
>>58264131
Looking from some of the posts that were deleted, it's possible someone was banned and had all his posts deleted.
>>
>>58264131
Oh, sorry. Why were they deleted?
>>
archive list
http://ar.vyrd.net/
Thread posts: 299
Thread images: 39


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.