/dpt/ - Daily Programming Thread

Previous Thread: What are you working on, Sup Forums?

Other urls found in this thread:

stackoverflow.com/questions/24105461/sorted-list-in-idris-insertion-sort
amazon.com/Understanding-Compression-Data-Modern-Developers/dp/1491961538
adventofcode.com/
youtube.com/watch?v=y4KLwKy6sLs
youtube.com/watch?v=b-Cr0EWwaTk
youtube.com/watch?v=HWhfZk1llUo
twitter.com/NSFWRedditImage

pls save me

i am working on an office chair attachment that uses a vacuum to create an virtual experience for fellatio
unfortunately, the software isn't reading the negative pressures correctly and it causes bruising and pain
so i need to tweak that at the moment

lol

how the fuck do I get an internship when everything around me is fucking nu-male webdev bullshit

So many entries around me reek of that fucking "macbook pro with a bunch of tattoos on your arms" type.
I just wanna do embedded, optimization, something C or C++ or fuck even python or C# but fuck none of this fucking webdev/""app"" or meme-game in Unity bullshit man. Where the hell are all those other jobs. I'm going to be graduating soon with not even an internship under my belt.

I have plenty of personal projects on my github and such to speak for myself but I have no idea how to properly put myself out there in an ocean of "we want 4 years of experience in gabber angular bonerscript typescrype coffeescript jquery fullstack ass bitch grunt fuck shit bootstrap fuck ass (Must have mac book air with at least 5 stickers and a full sleeve tattoo, must wear plaid regularly and have gauges of at least 3cm diameter)"

Obviously ignore the webdev shit if that's not your thing. If you want a career in C++ you need to seriously work your fucking ass off though because the language is humongous.

>If you want a career in C++ you need to seriously work your fucking ass off though because the language is humongous.
And the C++ jobs pie is rapidly shrinking, unlike Java jobs.

Country?

stackoverflow.com/questions/24105461/sorted-list-in-idris-insertion-sort

I'm trying to find the shortest Idris implementation of a type that describes a sorted sequence, along with a simple list sort function.

us, west,
I'm good at C and C++ and Assembly type of shit. Low level stuff.
Low level shit.

>Low level shit.
You can try to intern at Juicero.

The easiest way to get low-level experience is by doing Google Summer of Code. Actual low-level internships are rare. I know IBM offers low-level internships but they're usually 12-16 months

Also I hope you actually know you're stuff

Also, it's a bit late now, but Microsoft offers low level internships although the team has to pick you out meaning your projects need to be impressive

hey man if youre good at low level shit can you tell me why my god awful attempts at parsing the pe file headers of this dll arent working

>us, west
welcome to nu-male country, boi. you're pretty much fucked and better learn to be fucked by nu-males. it's going to be a needle in a haystack to find a decent internship in general if you're not into the whole hipster, nu-male new age liberal bullshit.

>it's another episode of trying to use python packages that break for no reason without telling you why

Lmao sounds like you suck, kiddo

t. Uni student with retard GPA and with co-op for next semester

python is cool af

Alright fuck it I'm going to sleep.
If someone could look at this and tell me why this doesn't work I'd really appreciate it.
HANDLE hFile = CreateFile ("C:/Windows/SysWOW64/kernel32.dll", GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0);
HANDLE hFileMap = CreateFileMapping (hFile, 0, PAGE_READONLY, 0, 0, 0);
LPVOID lpFile = MapViewOfFile (hFileMap, FILE_MAP_READ, 0, 0, 0);

IMAGE_DOS_HEADER* pFile = (IMAGE_DOS_HEADER*)lpFile;
IMAGE_NT_HEADERS* pHeaders = (IMAGE_NT_HEADERS*)(pFile->e_lfanew + (PBYTE)lpFile);
IMAGE_OPTIONAL_HEADER* pOptional = (IMAGE_OPTIONAL_HEADER*)&pHeaders->OptionalHeader;
IMAGE_DATA_DIRECTORY pData = (IMAGE_DATA_DIRECTORY)pOptional->DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT];
IMAGE_EXPORT_DIRECTORY* pExport = (IMAGE_EXPORT_DIRECTORY*)pData.VirtualAddress;

printf("%i", pExport->NumberOfFunctions); //Gives me read access violation

Is there a /dpt/ advent of code leaderboard?

how did you land your current job

if not, how are you currently trying to get a job and what are some key technologies/languages for the position

Red pill me on compression algorithms lads. What should I use that's random access and low on memory overhead?

>random access
block bsed
>low memory overhead
run length

block based*

also check out this book

amazon.com/Understanding-Compression-Data-Modern-Developers/dp/1491961538

Honestly JS is designed better. It's more performant, more consistent, and has higher quality third party libraries. Also python's functional programming support is garbage in comparison.

No. Piss off.

I started looking for a job on Thursday, sorted my CV out, found a hiring event for Friday. Attended, got talking with one of the guys in a very relaxed manner (because he was Oxford based and I was in London, he thought I wasn't interested in his job. I was.) He offered me an interview for Tuesday. On Wednesday I had a job.

Such is webdev life.

I hate programming but I want to work as a programmer, what to do?

Apply to MS, Google,Apple or any other enterprise company, you'll fit right in.

Juicero actually having a very good and robust product.
But their CEO is shit and can't have other idea other than blatant scam

>higher quality third party libraries
Now I don't know Python, but libraries worse than in JS is a bar buried pretty deep underground. Can't imagine things worse than the left-pad-esque shit we hear of every year.

I can't think of anything to learn/make so i'm learning Django for python

Is this a waste of time? I wanna get better but can't think of any useful projects I want to do

>learning webshit
Waste of time. The web is dying. Learn assembly - it's how computers really work.

How does /dpt/ stay motivated to complete its latest fizzbuzz? I can't seem to finish anything.

>how did you land your current job
By scrolling through a programming/tech startup job listing in a FB group and emailing all the interesting ones a resume of sorts with a portfolio link.

>What are you working on, Sup Forums?
advent of code day 13. i did the first part quite easily and could do the second one using brute force but i am pretty sure there is a more efficient way.

the problem is something like finding x here

x % 9 = 0
(x + 1) % 3 = 0
(x + 2) % 2 = 0
(x + 3) % 6 = 0


i know there is a theorem or something like that but i can't remember the name.

>What are you working
Just start to learn react.js and vue.js.
But I need some idea what do when I finish the tutorials.
any advice or ideia is welcome anons.

Bored as fuck. Where can i find some fun things to program? Any advice Sup Forums?

build new social media app or game
or
start adventofcode.com/

>i know there is a theorem or something like that but i can't remember the name.
Chinese remainder theorem?

Haven't coded in a year so dumb question. I made a while loop with exception handling in c++ and everything worked just fine. Then I just add a couple of random numbers and some strings before I implement the loop, and everything just broke. I didn't even change the loop at all.

Anyway, how can I make a while loop or any kind of loop that can catch errors and still loop the program until the user inputs a valid input? If I input a wrong number it still works but when I do a letter like 'k' it loops infinitely.
Here's an example of what I have now that doesn't seem to work.
bool loop=true;
while(loop=true)
try{
coutinput
if (input=1){do stuff}
if (input=2){exit(0)}
}
catch (string exception){ what do here}

Is it trolling? Because it looks like it's trolling.

This shitty professor gave me 20/100 in data comm and networking :-DDDD
i never failed before he just failing everyone basically will prob be fired next year and ill pass
meaning this semester I got some more free time might aswell learn something on my own

suggest me some books to read on my own. are the wiki ones any good or bait? which to start out with?

I need a system in which I can test conditions on a timeline and add and substract timeline elements easily (let's say, on a timeline from 1 to 8999, if I add an element at 122, everything will be pushed into the future and it'll grow to 9000)

the elements will be variables, bools and ints and strings, and their state will depend on the "timeline" value

I need to be able to run tests on the data depending on the timeline key

Should I use a temporal database or what tools do you see suited ?

Anyone here good with regex in java? I have a file with lots of entries, a json file. It has paramaters id,name,country, coordinates[lon, lat].
And I have the id and I need to match the id and find the coordinates which come after it. Yet I can't seem to find out how to do it.

template times(count: int, codeBlock: untyped) =
for i in 0 .. count:
codeblock

proc main() =
5.times:
echo "I love you."

main()

i-im not. I'm completely new and haven't coded in a year or so

I don't think it's a good idea to try match json using regex. It's probably better to parse it then work with the json objects.
If the json objects are very simple, e.g. no nested dictionaries deep you might be able to manage.
Something like (not escaped properly)
({.*?"id":.*?})

would match the object, then you can search for the fields you want.

So, first indent your code correctly. That's the rules here.

You're going to have to explain more. What you've described could be done with just a text file as the "database".
x = 1
y = 2

Then run through the file updating the vars.

...

So depressing. Java is such an icky language.

>The web is dying. Learn assembly
Why not both? Learn WebAssembly.

I plan to make a fully functional CMS only using assembly

I'm working on an python assignement which will use tweepy and googlemaps api, but I can't for the life of me acess the tweepy api
That's my auth code :

import tweepy
import json

fp = open("credentials.json", 'r', encoding='utf-8')

twitter_credentials = json.load(fp)["twitter"]
consumer_key = twitter_credentials['CONSUMER_KEY']
consumer_secret = twitter_credentials['CONSUMER_SECRET']
access_token = twitter_credentials['CONSUMER_SECRET']
access_token_secret = twitter_credentials['ACCESS_TOKEN_SECRET']


auth = tweepy.OAuthHandler(consumer_key,consumer_secret)
auth.set_access_token(access_token,access_token_secret)
api = tweepy.API(auth)


But i get a code 89 error :
tweepy.error.TweepError: [{'code': 89, 'message': 'Invalid or expired token.'}]

Any ideas ? I can't even start the assignment without this bit working

This looks like nonsense to me, user. Suppose we try to satisfy just the first two constraints:
If x % 9 = 0, then x = 9a for some integer a.
Plugging into the second equation gives us (9a + 1) % 3 = 0, meaning that (9a + 1) / 3 is an integer.
(9a + 1) / 3 = 3a + 1/3.
So we need to find an integer such that multiplying it by 3 and adding 1/3 gives us an integer, which is impossible.

>aced C course
>Java
>everything is fine
>get to Java's data base and trees
>it's rip
How do I get trough this shit? I can't grasp this shitty "Node" and Java generics concept

Want to jump into an overly ambitious imageboard project with a decently mature/big codebase?

Something people often forget are niches like logistic and finance companies with inhouse IT. Even if they aren't explicitly hiring send in applications anyways. Try to get into the door somehow, even if you have to exaggerate a bit on your resume, and then convince them of your potential in the interview. I dropped out of college because I just never went to class, was a neet for 2 years, and even with my completely fucked CV and no references or job experience I still managed to get a pretty awesome gig at the biggest logistics firm in my country like that, they weren't even officially recruiting.
There is a lot more to the market than just the data solution and webdev shit you see dozens of results pop up with a simple google search.

>Learn WebAssembly.
NO. WebAssembly is NOT how computers really work. Learn real assembly. The web is dead anyone.

I just had it like that so it wouldn't take up too much space and to make it simpler to read. I think it should be easy to understand but well:

int input;
bool loop=true;

while (loop==true)

try {

coutinput;

if (input==1) {

cout

-- times :: Applicative f => Int -> f a -> f ()
times count codeBlock = sequenceA_ (replicate count codeBlock)

echo = putStrLn

main = 5 `times` echo "I love you."

Use a goto.

Is that... Nim?

It's either Nim or some other shit, dead language

but goto is literally Hitler.

wtf i love goto now

>shit, dead language
Well, it doesn't look like C++ to me.

What music are you listening to while programming RIGHT NOW?
Panic in the disco is an 11/10 /dpt/ tune

Eurobeat.

shit taste

Anime OSTs

above average taste

Yes

why do you consider that nim code a good thing?
you're using untyped ASTs when you could just be using regular procedures

That also one of the reasons I'm not looking to get hired and make video games by myself instead
I don't wanna end up being forced to make some UI/websites in the latest hipster framework

#include

using namespace std;

int readinput () {
for (;;) {
cout input;
if (cin.fail ()) {
cerr

youtube.com/watch?v=y4KLwKy6sLs

youtube.com/watch?v=b-Cr0EWwaTk

youtube.com/watch?v=HWhfZk1llUo

Being able to manipulate AST like that gives you the ultimate freedom.

>untyped ASTs
Woah! That must be scary (for a typelet).

>you could just be using regular procedures
I don't know much about Nim, but I suspect he'd have to pass in a lambda to do what you're saying, but he wanted a new control structure.

you've literally achieved something that could easily be achieved otherwise, except without types and with AST manipulation (necessarily making it harder for the compiler to understand)

well done

>using namespace std;
>endl;
>for(;;) instead of while(1)
>int *p(0); cout

I'm writing a small C program which will generate a SHA256 from a string. Generally I would use something like C# which already has built in libraries for that (it could be pretty much a one-liner I guess), but lately I've been interested in /actual/ programming, learning how to do things myself instead of just using what others already created, even though I know that code reuse is generally a good thing.

More specifically, it's the first time I've had to parse argc/argv[] on C so that's what I'm figuring out right now. Doesn't seem too hard, just kind of boring.

>(necessarily making it harder for the compiler to understand)
Not necessarily.
>How else would you pass actual ASTs? Also, you do realise the potential of compile time optimisation here, right?

>>using namespace std;
The original code was using it. I'm against that but it was not my point.
>>endl;
What is the problem?
>>for(;;) instead of while(1)
Confusing integers and booleans, so typical.
>>int *p(0); cout

you don't need to pass ASTs for that, just use applicatives/monads and other abstractions

>you've literally achieved something that could easily be achieved otherwise, except without types and with AST manipulation
Why are you sperging about this, user? There's an infinite number of things you could never do using FP memery that can be done using AST manipulation, but this user was clearly just messing around, and Nim isn't Haskell. How are types even relevant in this instance?

>m-m-muh moan ads
It's funny how the typelet begins to sperg out preemptively upon running into things his memelang can't accomplish cleanly, like metaprogramming.

>infinite number of things you could never do
That's plainly false, since in the worst case you could literally write the AST yourself and do the same thing, but there is a much better way to do it.

>how are types relevant
Because getting rid of type information for no reason is stupid

Oh look, I just implemented C style for loops because I felt like it
template cfor(preLoop, condition, postLoop, body:stmt) {.immediate.} =
block:
preLoop
while condition:
body
postLoop

cfor (var i = 0; let c = "b"), i < 2, inc i:
echo c

>can't achieve metaprogramming
that's true since in good languages it's just called "programming", there's nothing meta about applicatives

>applicatives/monads and other abstractions
Why use "other" abstractions when mine works fine and purely compile-time expanded?

no luck ?

i dont even know what im really doing, but my code is getting longer and longer

t-thanks

you did it wrong

>That's plainly false
You're plainly retarded.

>Because getting rid of type information for no reason is stupid
What essential type information is he getting rid of, you retarded, drooling fucking typelet? He's splicing in an AST chunk.

Oh I forgot about the prefix ops
# Increment and decrement operators from C
proc `++`*(x: var SomeInteger): SomeInteger {.discardable.} = inc(x); return x
proc `--`*(x: var SomeInteger): SomeInteger {.discardable.} = dec(x); return x

A compiler can compile time expand a pure language as an optimisation. Yours works fine but is completely unnecessary.

For a start he's losing what the type of the AST chunk actually is, meaning that the compiler has to expand a call to his function and typecheck that in order to know that the whole thing typechecks