/dpt/ - Daily Programming Thread

What are you working on?

Previous:

Attached: haskellos.png (1446x2048, 21K)

Other urls found in this thread:

github.com/llakssz/FunKeyCIA/blob/master/FunKeyCIA.py
sourceforge.net/projects/win-agui/?source=directory
hentaihaven.org/ajax.php?action=pukka_infinite_scroll&page_no={}&grid_params=infinite_scroll=on&infinite_page={}&infinite_more=true¤t_page=home&front_page_cats=&inner_grid[use_inner_grid]=off&search_query={}&sort=date'
hentaihaven.org/'
my.mixtape.moe/mzexqk.7z
youtu.be/tEM9eNzXLIM
whoishiring.io/
packtpub.com/application-development/modern-python-cookbook
automatetheboringstuff.com
doc.qt.io/qt-5/qtgui-openglwindow-example.html
twitter.com/SFWRedditGifs

Can you guise help me figure out why this Python 2 code ( github.com/llakssz/FunKeyCIA/blob/master/FunKeyCIA.py
) which has been converted to Python 3 (using 2to3) is fucking up on this section? (The Python 2 version works fine btw)


#if using a keyfile
if (arguments.localkeyfile) or (arguments.nfskeyfile):

if not os.path.isfile('encTitleKeys.bin'):
print('The input file encTitleKeys.bin does not exist.')
sys.exit(0)
with open('encTitleKeys.bin', 'rb') as keybin:

keybin.seek(0x10)

for block in iter(lambda: keybin.read(0x20), ""):

titleid = binascii.hexlify(block[0x8:0x10])

key = binascii.hexlify(block[0x10:0x20])
typecheck = titleid[4:8]

if arguments.all:
#skip updates
if (typecheck == '000e'):
continue
#skip system
if (int(typecheck,16) & 0x10):
continue
elif (typecheck == '8005'):
continue
elif (typecheck == '800f'):
continue

if arguments.all or (titleid in titlelist):
processContent(titleid, key)
else:
processContent(titlelist[0], arguments.key)

fuck off piratefag

dude don't be a shithead. we can already pirate with the existing python2 script just fine, we're just trying to see if this can be ported to 3, just to have some fun programming. why you gotta be a shill for a company who doesn't even know or care you exist?

what should I look at if I want priperly checked TLS connection from C?

please post a programming (anime) related picture next time.

Attached: 1510128275974.jpg (1280x720, 456K)

Haskell is pure, just like the best animays

/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

please use an anime image next time.

Attached: primejacky.webm (1280x548, 2.87M)

>Haskell loss
We have reached new lows.

why should I learn rust ?

it saves you from a lot of easily avoidable mistakes

Maybe you're already concerned with safety and are using a safe language, but you want more performance. Or maybe you're already concerned with performance and are using a fast language, but want more safety or other modern features.

you shouldn't, it's a ded lang, kept on life-support by false-hype. No one who uses Rust actually enjoys programming in it. Watch any talk and you'll quickly find this out.

for the code of conduct

this

Worst argument ever made with regards to pirating

Tha'ts it, I'm sold !

i'm not even talking about pirating, dickhead. i'm trying to convert a python 2 script to python 3. if i wanted to pirate, I already can do so using the existing python 2 script as it works fine. i just don't know how to convert the section i pasted in to python 3.

easiest language to learn for finding a job?

c# by far

post error message or something, how does it fuck up

Haskell is the purest form of anime

sql

might be because b'aaaa' == 'aaaa' is true on python2.7 and false on python3.4

Elisp.
Just tell everyone that you will fix, optimize, and trim useless stuff from their init.el or .emacs for a fee.

js

>easy
visual basic

I run it and it goes quiet until I ctrl-c out and then I get this
$ python3 FunKeyCIA.py -title 0004000000040a00 -nfskeyfile
*****
!!!!!Warning - Only tested with Python 2.7!!!!!
*****

*******
FunKeyCIA by cearp
*******

Downloading encTitleKeys.bin from 3ds.titlekeys.gq...

Downloaded encTitleKeys.bin OK!
^CTraceback (most recent call last):
File "FunKeyCIA.py", line 286, in
for block in iter(lambda: keybin.read(0x20), ""):
File "FunKeyCIA.py", line 286, in
for block in iter(lambda: keybin.read(0x20), ""):
KeyboardInterrupt

Thanks, I'm not sure which of those lines it's doing the check on, I'll have a look

yeah pretty sure it's the string comparison change, change the "" in the iter call to b'' and prefix the strings in the loop body with b
your loop runs forever because the lambda returns b'' as a sentinel which in python3 is not equal to '', but in python2 it was

If I show a do block to someone who hasn't drank the hasklel kool-aid, do you think that they'll agree that it's pure?

Thanks man. I assume you meant do something like this? It is at least exiting cleanly now, though it's not downloading the CIA file as it should.
#if using a keyfile
if (arguments.localkeyfile) or (arguments.nfskeyfile):
if not os.path.isfile('encTitleKeys.bin'):
print('The input file encTitleKeys.bin does not exist.')
sys.exit(0)
with open('encTitleKeys.bin', 'rb') as keybin:
keybin.seek(0x10)
for block in iter(lambda: keybin.read(0x20), b''):
titleid = binascii.hexlify(block[0x8:0x10])
key = binascii.hexlify(block[0x10:0x20])
typecheck = titleid[4:8]

if arguments.all:
#skip updates
if (typecheck == b'000e'):
continue
#skip system
if (int(typecheck,16) & 0x10):
continue
elif (typecheck == b'8005'):
continue
elif (typecheck == b'800f'):
continue

if arguments.all or (titleid in titlelist):
processContent(titleid, key)
else:
processContent(titlelist[0], arguments.key)

>do'ing outside marriage

Another strange behavior I noticed was that running 2to3 produces a modified file, but running it again does further changes, is this normal?
Shouldn't all conversions just take place on the 1st pass?

what is the easiest way to create enterprise software (with GUI) with c++?
I usually use visual c#.

sourceforge.net/projects/win-agui/?source=directory

Qt + C++

yeah now the bytes should compare correctly
I guess if this was broken then every other instance where you compared bytes to string literals is now broken too, probably in more subtler ways, so you should go through and make sure that bytes are only compared to bytes and not to strings

C++ is too canny for business software. You'll need a more verbose language, C# is perfect.

Is Learning Python the Hard Way 3rd edition still ok book? I saw it listed on resources on wiki but figured it might have been added quite some time ago, and the book itself is from 2013 so just wondering if it isn't outdated, because I saw opinions that it indeed is.

My job uses C++. It's even government work.

If you want:
zero-cost abstractions
move semantics
guaranteed memory safety
threads without data races
trait-based generics
pattern matching
type inference
minimal runtime
efficient C bindings

dunno, never used 2to3, but if you ran it once the output should be a python3 program, so I don't know why you would run it through 2to3 again. I wouldn't be surprised if that produced something weird

>visual c#
i know c#, but dafuq is visual c#?

But 'do' is pure.

Do people actually do work with python? I always hear how easy it is to learn, but I want to know if I can get paid for it

Visual C# is Microsoft's implementation of the C# language. It's a branding.

i see. that's new to me. thought it's all c# all these years.

softwareengineering.stackexchange.com/questions/237153/what-is-the-difference-between-c-and-visual-c

I'm curious, I've been using python for a bit, but I want your opinion on this.

What's so good about Ruby? How is it different from Python? The only thing I know (besides the fact that they're both interpreted langs) is that Ruby is much more object oriented than python. Which one does /dpt/ prefer?

lies
awful
lies
lies
good
great
type inference is a coping mechanism
lol its larger than lisp's
>The raw C API needs to be wrapped
lol

import requests, urllib
page_list=[]
url ='hentaihaven.org/ajax.php?action=pukka_infinite_scroll&page_no={}&grid_params=infinite_scroll=on&infinite_page={}&infinite_more=true¤t_page=home&front_page_cats=&inner_grid[use_inner_grid]=off&search_query={}&sort=date'
search=''

max_pages=requests.post(url.format(0, 0, search)).json()['max_num_pages']
for page in range(1,max_pages+1):
page = requests.post(url.format(page, page, search)).json()['content']
page_list += [x.split('">')[0] for x in page.split('brick-title" href="') if 'hentaihaven.org/' in x.split('">')[0]]

track=len(page_list)

for num, hentai in enumerate(page_list):
page = requests.get(hentai).text
try:
url = page.split('label="720p" src="')[1].split('" type=\'video/mp4\'')[0]
except:
url = page.split('label="480p" src="')[1].split('" type=\'video/mp4\'')[0]

the_file = requests.get(url, stream=True)
print(num,'of',track,'Downloading:\n'+urllib.parse.unquote(url.split('/')[-1]))

with open(urllib.parse.unquote(url.split('/')[-1]), 'wb') as animu:
for thing in the_file.iter_content(1024):
animu.write(thing)

>type inference is a coping mechanism

Attached: 1525891708311.png (229x220, 6K)

I am really having trouble wrapping my head around this. "Here is a desk." is supposed to be only printing 12 times overall. but it's printing many, many more times than that. What am i doing wrong?

public class DeskAllocation {

public static String[][] deskNames;

public static String[] names =
{ "Amy", "Ben", "Carly", "Danesha", "Evy", "Faroukh",
"Greg", "Heather", "Ivy", "Jaz", "Keith", "Monica",
"Nick" }; // 13 names!

public static void main(String[] args) {
deskNames = new String[3][4];

allocateAllDesks();
}

public static void allocateAllDesks() {
for (String name : names) {
allocateDesk(name);
}
}

public static void allocateDesk(String name) {
for (int row = 0; row < deskNames.length; row++) {
for (int col = 0; col < deskNames[row].length; col++) {
System.out.println("Here is a desk.");
}
}
}

your printing it 12 times per name

It's a coping mechanism for static typing. explicit types are only useful for specifying memory layout.
>inb4 but muh type checks prevent me from being a retard

Static typing prevents the programmer from being a retard, yes. But, more importantly, it prevents the compiler from being a retard when optimizing.

I made this rotating marble maze game for Linux, with C and Xlib
Would anyone try it out? The source code isn't available right now, I can only share a binary at the moment, but I promise that it doesn't do anything malicious.

Controls: z, x, space

Ctrl+C to quit

my.mixtape.moe/mzexqk.7z

Attached: 2018-05-16-211951_652x512_scrot.png (652x512, 8K)

Are you retarded. Of course it will print it 13*12 times.

>download
hell no

>share binary
nice try

go to facebook
join a programming group with lots of pajeets
do your shit there
???
profit

isn't there a quote somewhere about premature optimization? hmm interesting. good languages don't require them and have them be optional, and the compiler can still infer types on a dynamic system.
>optimization
Interesting that lisp is still faster than hasklel even though common lisp is only 4 years hasklel's senior.

that looks neat but I am definitely not downloading a binary from fucking Jow Forums. post the source code or post a webm.

Python, Java, C#, Ruby
Take your pick based on local demand.

>applying premature optimization to compilers
Fuck off you cretinous slug.

PHP is the hottest programming language in my country. I hate PHP. People Hate PHP. Stack overflow caused by PHP.

Do you seem to think that writing types is somehow magically not programming despite the Curry Howard Isomorphism? Interesting. I guess you must black out when you do it.

Did you respond to the wrong person?

Attached: 1526502207929.png (2358x2526, 803K)

dumb frogposter

>What are you working on?
20x12 RGB LED matrix. I think I have everything completed including the inverter box and everything.

Attached: output.webm (720x480, 2.57M)

I prefer Ruby myself. I don't like Python's significant whitespace, and Ruby is more consistent with the '.method' syntax, over Python's mixed syntax.

Although I've never spent more than 10 minutes in Python for a fairer assessment.

Speaking of Curry-Howard, there is a very interesting correspondence between futures and the diamond modal operator in temporal logic.

Streaming me working on a media center for sharing content. Eventually it will have a federated protocol sort of like Diaspora's. But it'll be more similar to forum software rather than FB. It's written in Python/Django and vue.js.

youtu.be/tEM9eNzXLIM

Attached: terryflip.png (509x414, 154K)

In that case, make your own language and target PHP.

How do I find a job near me? Can someone help

>2018
>not using node

>whoishiring.io/

weren't you making some demoscene effects? I wanna see those.

I'm thinking about what to work on in regards to my text editor. I know what I should work on desu (scrolling), but I really wanna play around more with its parser and I'm also itching to add google docs on-line collaboration features.

did you buy a new microphone yet? I'll only watch your stream if your audio quality is better.

Even added a fan to my inverter box since it was getting very very toasty.

>weren't you making some demoscene effects? I wanna see those.
Yes, I'll make you a webm with what I have so far.

Attached: box.png (720x480, 547K)

4/10, get a better hairstyle and a stronger chin

>inverter
>leds
??? ok ignoring that, wouldn't running mains voltage through a transformer be more efficient and hence cooler?

“Hard way” books are shit.
If you know another language use “modern Python cookbook”.
packtpub.com/application-development/modern-python-cookbook

If you don’t know programming use
automatetheboringstuff.com

Transformer is what I meant by inverter.

I shot some videos, just making them into webms now.

Attached: plasma_still.png (720x480, 474K)

how can I use opengl with qt? I've found a bunch of old stuff but nothing about opengl 4.5+

I'd advise against, it's fucking mental gymnastics to get it working 100% properly. I even found like 2 bugs within Qt itself while doing so and after reporting and after maintainers have tagged it as critical, high priority bugs they've not been fixed for close to a year now.

It's the exact same way as the old stuff except you need to change the requested opengl version string 4.5 and use glew to wrangle the function pointers. Unless you were looking at hilariously ancient documentation for GL1.1, you're already doing this and it should be a simple matter of changing a copule numbers.

OpenGL was a mistake.

you mean this but with QOpenGLFunctions_4_5_Core Class instead of QOpenGLFunctions?
doc.qt.io/qt-5/qtgui-openglwindow-example.html

what would you advice instead?

>python
>trying to figure out why calling a function is raising a NoneType exception for no plain reason at all
>spend an hour searching stack overflow and rereading tutorials to no success
>rewrite the script completely from scratch
>it works
>do a diff on both scripts
>in the original script, one of my decorator's return statements was indented one too many times and the linter didn't pick up on it
>neither did i

g-goodbye friends...

Attached: done.jpg (444x460, 126K)

learn Haskell

>C

Guys got 4 linked lists of around 500 elements each to sort.

What is the best way to speed up (to seconds) insertion of instantly created nodes that get assigned to the list upon creation.

Also, if I choose to just fill in the linked list without sorting which sort might give me the best results? Qsort or Merge?

help this noob

Attached: fN_RjNgI.jpg (500x500, 32K)

>weren't you making some demoscene effects? I wanna see those.
Here's a few effects I have so far. Video was blurry to begin with then I had to downscale and lower bitrate but hopefully this gives you an idea.

Attached: output2.webm (360x240, 2.6M)

500000 I mean lmao

mergesort is by far better for linked lists.

you'll have to clarify what you mean by insertion. I'm having trouble, uh, parsing, your sentence.

Are these singly or doubly linked lists?
That is really sweet. shit can get ya laid for sure.

kek, I just went too overboard.

I have a file of around 600000 elements to read. The files total around 4M of elements to read and parse and etc.

Lets just look at a single file, suppose I read a file line, parse it into a node and insert it in the list. This takes way too much time (hours I believe). How can I speed this process if I choose to do it this way?

I actually figured out a smart way that speeds around 3x, which is store the first node of a certain information (year in this case) in a pointer vector, so I can start the insertion at a checkpoint to say so.

But it's not enough.

Filling up the linked list from 0 to full then using mergesort should be faster than filling up the list, inserting each node so that its always sorted. Don't be a brainlet and make sure your mergesort uses runs. Bonus point if you deforest your algorithm so that your generator function directly spits out runs instead of making the linked list and splitting it up into runs.

Filling up the list so that it's always sorted is equivalent to insertion sort, which is O(n^2).

Still working on refining my PNG code before I take the deep dive into implementing DEFLATE and ADAM7 Interlacing

How would you rewrite this?
The point of this code is to be able to write something like:
if( currNum == IDAT_TAG )
and make it clear what the value of IDAT_TAG is.

Here's what I have.
#define STR_TO_HEX(str) (str[0]

Attached: ThinkThanos 2.png (478x483, 155K)

You are use wrong datastructure use one tree, insertions in list are O(n)

Should be parentheses instead of brackets, sorry.

PHP7 isn't awful and there's a fuckton of legacy PHP to maintain

its guaranteed work

Are you inserting it into the list sorted? I.e. if you were reading playing cards, would you read a two from the file and insert it into your linked list before a 3 or just at the front? If you are, then you're doing insertion sort my user. O(n^2) vs O(n log n) makes a comically huge difference here.