[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: 319
Thread images: 31

File: 1397117351711.png (176KB, 441x421px) Image search: [Google]
1397117351711.png
176KB, 441x421px
Old thread got hotpockets. What are you working on?

Old thread: >>56274707
Old old thread: >>56266496
>>
If youre goal is to get an entry level programming job, would php be the easiest way to go?
>>
>>56275136
>Old thread got hotpockets.
What? Why?

>What are you working on?
Benchmarking util for measuring bw and latency of GPU to GPU RDMA
>>
>>56275136
implementing spreadsheet in webapp

pretty pointless, but whell
>>
>>56275154
>What? Why?
Probably the 3D in the OP image.
>>
>>56275153
>youre
Yeah I meant your. I'm not brain dead I swear.
>>
>>56275153
If you have some self respect at least start with python (+django if you wanna make webdev)
>>
>>56275153
I'd almost consider webdeb to be only tangentially related to programming at this point. Should probably give >>>/g/wdg/ a look if you want to get into that part of computers.

>What are you working on?
Program automation in memesnake.
>>
File: Calculus of Maki Constructions.png (312KB, 452x355px) Image search: [Google]
Calculus of Maki Constructions.png
312KB, 452x355px
dependent
types
>>
File: Cola.Gotouryouta.full.1982533.jpg (2MB, 1300x1276px) Image search: [Google]
Cola.Gotouryouta.full.1982533.jpg
2MB, 1300x1276px
Can somebody explain this code to me?
I don't get it at all.
https://en.wikipedia.org/wiki/Recursive_descent_parser#C_implementation
>>
>>56275310
What specific part do you want explained first?
>>
>>56275201
>>56275250
So webdev is the easiest avenue for entry level?
>>
File: mfw got my keyboard.gif (502KB, 480x270px) Image search: [Google]
mfw got my keyboard.gif
502KB, 480x270px
I reworked my database fetching code on my C commentboard so I no longer have to drag the entire database into memory when displaying content!

http://45.32.80.36/board.cgi
todo: view posts by pages, with offsets
>>
>>56275323
The purpose of accept() and expect() for instance.
>>
File: 2016-08-26-123830_391x43_scrot.png (2KB, 391x43px) Image search: [Google]
2016-08-26-123830_391x43_scrot.png
2KB, 391x43px
wait, hold on, hscurses's newWin says it returns an IO Window
and a Window is pic related
does that mean I have to do pointers
wtf, I don't even know C
what am I supposed to use here, senpai
>>
>>56275458
The input to the parser is a stream of tokens. You call accept() to check whether the next item in the input is a certain kind of token, so you can decide what to do next. The expect() function is a wrapper around accept(), with the semantics of "this MUST match, or this isn't a valid parse and we have to quit."
>>
>>56275423
I wouldn't call it the "easiest" since it's got its own subset of challenges but it's not like CS where you need a degree because of the type of thinking involved (hence one reason why it's not really respected 'round these parts).
>>
File: 1468899863437.jpg (95KB, 394x404px) Image search: [Google]
1468899863437.jpg
95KB, 394x404px
post a screenshot of your programming environment (ide, terminal, code, etc)
>>
>>56275538
>learning haskell before C

Try again.
>>
>>56275664
pointers r hard
>>
>>56275705
they're just comonadic arrays
>>
I listened to you fags and learned C before C#.

I'm glad I did this, despite how long it took.

I want to make one useful program with it to put in my portfolio before I move onto C#. Recommendations?
Something that will use a lot of aspects of the language.
>>
Say I have a vector of pointers to objects.

std::vector<object*> vector;

And I have multiple classes with object as a member and I want my vector to hold pointers to members of instances of those classes. For instance:

vector.push_back(&classInstance.member);
vector.push_back(&class2Instance.member);
vector.push_back(&class3Instance.member);

Would there be any reason why this would only work for some classes and not others? I'm really scratching my head here. The members are all public.
>>
>>56275840
a compiler
>>
File: emacs.png (62KB, 1920x1050px) Image search: [Google]
emacs.png
62KB, 1920x1050px
>>56275652
>>
>>56275862
I'd rather suck a dick
>>
>>56275880
>alright guise, give me something to program that that will use a lot of aspects of the language.
>do a compiler
>fuck no, I'd rather suck a dick

that's why you'll never do anything worth in this life

thanks for playing.
>>
>>56275652
ok senpai
>>
File: 1467019345752.jpg (10KB, 180x157px) Image search: [Google]
1467019345752.jpg
10KB, 180x157px
>>56275878
>>56275921
>that colour scheme

>>56275880
fag
>>
>>56275538
IO motherfucker, do you know what it even is? And no you won't have to touch pointers beyond passing them around, it's just internals of the C ffi basically. Also how's ChType doing?
>>
>>56275878
>>56275921
why do people use dark backgrounds? I can't even read that shit
>>
>>56275929
no them, but what kind of difference does color make
>fag
yeah i agree
>>
Game engine for Ludum Dare at the weekend
>>
>>56275921
>nano
Learn a better editor.
>>
>>56275955
It's quite readable.
You're just a junkie who can't handle bright lights.
>>
>>56275961
>what difference does colour make
Are you blind and using braille?
>>
>>56275955
Are you blind, on a laptop, or just have a shit monitor? I need dark backgrounds or I want to gouge my eyes out.
>>
File: anal beads.png (641KB, 4920x1920px) Image search: [Google]
anal beads.png
641KB, 4920x1920px
>>56275652
Threw some shitty old code up there because almost everything I'm writing right now has personal info.
>>
I want to write a http router.

It basically comes down to using a tree structure but now is the question:

Should I use a radix tree or a patricia tree? Are the performance benefits of the patricia tree so big that it's worth the more complicated model?
>>
>>56275979
well it's hard to bring a desktop on campus
>>
>>56275979
Black background + neon text = eye rape.

The contrast is jarring.

See >>56275991 for a much better dark theme.
>>
>>56275954i jus put the char in a string and use wAddStr, much easier that way
>>
>>56276029
The real eye-rape is black text on a white background. I need to write custom stylesheets for websites that do this (like Wikipedia)
>>
File: vi_environment.png (109KB, 1440x900px) Image search: [Google]
vi_environment.png
109KB, 1440x900px
>>56275652
Typical monochrome vi.
>>
File: This..gif (2MB, 960x547px) Image search: [Google]
This..gif
2MB, 960x547px
This.
>>
>>56275878
how do u have autocompletion?
>>
File: ass.png (67KB, 699x404px) Image search: [Google]
ass.png
67KB, 699x404px
>>56276052
No arguments here; white background + black text is even worse.

I'm not sure why you're writing custom sheets. Stylish has dark styles for almost all websites.

Pic related for comparison of a muted dark theme vs. an eye-rape dark theme.
>>
>>56276029
If you are going to use a terminal with a black background and bright text, using red text color seems to work fine for me.
Still appeals to my preferences and doesn't go harder to town on me for color contrast than an sjw on a bad day.
>>
>>56276087
The eye rape dark theme though is more useful if, per say, I am using my laptop and coding on a train, and don't want to waste battery through increasing the screen brightness.
The high contrast allows things like syntax elements to still be easily readable with the screen barely being lit, though that may play into the fact it rapes your eyes are regular brightness in the first place.
>>
>>56276100
>If you are going to use a terminal with a black background and bright text
Why would you?

I can't think of a single situation in which you would be forced to do this.
>>
95% of all the posts in these threads are people bikeshedding about "what's the best editor", "how can you use that color scheme", indentation types and variable/function naming cases. It's pathetic.
>>
>>56276138
last thread was arguing about mathematicians
>>
>>56276134
My explanation as to why I would be doing this was in my follow up message.
It has to do with screen brightness and battery consumption when I'm coding while traveling.
>>
>>56276078
I use company-mode with the irony and irony-company backends. It uses clang so it works pretty well. I run it in a Gentoo VM because the Windows compatibility is pretty shit.
>>
>>56276133
>per say
>coding
>into the fact it rapes your eyes are regular

>programming on a fucking train

Which European shithole do you reside in? Going to take a stab and guess Germany.
>>
>>56275970
But I really like nano tho.

>>56276087
I'm not sure what you're trying to say with this post.
Gray on gray looks awful and is an eyesore.
>>
File: total.png (4KB, 399x67px) Image search: [Google]
total.png
4KB, 399x67px
>What if we insert code into our config files
>And allow executing functions from shared libs

http {
upstream database {
postgres_server [::1] dbname=user user=user;
}

location / {
postgres_pass database;
rds_json on;
default_type application/json;
set_by_lua_block $num { return 20 }
postgres_query HEAD GET "SELECT * FROM table WHERE id=${num}";
}
}


But apart from that is developing with lua_ngx really a breeze. Pic related, a small Chinese cartoon scrapper/archiver/backup.
>>
>>56276200

what does it actually do?
>>
>>56275862
Not same anon but isn't this something a little difficult for anyone who doesn't have years of C experience? How long would this take a novice to write? A year?
>>
>>56276178
Okay, those were typos, but my point is that high contrast does have its uses.

Though to make myself clear, I hold more a preference towards muted dark themes such as those found in Visual Studio and Android Studio.
>>
>>56276178
Also, do you realize how fucking boring it is to be on a train in Nordic Europe.
Especially Finland, holy shit, constant conifers with the occasional summer home for six fucking hours.

You should understand why I would pass the time programming.
>>
>>56276262
>how boring
>you're on a comfy train with internet and enough room to use a laptop

fuck you
>>
>learning x86 assembly
>mfw floats are actually 80 bits wide if you use the FPU

Why does not language support this? Why does no language explicitly support SIMD shit without instrinsics?
>>
>>56276288
I don't typically use the internet on a train.
Don't have a reason to unless I just give up debugging something on my own.

Also the boredom from scenery is because I tend to be someone who studies my surroundings, so yeah.

Good day sir.
>>
>>56275840
>C
>useful program that can be done with almost no C experience

Anon...

>>56276262
Music
Books
Movies
Anime

Anon, I drive six hours within my state regularly, and I'm happy enough with just music.

I can't imagine trying to get anything productive done in any of my major codebases while traveling.
>>
>>56276236
wriiting a compiler usually takes the following steps (and others not mentioned):

>Parsing:
>Lexical Analysys
>Abstract Analysis

>Semantic Analysis
>Code generation

you should probably take a few months, its not expected from you to write a full-blown compiler, just a simple one, to understand the underlying concepts

In my college, you have to write one for the Compilers course, (the course is 3-4 months)
>>
>>56276305
If you want a fun time, try writing your own printf() that supports printing floats and doubles. Float -> string is fucking rocket science
>>
>>56275954
can you give me an example?
>>
>>56275840
Why are you glad you learned C first?
>>
>>56276335
I'd rather not. Binary representations of floats hurt my brain.

>mfw bias
>mfw omitting the leading zero

What the fuck is this shit?
>>
>>56276313
It really just comes down to if I have some idea, problem or algorithm issue bugging me.

If so I'm more inclined to program when traveling.

Otherwise I listen to music, write in my engineering notebook (book for my schematics, thoughts and other ideas), or read a book.
>>
>>56276345
because i can't see sharp
>>
the japanese professor in my math class was talking about a problem and said "Now we know A is equivalent to B, but here is the more difficult question... is B equivalent to A?" and all the black guys in their corner said "no". is it possible black people are unintelligent?
>>56275154
posting 3dpd is a bannable offense
>>
File: res.png (18KB, 918x351px) Image search: [Google]
res.png
18KB, 918x351px
>>56276231
You can POST a query like
{"title":"re: zero","method":"search","offset":0}
and the server generates a response from the scrapped data.

Had the idea long ago when nyaa had occasional downtimes. Since the switch to cloudflare that's redundant of course.
In uni they teach you everything about databases but never make you actually use one, so still a nice experience.
>>
>>56276368
If A == B, why would B != A?
>>
>>56276355
Oh come on, IEEE754 is not that hard. We did this on pen&paper in class.
>>
>>56276059
Oh shit ahoviewer RIP.
>>
Anyway, I'll get going.
Thanks for the chat /g/.
>>
>>56276420
no, what if you're important to the discussion?
>>
>>56276408
Why should I bother is cumbersome shit that has already been solved for me?
>>
>>56276305
>Why does no language explicitly support SIMD shit without instrinsics?

Because
>muh portability

For some reason, programmers seem to think we live in a universe where 99.999999% of all relevant code doesn't run on x86-64 and think we should cater to other platforms.

Check out https://ispc.github.io/ for a compiler that isn't written by retards.
>>
>>56276433
I'm not, at least not now.

I just had an argument with somebody over background vs. screen contrast which somehow morphed into how best to spend time on a European transit train.

Believe me, this isn't prime time material.
>>
>>56276393
he was trolling to see what retards would say "no"
>>
>>56276393
Javascript.
https://www.youtube.com/watch?v=wjYlw_VtPtw
>>
>>56276478
God damn it, another typo.
* background vs. TEXT contrast
*facepalm*
>>
wtf, how do I box in my newWin?
>>
File: sopranos.png (226KB, 406x307px) Image search: [Google]
sopranos.png
226KB, 406x307px
Anyway I need to leave.
/g/ board has a way of keeping you hooked.
>>
>>56276531
farewell
>>
>>56276531
see you in 10 minutes
>>
I'm thinking about writing a C++ esque language for my bachelor thesis that is designed around x86, especially later editions like bit manipulation and AVX. Something like this:

float80 f = 1/2; //uses the fpu
float32 g = 66*0.3 //uses scalar sse

SSE:float32 v = {0.1, 0.2, 0.3};
SSE:float32 s = {5, 10, 12};
auto result = v * s; //single instruction
>>
>>56276548
meant to reply to >>56276476
>>
Can someone explain merge sort to me?
>>
>>56276558
shart in mart
>>
>>56276582
https://en.wikipedia.org/wiki/Merge_sort
>>
>>56276582

Given two separate lists A and B ordered from least to greatest, construct a list C by repeatedly comparing the least value of A to the least value of B, removing the lesser value, and appending it onto C. When one list is exhausted, append the remaining items in the other list onto C in order. The list C is then also a sorted list.
>>
>>56276393
a non symmetric relation?

>>56276585
Can you stop spamming this every fucking thread you autistic son of a cunt?
>>
>>56276604
>Can you stop spamming this every fucking thread you autistic son of a cunt?
triggered, americuck?
>>
>>56276604
Just ignore it.

She's going to call you a butthurt American now because you responded negatively.
>>
>>56276582
you have to understand recursion first. then understand that the first item in a sorted list is the smallest, so to combine 2 sorted lists you just compare the first items and take the smallest, then compare the first 2 again etc. comparing 1 item per list is more efficient than comparing both entire lists against each other every time
>>
File: IMG_20160826_180432.jpg (3MB, 4128x3096px) Image search: [Google]
IMG_20160826_180432.jpg
3MB, 4128x3096px
I am at work,
So can't copypaste from a laptop I am usually doing.

How could I generalize this Java code any further?
>>
>>56276548
This is a pretty cool idea.
Keep it up.
>>
is it normal to want to masturbate all the time when coding?
>>
>>56276633
I would have to take courses on compilers first. I imagine that shit is not easy, otherwise everyone would just add custom features to existing languages instead of bugging the committee.
>>
>>56276623
>>56276599

Is this a valid implementation?


def mergeSort(a, b):
mergelen = len(a) + len(b)
ab = []
while min(len(a), len(b)) > 0:
if a[0] < b[0]:
ab.append(a[0])
a = a[1:]
elif b[0] < a[0]:
ab.append(b[0])
b = b[1:]
return ab

>>
>>56276638
Found the Haskell programmer.
>>
>>56276638
Do you take any stimulants like adderall or caffeine tablets? If yes, there is your answer.
>>
>>56276337
>an example of IO
main = putStrLn "Hello world"


Bruh do you even Haskell? IO is a monad (if you don't have an intimate understanding of thus word go back to LYAH or whatever you're learning with, you just can't jump into hscurses at the moment) that represents all non-pure operations such as input/output (hence the name), using the system clock, getting random data from the OS for use in cryptography, FFI calls and such. Officially you can't "run" IO actions and get their results plainly like you could with runState for example, you have to chain your code into a new
IO something
all the way up to main. Note that this still allows most of your code to be pure.
>>
>>56276638
Yes
>>
>>56276638
Only if you're wearing a skirt.
>>
>>56276625
public static int Count(String s) {
int count = 0;
for (int i = s.split()-1; i >= 0; i--) {
char c = s.charAt(i);
if (c == '(') {
count++;
} else if (c == ')') {
count--;
}
}

return count;
}


what do you mean generalize?
>>
>>56276669
perform mergesort on a list manually on a piece of paper, understand the actual algorithm, and then translate it to code. don't type blindly and hope you come across the correct solution
>>
>>56276679
sorry, I meant for Window
I know how IO works
and I figured that I was working with Window all along, (stdScr :: IO Window)
>>
>>56276688
*length not split ftfy
>>
>>56276625
Turn it into this:
int Count(Iterator<T> collection, T increment, T decrement) {
int count = 0;
for (T item : collection) {
if (item == increment) count++;
if (item == decrement) count--;
}
return count;
}


I can't be bothered checking if it compiles, I might have made some small mistakes. But the general principle should work. Might have to use equals() instead of == depending on how you want to compare.
>>
>>56276727
I'm not into curses neither in C nor in Haskell dude. Maybe in https://hackage.haskell.org/package/hscurses-fish-ex ?
>>
>>56275652
Don't feel like screenshot.

3 putty windows open with vim and another sitting on the command line. Alt-tab is easier than fucking with windows or buffers. Honestly, I'm half tempted to write my own editor. I'm just not completely happy with vim or emacs. Don't meme me up with spacemacs, it's a bloated pos.
>>
>>56276669
It's a correct implementation of the merge in merge sort. You can merge two sorted sequences with that, but you can't sort one unsorted sequence entirely. Don't delete it tho.
>>
>>56276795
Literally what is wrong with Emacs + Evil? Frankly vim is shit-tier just because of the atrocious plugin system. At least elisp is very easy to hack together.
>>
File: Screenshot_2016-08-26_13-23-26.png (1MB, 1599x899px) Image search: [Google]
Screenshot_2016-08-26_13-23-26.png
1MB, 1599x899px
>>56275652
>>
>>56276830
Emacs and Spacemacs especially are slow and crashy as fuck. It's just insufferable. NeoVim is where my hopes an heart lie.
>>
>>56276872
>Emacs and Spacemacs
Spacemacs is just an emacs configuration.
I also never had a problem with the speed of Emacs nor any problem with crashes.
>>
>>56276877
Spacemacs is garbage shit. The maintainers don't give a fuck about it and just throw everything in. A minimal Emacs configuration is incredibly stable.
>>
>>56276368
if we're talking sets, that could be true right? Or is the terminology way more different
>>
>>56276900
>>56276877
What does 'Spac' mean?
>>
>>56276676
Two espressos and ritalin.
>>
>>56276939
Space means space
>>
>>56276959
she clearly said Spac Emacs
>>
>>56276877
Makes sense given that no 2 users are the same, but OMG that bootup time even without comparing it to Vim is a nono. Are you running a daemon by any chance? And then it hangs or starts behaving badly and you have to restart. Granted I miss MaGit and UndoTree and Helm, but oh nvim, I would sell my soul for your future my beauty!
>>
Need some help with Java.

If the home button is pressed on a phone, the game is paused.
Upon resume, I want to check if the state at the top of my stack is PlayState.
I don't know how to write the if() statement. Help please.

@Override
public void resume() {
if(gsm.states.peek() == PlayState()) {
}
}

// initialising the stack in another class
public Stack<State> states;
public GameStateManager() {
states = new Stack<State>();
}
>>
>>56276906
do you know what the word equivalent means?
>>
>>56276830
>plugin system
I could care less about plugins.

The thing wrong about all of them is that they try to be too general. You end up having to hack together stuff to get what I consider a minimal environment for developing.

I kinda like how godbolt works, where it compiles as you go and inserts the warnings/errors below their respectful lines. All navigation should be metakey based, and all formatting and manipulation should be command based. I'm just not familiar with lisp enough to write scripts and I think it's language is too ad-hoc (vimscript is even worse in this regard). It should be scriptable with any language with a C FFI or API. Only other thing I require is autoindent and syntax highlighting, both of which should be BUILTIN, plugins are too slow for that shit.
>>
>>56276968
???

>>56276969
No, I am not running it as a daemon but I hear that it improves the performance.
>>
>>56276974
thought so :V)
>>
>>56276979
>literally mental illness
>>
>>56276972
use
gsm.states.peek() instanceof PlayState
>>
Is it true that Haskell programmers are literally too smart to be employed?
>>
>>56276979
Well, I agree with you. An Emacs with a C API for extensions would be my dream editor. I use Emacs because I need good autocompletion and the vim autocomplete plugins are dogshit.
>>
>>56277039
"Yes."
>>
>>56277039
No I am a Haskell programmer and I made $400,000 last year. Only do contract work
>>
What do you call a method that is solely used to call many other methods?

It doesn't really *do* anything on its own.
>>
>>56277032
you're amazing, thank you anon
>>
>>56277069
Driver?
>>
>>56277069
MethodController
>>
>>56277069
a slave driver
>>
>>56277132
I really, really like this post.
>>
>>56276055
A-are you writing Python with explicit semicolons?
>>
>>56277069
Depends what those other methods have in common. It could be called Initialize() or IgniteAndSelfdestructBear(). You don't name functions based on what they include in terms of control flow, statements, function calls etc. You name them based on what they are trying to accomplish.
>>
>>56277069
Useless
>>
File: GRecemm.png (18KB, 448x461px) Image search: [Google]
GRecemm.png
18KB, 448x461px
Pick your poison, /dpt/.

What do you usually use?

>Lambda?
>Foreach?
>Traditional?
>>
>>56277230
I write in Haskell so I don't have this problem
>>
>>56277230
1, 2 and 3 are not equivalent depending on the underlying collection. For that reason I always use 3 when I need something in order of index. If order doesn't matter I usually use 2. 1 is for when I want to use some fancy LINQ to return a subset of a collection.
>>
>>56277230
for elem in composite_keys:
\tfor ans in elem:
\t\tprint(ans)
\tprint()
>>
>>56277286
You could just say foreach instead of posting an unformatted snippet of code that doesn't even mimic what the person you're responding to posted.
>>
>>56277230
3 is the fastest. Always use 3.
>>
>>56277340
explain why is fastest
>>
>>56277340
>3 is the fastest.
Not necessarily.

It can use much more memory, too, depending on the implementation.

LINQ can defer evaluation until you actually assign or utilize a segment of the enumerable.
>>
>>56277328
yeah you're probably right huh
>>
>>56277369
It's 2016. You don't need to worry about memory.
>>
>>56277380
kill yourself
>>
>>56277380
LINQ can be faster to.

Contrivied example: you assign a lazy evaluated LINQ statement to a variable vs a traditional loop that iterates through those collections.

If you don't use either field, the LINQ variable will not take up CPU time or memory to process and store the results; it simply says "I'm here and I know how to retrieve this if you actually come and ask me for the results."

The traditional method would go through all the calculations, whether or not the result is later used.
>>
>>56277406
>to
too*
>Contrivied
contrived*

Shit, son. I need to stop getting buzzed at the office while arguing on 4chan.
>>
>>56275310
Why isn't parsing done with regex?
>>
>>56277453
regex is slow
>>
>>56277460
Not if you write it in C
>>
>>56277475
Okay, you should do all of your parsing with regex written in C.

Man, I sure am disappointed that I'll never be as good of a programmer as you are.
>>
>>56277453
Not all expressions are regular.
>>
>>56276368
>and all the black guys in their corner said "no". is it possible black people are unintelligent?
No they're super mathematicians is why they answered that way.
>>
>>56277475
xdddddd
>>
File: Capture.png (26KB, 532x579px) Image search: [Google]
Capture.png
26KB, 532x579px
anyone know where I could find naming conventions for sublime 3's language defining tool?

It's not on their website, and it's difficult guessing what sisters storage.type.function has

tried looking through their console too but no luck
>>
>>56277380

That's true. It's why freeing allocated memory is a relic of an earlier time. No longer necessary. Just wait until execution is done and that memory will be reclaimed.
>>
>>56277453
HTML
>>
>>56277540
https://www.sublimetext.com/docs/3/syntax.html
>>
>>56277380
t. modern sjw browser dev
>>
finished merge sort implementation in Python

any gud?

def merge(a, b, lt):
"""Assumes a and b are sorted lists.
It defines an ordering on the elements of the lists.
Returns a new sorted(by lt) list containing the same elements as (left
+right) would contain."""
result = []
while min(len(a), len(b)) > 0:
if lt(a[0], b[0]):
result.append(a[0])
a = a[1:]
elif lt(b[0], a[0]):
result.append(b[0])
b = b[1:]
if len(b) > 0:
for i in b:
result.append(i)
elif len(a) > 0:
for i in a:
result.append(i)
return result

def sort(L, lt = lambda x,y: x < y):
if len(L) < 2:
return L[:]
else:
middle = len(L)//2
a = sort(L[:middle], lt)
b = sort(L[middle:], lt)
return merge(a, b, lt)
>>
>>56277574
so?
i've written more code than you

https://github.com/Charlotteis
>>
>>56277557
I've already been down that
I'm looking for documentation on the specific names you can use, because they change what color your definitions take

like these take two different colors corresponding to the colors set by the skin in place under sublime:
<dict>
<key>comment</key>
<string>comments</string>
<key>match</key>
<string>\#[A-Za-z][A-Za-z0-9_]+</string>
<key>name</key>
<string>keyword.other.nm</string>
</dict>
<dict>
<key>comment</key>
<string>Anything that comes before = ...</string>
<key>match</key>
<string>.+=</string>
<key>name</key>
<string>string.quoted.double.nm</string>
</dict>

but they don't expand on it at all or provide a reference I can find
>>
>>56277591

holy shit is that actually you?

if so I'm so sorry
>>
>>56277591

Your eyes are too far apart. Nose is definitely crooked. The shape of your face is not aesthetically pleasing at all. You look like a 3/10 with make up in this photo. I don't even want to imagine what you look like without make up. I actually just threw up in my mouth, just thinking about it. Your head is too big (although that may be, because of your giraffe neck posture) . As for your hair, lol. Seriously, do something. You look like a horse. Stare at your face for more than 5 seconds, and you will see how ugly you are. The eyes which are too far apart is what ruins /damages an already ugly face even further. Unfortunately for you, that can't be surgically fixed, lol. You arms are way too long. lol at how they hang by your sides. Kind of reminds me of lurch. Don't even let me start on your pale complexion. It only works if you look hot. Unfortunately, you do not look hot. Its hard to sum up a creature like you in one word. 'UGLY ' would be unfair , since it doesn't reflect how repulsive you look. GROTESQUE is stretching it. But somewhere in between, is where you would be, on the scale of an average man. I'm sorry if my words seem a little harsh. Just so you know, I sugar coated this post as much as possible.
>>
>>56277591
>charlotte
girls' name
>>
I tried to create a brainfuck interpreter in Java, and it works for small programs like hello world, but takes forever and never finishes running anything larger.
):
>>
>>56277686

can you code my father in java please ;(
>>
>>56277686
Might have fucked up your jump table. Debug that code fuccboi.
>>
>>56277069
main?
>>
File: 1460612544671.jpg (33KB, 590x394px) Image search: [Google]
1460612544671.jpg
33KB, 590x394px
>>56277591
Holy fuck
>>
Anyone have a reading list? I know I've seen one thrown around and want to know what to look for in my library.
>>
>>56277747
>>56277635
>>56277619
>>56277641
thanks for the (You)s guys.

https://github.com/rust-lang/rust-www/issues/268
>>
>>56277768
No problem, I certainly got a laugh although it's just typical Rust
>I am proposing that we include 'gender identity and expression' in the Code of Conduct used for all of Rust.
>>
>>56277768

Klabnik is such a fucking cuck. He's good at language development (sort of), but I also hate him to death because he bent over to the SJ(e)Ws.
>>
>>56277796
>caring about other people's opinions make you a cuck !!!

Go back to pol we dont want you here
>>
File: 1471537085096.png (7KB, 220x165px) Image search: [Google]
1471537085096.png
7KB, 220x165px
>>56275136
Strong AI.
You?
>>
>>56277855

There's nothing pol about not wanting SJW culture to infect programming.

>inb4 (You)
>>
>>56277898
>SJW culture

Lol you "cuck". What does it even mean ?
>>
Got a memesnake question: I'm trying to have my script access a image located in a subfolder of the script's CWD for some minor image recognition, and I want to avoid hardcoding. What I've got "works":
scriptHome = sys.path[0]

def locate(img):
btn = p.locateOnScreen(img)
btnX, btnY = p.center(btn)
p.click(btnX,btnY,'left')

locate(os.path.join(scriptHome, 'elements\\connect.png'))


But is there a way to do something like:
def imgPath(img):
os.path.join(scriptHome, 'elements\\' + img)

locate(imgPath('connect.png')

just so I don't have to do os.path.join etc every time I call the locate function? My terminal spits out an AttributeError ('NoneType' object has no attribute 'mode') when I do what I wrote immediately above.
>>
>>56277972

I'm suggesting that Klabnik would let other men have sex with his wife.
>>
>>56278021
>is there a way to do something like
def imgPath(img):
os.path.join(scriptHome, 'elements\\' + img)

locate(imgPath('connect.png')


possibly, but i'm not a programmer, so i can't help
>>
>>56278059
ebin 5/5
>>
>>56278021
Yes instead of just calling os.path.join in imgPath return the joined path. The join function does not modify the input, it returns a new string.
>>
File: maki???!.jpg (111KB, 436x626px) Image search: [Google]
maki???!.jpg
111KB, 436x626px
I want to maintain a strict 80 character limit and my function declarations are preventing me from doing that.

Can I switch to K&R style to save horizontal space?
>>
>>56277882
Websocket server.
>>
>>56278074
>The join function does not modify the input, it returns a new string.
Makes sense, worked when I changed it to return as you said. I forgot it worked like that. Thanks for the knowledge.
>>
>>56278092
You'd only be saving one character with K&R style. You could do MicroSoft style which is
type function(
type arg1,
type arg2,
...
type argn)
{ }


I think they do it that way because the argument names and macro/enum names they use are fuckhuge.
>>
>>56278092
dont have more than 3 parameters for any function and dont have your function name be more than three words
>>
What are the most and least Pajeet languages?
>>
>>56278216
Most: Java
Least: Anything low-level or FP
>>
>>56278092
I used to keep to a strict 80-char limit, and now I'm more relaxed and only do it most of the time.

Get creative with rearranging things. Putting things on a new line is your friend. Like other(s) said, put your arguments on new lines. Either one line of their own, or one line for each parameter.
>>
>try to get a website
>error 403 forbidden
>change user agent to a web browser like firefox
>it works

What's the point of denying it when anyone in a position to actually abuse it knows how to circumvent it?
>>
>>56278247
I mixed parameter and argument there, but you get the point.
>>
>>56278256
post website
>>
>>56277591
>that pic
>that much js
This is bait
>>
Trying to make a program that calculates the number of hours, minutes, and second for a value of seconds that is >= 3600. Need help figuring out how many minutes are left AFTER calculating the number of hours. I know that to figure out the number of seconds given a value of seconds that are < 3600 is to do
seconds % 60
>>
>>56278274

torrentz2.eu, a torrent meta search engine.
>>
>>56278278
What's wrong with jS? It's good to use if you're a web dev
>>
>>56278325
It's probably a way of saying "fuck you" to unconventional browsers, not as a mean of security.
>>
Is it possible to do this in Python?

data.py:
points = []
values = []


main.py:
x = import points from .data
y = import values from .data
>>
>>56278280

import time
start = time.time()

def timeSince(time):
"""Prints the time since a given event, where time is a time given in seconds"""
days = time // (60*60*24)

hours_left = time % (60*60*24)
hours = hours_left // 3600

minutes_left = hours_left % 3600
minutes = minutes_left // 60

seconds = int(minutes_left % 60)

print ('The time, in seconds, since the epoch is {}'.format(start))
print ('It has been {} days, {} hours, {} minutes and {} seconds since your event.'.format(days, hours, minutes, seconds))

timeSince(start)
>>
>>56278342
Why don't you try it and tell us?
>>
File: Screenshot - 260816 - 21:21:20.png (13KB, 652x268px) Image search: [Google]
Screenshot - 260816 - 21:21:20.png
13KB, 652x268px
>>56278325
yeah, it works on firefox, but not in this browser
>>
>>56278349
Ahhh thanks dude. Thanks for telling me the math behind it.
>>
>>56278342

"Accessing" things from a different file? Just import them.

import data
print(data.x)
print(data.y)
>>
>>56278280
unsigned int totalseconds = INPUT; //your input value
unsigned int secondsleft = total seconds;
unsigned int hours, minutes, seconds; //outputs

hours = secondsleft / 3600;
secondsleft = secondsleft % 3600;
minutes = secondsleft / 60;
seconds = secondsleft % 60;
>>
>>56278383
I know I can do that, but I'd like to specifically import something and assign it to a variable rather than importing in general to current namespace and I'd rather avoid importing then assigning somewhere.
>>
>>56278366

Which browser is that?
I am using Python to do this, so I assumed they blocked its user-agent to prevent people from scraping their website or something.
>>
>>56278216
most: anyhting you use
least: anything I use
>>
>>56278398

Why not do "from data import x"?
>>
>>56278092
>80 char limit

Needlessly restrictive. 110-120 is fine, now.
>>
>>56278405
>Which browser is that?
dwb
>>
>>56275136
In python 3, is it possible to make
if x == y:
return a
elif x == z:
return b
else:
return c


into a one-liner? or does that only work for if else, instead of if elif ... els?
>>
>>56278451
Chaining ternary operators maybe.
>>
>>56278451
def foo(x,y,z,a,b,c):
return a if x ==y else b if x == z else c

print (foo(10,20,30,1,2,3))

output
3
>>
>>56278451
Possibly with a ternary operator, not sure if you can nest them in Python - not that you should ever nest ternaries.

In basically any C like language it'd be something similar to this...

return x == y ? a : x == z ? b : c;


I assume in python it'd work somewhat like this (if it were to work at all)

a if x == y else b if x == z else c


Welcome to try it out but I haven't touched Python so I wouldn't know.
>>
>>56278418
Because that'll just import into x variable in current namespace, what if I wanted to import these lists into object's instance members during object initialization and then mutate them independently?
>>
>>56278451
return a if x == y else b if x == z else c

Or with a dict, if x is hashable
return {y: a, z: b}.get(x) or c
>>
>>56278476
>>56278503
>>56278507
Thanks guys, I've got it figured out now.

return a if x else b if z else c


instead of elif statements was the solution
>>
>>56278342
from .data import points as x
you see this a lot with numpy and scipy etc
>>
File: 1470601624540.jpg (210KB, 500x509px) Image search: [Google]
1470601624540.jpg
210KB, 500x509px
>>56277591
>poopthis
>Input a string, get a string surrounded with poop
>9 fucking stars
KYS SRLY K Y S
>>
>>56278503

almost reads like English
>>
File: feelsgood.jpg (20KB, 329x357px) Image search: [Google]
feelsgood.jpg
20KB, 329x357px
>>56278541
>>56278522
You included
>>
>>56278541
That's much less readable now.
>>
>>56278543
Again, this will only import them in the importing namespace with an alias. This isn't something that I want as I already stated.

To better picture my problem...

data.py:
points = []
values = []


main.py:
class Generator(object):
def __init__(self):
self.x = ?? how to import points here each time the ctor is called
self.y = ?? how to import values here each time the ctor is called

def compute(self):
pass

a = Generator()
b = Generator()

a.compute()
b.compute()
>>
Do you think it's possible to code an AI to play Dark Souls 3 PvP (and win?)
>>
>>56278543
or more sensibly, import .data.points as x lol
not sure if you can even have periods in module names tho?
>>
Don't know if this is the best place to ask but here we goooo

So I went to a meeting for this research program at my uni where undergraduates can participate in STEM projects with mentors/professors/faculty/etc
I'm a CS major and most of my knowledge (including programming) comes from my courses, meaning that I haven't done too much outside of school
There was one project that I thought looked cool that dealt with augmented reality but it looked a little difficult for me. There was another project who's leader ended up coming and explaining it to us; I liked the other project more but this one seems less difficult for me

In both cases I would have to learn stuff due to my lack of practical skills, it's just that in the easier one I feel like I'd be less dead weight.

When I asked the presenter if it was okay if my skills weren't up to par and we could learn along the way he said it depends on the project and the people working on it but more or less yes.

Typing this out I think the best answer is going for the "easier" one, something I could probably contribute more to, and just save the harder ones for later semesters. Anyway what do yallz think
>>
>>56278585
does dork souls 3 still have invincibility in rolls?
>>
>>56278561
Yeah while one liners feel cool they're often just showmanship over readability.

Like guys look at my LOC
>>
>>56278601

yes
>>
>>56278584
So you mean the data file can change in between calls?
>>
Workin' on SPNatI. It's a stupid strip poker game where you obviously play strip poker with kisekae models and that's it. It looks like ass and the other people on the project are inept. The characters have shitty lines and the games are long and draw out. If you wanna play the game, just play real strip poker, or even better, just strip kisekae models.
>>
>>56278623
Are you at least getting paid? That sounds like a 100 hour project max desu, Poker isn't that hard to clone.
>>
>>56278623
at least its something you can show your employers
>>
>>56278584
Just use two different files, one with points, and one with values.
>>
File: 542140?v=3&s=400.jpg (13KB, 400x400px) Image search: [Google]
542140?v=3&s=400.jpg
13KB, 400x400px
Fucking apologize. Now.
>>
>>56278614
No, but Generators shouldn't modify each other's values (which is a case here).

>>56278646
How is that going to help?
>>
File: DfWEUpb.jpg (377KB, 1800x1248px) Image search: [Google]
DfWEUpb.jpg
377KB, 1800x1248px
want to start on some C64 programming
found this https://gumroad.com/l/64bites
don't have credit card
anybody has a magnet for the course rip?
>>
>>56278661
I don't get what you are trying to do. Can you be more high level here, what are you trying to accomplish?
>>
>>56278661
Why don't you just put the data in a csv and read it as a file?
with open(data, 'r') as file:

etc
>>
>>56278666
>paying
you've videos on youtube

https://www.youtube.com/watch?v=xBUG8xvoQo4

or books
>>
>pajeet "answers" your questions on stackexchange even though he didn't understand the question
>>
>>56278746
post the question here
>>
>>56278757
God no, I would get bullied so hard.
>>
>>56278746
link it here so we can flag and downvote

>>56278773
at least post the contents of it
>>
>>56278773
who cares? you're anonymous
>>
>personal project now over 25k loc
Feels good.
>>
>>56278834
about what? language?
>>
>>56278789
Not on SO I'm not. What if you track down my dad and call him to tell him just how much of a disappointment I really am?

[spoiler]If you do pls tell me how to contact him...
>>
>>56277590
I see no big fat errors. I assume it has been tested? It feels really intelligently written anyway.

Remarks:
What if there are elements that are neither lt(x,y) nor lt(y,x)? Your code will throw one away, but you've not been asked to uniq the elements in addition to sorting them, and the person who's written lt might have a use case were two elements compare equals but are nonetheless different and should both appear in the output list. Maybe you can make it optional ;-) ?

for i in b:
result.append(i)
might as well be result.extend(b) or result += b
I'm not sure you need the [:] in return L[:], but maybe I'm not spotting the reason or maybe you wanted to be safe, which is cool.

Inb4 I know [ code ] blocks are available but I'm lazy rn.

Keep up!
>>
>>56278834
What have you been working on?
>>
>>56278846
post the fucking question before i murder you
>>
>>56278852
>>56278839
An imageboard in Go and Typescript with live character by character updates. Still very much alpha, but most of the core backend systems are done so I can really get at the frontend now.
>>
>>56278639
Not getting paid a penny, I was promised money but I'm not getting it anymore because I said something against the game creator and he said to fuck off.
>>56278645
kek
>>
>>56278584
You can put import statements inside functions. Not sure how it mixes with mutable data tho. Why not just import once then make copies? So much simpler...
>>
>>56275136
maki a shit
>>
File: akari!.jpg (2MB, 1300x1560px) Image search: [Google]
akari!.jpg
2MB, 1300x1560px
>>56275441
I added pages and offsets to my messageboard!

Try it out and try to break it!
>>
File: 1379735021024.gif (840KB, 500x141px) Image search: [Google]
1379735021024.gif
840KB, 500x141px
>>56278972
That's Mari.
>>
>>56279023
Same shit.
>>
Is there a free hex editor supporting binary templates?
>>
>>56279110
http://www.sweetscape.com/010editor/
>>
>>56279135
I meant free as in no costs, and I don't want to have to bypass the expired trial every 30 days.
>>
>>56278850

ty dude appreciate it, and yeah I switched over to list.extend() just now
>>
0 : 0 : 0
1 : 1 : 1

1 : 0 : 0
1 : 1 : 0
1 : 1 : 1

0 : 0 : 1
0 : 1 : 1
1 : 1 : 1

1 : 0 : 1
0 : 1 : 0

Is this all possible combinations of 3 booleans?
>>
>>56279222
3 bits = 2^3 = 8 possibilities
this is CS 101
>>
>>56279110
Make one.
>>
>>56279222
take a digital logic course my man
>>
Can you do SICP in Python?
>>
>>56279303
Kek. Learn a lisp or get out scrub.
>>
>>56279324
Excuse me?
>>
>>56279303
http://www-inst.eecs.berkeley.edu/~cs61a/sp12/book/
>>
>>56279362
Is it as good, and comprehensive, as the actual book?
>>
>>56279260
Okay, C + ncurses, i will take over 010Editor Syntax, highliting files will be primary objective, making a hex-editor comes second.
Any objections/tipps?
>>
trying to wrap my head around binary multiplication because i have to make a function for it for class, can you tell me if my rough outline of the algorithm is right before i implement?

    public static byte[] product(byte[] A, byte[] B)
{
// make a binary array C to hold the current sum
byte[] C = new byte[Math.max(A.length, B.length) *2];
for(int i = 0; i < B.length; i ++){
if(B[i] == 0){
// make a binary array temp to hold the value to be added to C
// put "i" number of lowest-order 0's slots into temp
// fill in the rest of temp with the values of A
// add temp to C
}
// else do nothing
}
return C;
}

>>
>>56278585
It probably wouldn't be hard, given that the current tryhard meta is being as reactive as possible and never attacking first.
>>
>>56279434
oops forgot to change it to B[i]==1, i had changed it from doing if(==0) break else {..}

feedback appreciated
>>
WHY THE FUCK IS IT SO HARD TO FIND AN ACTUAL PROGRAMMING JOB

NO, WEB DEVELOPMENT IS NOT "PROGRAMMING" !!!STOP LISTING THEM AS SUCH!!!!

I AM NOT A FULLSTACK STARBUCKS TRANSAUTIST, OR A ROCKSTAR MOCKUP TO WEBSITE IN 3 HOURS MACHINE, OR A "INTUITIVE USER EXPERIENCE NEGOTIATOR"

WHERE ARE THE ACTUAL JOBS. I WANT WEB 4.0 TO END.
>>
wtf java
why does every other section work fine but this one doesnt?
>>
>>56279434
>
Math.max(A.length, B.length) *2

A.length+B.length
>else do nothing
What... that's incorrect.
Also your algorithm is not going to be correct from what I see.
>>
>>56279489
>AP
fuck off underage
>>
>>56279487
Uh, do you not have a degree in Computer Science?
>>
>>56279510
Most students in highschool take AP as a senior in which case he could be 18 years old.
>>
>>56279510
senior in hs
>>
>>56279489

>multiplying fractions
>difficult to code
>>
>>56279513
No, because I cannot afford to get one. I work full time and code in my free time. Yes, I fucked myself in high school, intending to kill myself eventually. Honestly don't know why I haven't yet, doesn't look like I'll ever have a job as a developer.
>>
>>56279222
Here is a better system:

2 bits:
00
01
10
11

3 bits: Do the same thing but with a 0 or 1 in front
0 00
0 01
0 10
0 11

1 00
1 01
1 10
1 11

For 4 bits, repeat the above with with another 0 or 1 in front.
>>
>>56279489
>doing all the work and then choosing the specific result afterwards
???
>>
>>56279498
does that not make the array big enough to hold the number of digits? and if the digit's 0 you're multiplying 0 and a number so you don't have to add it to the sum, correct? i said earlier you may not have seen it, i meant to have it be if == 1, not == 0
>>
>>56279498
No mate, the correct length is actually
max(A.length, B.length) + 1
>>
>>56279539
Ok, well do you have a portfolio with any projects you you have worked on that you can show proving you know what you're doing?
>>
>>56279597
but 100 * 100 is 10000, which is 5 digits compared to 4 digits which your way gives
>>
>>56279245
Seems there are benefits to CS memes. Lol.
>>
>>56279597
Wait no it's product not sum so you're right.

>>56279584
Have you done some instances on paper? If not, do so.
>>
>>56279629
I have a couple projects on my github (won't post, linked to my real name) that involvereally low level stuff. I made a hobby OS which is probably the project I put most of my time into, even wrote a style guide and everything. Nobody has even looked at it though. I have a couple other projects including this 2D graph thing that visualizes data structures, like you can connect one value or data structure to another. Other than that there isn't much I haven't deleted off my hard drive because I hate myself.
>>
>>56279656
i've done it on paper. i'm gonna go ahead and make it real code and see what happens
>>
>>56279222

0
7
4
6
7
1
3
7
5
2

You repeated 111 two extra times. Why?
>>
>>56279434
>make a binary array temp to hold the value to be added to C put "i" number of lowest-order 0's slots into temp fill in the rest of temp with the values of A add temp to C.
Makes perfect sense except you should do so if B[i] == 1
>>
NEW THREAD!

>>56279701
>>
>>56279670
Start applying to any and ALL companies for programming positions linked to your GitHub obviously.

How many jobs have you actually applied for anyway?
>>
>>56276988
there's only one e in spacemacs

so it's space macs
or spac emacs
>>
>>56279419
>>56279362
doesn't cover all of the stuff in sicp

just like python is a toy language, it's a toy book.
>>
>>56279489
can you actually format your code before asking for help you fucking idiot
>>
>>56280039
the e is shared
turd
>>
>>56278595
You want something in the middle of easy and hard. Join a project where you won't be able to solve all the problems without research but one where you're familiar enough with what's going on to know what question to ask when you need help.

If you have little experience working with others then you're going to learn a lot no matter what project you join.

Don't be afraid to think of other stuff as a black box. I got asked a question about a problem with a signal in a car while sitting around the ME lab watching stuff. I had a general idea of how everything worked but what it came down to is our signal looks like this and it's supposed to look like "hand drawn expected signal" when we feed it to the ECU. Turns out I just had to filter all the interference from the ignition and shit. Two parts that cost a dime did the trick but it was a big help and the car started. That was rewarding.

I had similar experiences in other projects. I would work on one part where I had familiarized myself in detail. The other 75% was stuff that I knew in varying detail depending on how closely I had to interact with it.
Thread posts: 319
Thread images: 31


[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.