/dpt/ - Daily Programming Thread

What are you working on, Jow Forums?

Last thread:

Attached: 1492928207490.jpg (1440x810, 392K)

Other urls found in this thread:

developers.google.com/training/android/#for-new-programmers
github.com/jserv/mini-arm-os/tree/master/06-Preemptive
boards.Jow
github.com/sharpsuite/sharpinit/
programarcadegames.com/python_examples/show_file.php?file=pong.py
a.4cdn.org/g/thread/65754468.json
twitter.com/SFWRedditGifs

First for C.

>JavaScript as fast as C++

Have we reached peak technology

Attached: ReasonML.jpg (1280x720, 35K)

I want to program a quick mobile app to illustrate something, where should I start ? I only find website that propose me to do it for me for (((free))) :^)

Do you know any programming? If not, you probably need some time learning java first.
Assuming it's an android app ofc

I have the basics of Java and really mostly did [spoiler]html[/spoiler] in my life

Then get going. Surely there are billions of youtube tutorials or a book or something on it.
I remember I followed google's own online courses like a year ago, but already at that point they were a bit outdated.

Sorry, meant to link these:
developers.google.com/training/android/#for-new-programmers

They can still be useful I think.

god speed, you're a life saver

>What are you working on, Jow Forums?
a delphi 7 program

Name a worse language than VBA

batch

english

we lambdas now

sepples

Attached: handlers.png (866x214, 19K)

Writing some data to a nosql database with node.js

I'm storing one context for each user program (in their PCBs) and then one for the scheduler state.
My SWI handler basically saves the user context back to its PCB, then loads the scheduler's stack pointer and executes whatever function handles the particular system call.
If an interrupt were to arrive in the middle of the SWI handler itself, I don't have anywhere to put its state. I also don't have anywhere to put the state of a function implementing the requested system call if that were interrupted.

Hmm. I think I don't know enough about ARM to give you a helpful answer. Sorry :( I would look for a small ARM preemptive kernel and see how it's implemented. Maybe something like this? github.com/jserv/mini-arm-os/tree/master/06-Preemptive

FWIW in my kernel I don't change process context when handling a software interrupt, although I do use the x86 hardware to switch to the current process' dedicated kernel stack. I only ever change process context from the scheduler (which can be invoked by the timer IRQ or by making a yield() syscall.)

Added support for enums in my programming language, you can also add "bitflags" prefix to the enum identifier to automatically turn the enum values into bitmask flags, such as:
enum bitflags Color = (Red, Green, Blue, Alpha)


Will result in:
Color.Red = 1
Color.Green = 2
Color.Blue = 4
Color.Alpha = 8

>when you use python for so long that you become python

Attached: 1528023982995.gif (305x320, 890K)

I need a JAVA book with good exercises so I can get a job after uni.

any recommendations?

Find internship

ISBN?

>RUST

Attached: soy2.jpg (400x401, 39K)

How to make terminal emulator from scratch? I know there is libvte and I know how to use it, but I want to do it COMPLETELY from scratch (except for GUI library, of course)? I've read up some theory on terminals but I think I need to make one to really understand what's going on.

perhaps read the source of libvte to learn?

>open /dev/ptmx to instantiate a new pseudoterminal pair, let's call the returned file descriptor "ptm_fd"
>ptm_fd is now your master pty
>fork

in child process:
>call ptsname on ptm_fd, this gives you the path to the corresponding slave pty for your master
>open the slave path, let's call this file descriptor pts_fd
>close() 0, 1 and 2 (stdin, stdout, stderr)
>dup2(pts_fd

Okay, this is epic.

Attached: Screenshot_2019-03-12-12-09-35-1.png (717x373, 31K)

fuck accidentally posted
still in child process:
>dup2(pts_fd, 0)
>dup2(pts_fd, 1)
>dup2(pts_fd, 2)
>now you have stdio hooked up in slave pty
>ioctl(0, TIOCSCTTY)
>now the slave pty is the controlling tty of this process
>exec() /bin/bash

in parent process:
>create a gui
>read from ptm_fd
>parse input character-by-character
>detect sequences that start with escape (\033) and react according to VT100/Xterm/whatever spec you want

have fun :)

JavaScript rocks!

Attached: js-rocks.png (1000x494, 368K)

JavaScript rocks!

Attached: javascript rocks.png (1000x494, 134K)

I'm trying to make a program similar to docker swarm, where there is a master instance on one computer, and then other worker instances on different machines, and the master can communicate with the workers. Currently looking through docker swarm's source to look for pointers, but fuck me I hate Go.

uint32_7 = mfw
mfw ++;;
IRQ();;;;;;;;;;;;;;;;;;;;;;;;;
if IRQ ===== 7
BRA :+
return SWI 0x20
+: setmetatable(uint32-6) // counting from 0
else ()
return struct "NO FAIL ", 0 // null terminated
endelse

what the fuck

irq should not last 25 cyclets you fucking javacolon

I'm standardizing my form's so that I can use one generic class to handle all the I/O with the server.

typedef #define uint26 (uint32-6)

double rounddown(double d) {
int i = d;
return i;
}

Attached: 1539442393785.jpg (850x800, 65K)

We call it "floor" in these parts.

what's wrong with front end devs? why do they need frameworks and libraries for literally everything? It's fucking infuriating
it's just doing the same thing with slightly changed syntax

Attached: 1531880184385.png (1288x1152, 88K)

I have a list of anime episode ids, sorted by ranking:
[4,2,1,3] // up to 2000 episodes for really long animes
I also have a list of full anime episode objects:
[{ id : 1, name: "blah blah", ... ]
Id like to sort the episode object to match the ordering in the first list.

What is the fastest way to do so? Memory is not a problem, just trying to optimize CPU time.

Hash the episode objects with the id as a key. Create a new list with something like [hashed_objects[i] for i in [1...2000]]

it's easier to blame the language for not having an intuitive and straightforward way to do things because of it's unpredictable quirkiness

>What is the fastest way to do so?
>just 2000 entries
eh

episodes.sort((a, b) => {
return epOrder.indexOf(a.id) - epOrder.indexOf(b.id);
});

???

select er.id, name
from rankings er
join episodes ep
on er.id = ep.id

javascript is such a high level language it allows you to detect evens and odds with libraries

>using double
ishygddt

perfect

Attached: poointheloo5.jpg (1057x918, 136K)

Make it better before talking shit :^)

O( n log(n) )
O(n^2) worst case
O(n)

Erra~

brb publishing is-odd on pip and sneaking it into some huge project
>hurr y r pytards so dum

brb publishing is-odd on cabal and sneaking it into some huge project
>hurr y r haskleltards so dum

brb publishing is-odd on quicklisp and sneaking it into some huge project
>hurr y r lisptards so dum

brb publishing is-odd on nuget and sneaking it into some huge project
>hurr y r dotnettards so dum

brb publishing is-odd on luarocks and sneaking it into some huge project
>hurr y r luatards so dum

Retarded people will be retarded regardless what language they are using.

And how long/how many ops will it take to hash 2k objects?

based

If your ID's are all small integers, it takes one operation, which is to read the id. Otherwise it depends on your hash function. O(1) either way.

bython :DDDDDd
import requests
import operator
import sys

BOARD, AMOUNT = sys.argv[1], int(sys.argv[2])
C_URL = "boards.Jow Forums.org/%s/thread/%d"
CATALOG = requests.get(C_URL).json()
l = []
for page in CATALOG:
for thread in page["threads"]:
x = [t.get("time", 0) for t in thread.get("last_replies", range(0))]
d = {}
if x is not []:
d[thread["no"]] = sum(x)
else:
d[thread["no"]] = 0
l += sorted(d.items(), key=operator.itemgetter(1))
l = sorted(l, key=operator.itemgetter(1), reverse=True)
l = l[:AMOUNT]
for j, k in l:
print(T_URL % (BOARD, j))

Attached: 2019-03-12_12-32.png (409x415, 30K)

k den, how bout this
epOrder.map((e) => {return episodes[e-1];});

check and mate, faggot

That's literally the same solution I gave in my first message, except with the possibly wrong assumption that the ids are integers. Retard.

don't be a sore loser user. mine is more efficient.

Keep posting this every thread please

Attached: Screenshot_20190312_133806.png (993x840, 149K)

If you need three tries to get to the same solution I already posted, perhaps you should just go somewhere else.

every thread until you like it
at least I got my (You), so I can leave now

user, my first solution was assuming that the episodes weren't in order. My second solution is better than yours because no hashing is involved. I don't know what third solution you're talking about, but it's still better than yours, nigger.

SEE SHARP!
NET CORE!

github.com/sharpsuite/sharpinit/

>My second solution is better than yours because no hashing is involved.
It's the same with an extra brainlet assumption, like I said. Just go away. I have a very limited tolerance for this level of stupdity.

i dont understand this?

is this faggot doing creepy stuff?

woah, youre really fucking dumb. why would you need to hash the objects when you can just access the array index?? how are you going to "unhash" it? or do you just want to end up with an array of hashed objects for some dumb fucking reason? stop pretending to be smart and kys already, faggot

it's just a shitty script that will request the catalog, run through every page, and for every thread in the page, judge it's "activeness" based on the last_replies attribute in the JSON
it's better than just using bump order in my opinion, since you only need one reply to bump a thread, but that may not mean it's "active"

>when you can just access the array index??
Because these indices will magically match the ids supplied by the sorted list, right? What happens if the ids are strings? What happens if the sorted list has fewer entries than the database? Jesus, you're possibly the stupidest person I've seen in any of these threads, and we get some total brainlets from time to time. All your solutions are shit to a problem anyone with a brain could have solved literally in seconds.

>python
>dont understand
peak brainlet

nice job dodging the rest of the questions :^)
your solution makes the same assumptions btw

Okay, I've had enough. I have a good idea, but am sick of putting off getting started.
How do I start programming a game with Python? I'm even going to just make a basic game like fucking Pong or something because I'm a complete dumbass that knows nothing about programming.

It has none of those assumptions, but you're clearly too fucking stupid to understand. And you're also an insufferable faggot for starting this flexing with your beyond shitty ansers.

import pygame

or try renpy

programarcadegames.com/python_examples/show_file.php?file=pong.py

lmao you're still dodging the "how to unhash" question :^)

Because it makes no sense you fucking idiot.

>knows nothing about programing
you might need to learn the basics first
start with a subgoal of running a python program

How do you get the episode object back from the fucking hash? What do you mean it makes no sense?

in a hash map, the keys are hashed not the values

*teleports behind you*
curl a.4cdn.org/g/thread/65754468.json
| jq '.posts[]
| select(.tim != null)
| {channel: "i.4cdn.org/g/\(.tim)\(.ext)"}
| .channel'
| grep -Eo ''
| xargs -I {} wget \{\}

Because of autismal corporate culture
Everything should be modulised, so it can be separately reviewed, unit-tested and reused

Then again
>one million weekly downloads
Dios mio

renpy uses pygame and pygame sucks

What's the fastest way to learn python for someone who has experience with all kinds of programming languages?

>curl wget
lol

>Hash the episode objects with the id as a key
I didn't interpret that as a hash map. Ok you win.

If you want to write a language purely in a programming language, then that will be a huge pain in the ass
You will spend a huge amount of time calculating shit on paper if it's anything more complex than pong

If it's your first game just use Unity or Gamemaker

?

What is going on.
I just want a python project. Why can't I just do "python3 init my-project" and be done with it.

What is this virtual environment stuff I'm scared please help

same way as you learned all the other languages you have experience with

gb2r

nobody wants to write a language

It's a scripting language, not a webdev framework. You start your project by writing "touch asdf.py; xdg-open asdf.py"

I did that but just having files in a folder kind of butchers spacemacs' python functionality it seems. Or I'm retarded.

Probably the latter.

It's so weird going from Java to Sepples that I don't have to babysit my generics.
The compiler will just tell me if T doesn't have add(), I don't have to write shit like "T extends addingStuffInterface", it just works

This is not doing what you think it's doing.

You can't know what I think it is doing.

If I knew what the hell your point is, I'd be extremely shocked and appaled

sorry for any confusion
if its any consolation, for very very large arrays, hash maps fall back to O(n log (n) )

What sets you apart from your peers? are you better than them?

Out of a 100 programmers, why should I pick you?

Attached: 1552398050053s.jpg (250x250, 7K)