[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vr / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / asp / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / qst / sci / soc / sp / tg / toy / trv / tv / vp / wsg / wsr / x] [Settings] [Search] [Home]
Board
Settings Home
/g/ - Technology



Thread archived.
You cannot reply anymore.



File: haskellos.png (21 KB, 1446x2048)
21 KB
21 KB PNG
What are you working on?

Previous: >>65959363
>>
>>65963593
>>65963678

Can you guise help me figure out why this Python 2 code ( https://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)
>>
>>65963738
fuck off piratefag
>>
>>65963756
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?
>>
File: 1510128275974.jpg (456 KB, 1280x720)
456 KB
456 KB JPG
>>65963715
please post a programming (anime) related picture next time.
>>
>>65963862
Haskell is pure, just like the best animays
>>
File: primejacky.webm (2.87 MB, 1280x548)
2.87 MB
2.87 MB WEBM
/dpt/-chan, daisuki~

Ask your much beloved programming literate anything (IAMA).

>>65963715
please use an anime image next time.
>>
>>65963715
>Haskell loss
We have reached new lows.
>>
>>65963890
why should I learn rust ?
>>
>>65963926
it saves you from a lot of easily avoidable mistakes
>>
>>65963926
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.
>>
>>65963926
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.
>>
>>65963926
for the code of conduct
>>
>>65963960
this
>>
>>65963781
Worst argument ever made with regards to pirating
>>
>>65963960
Tha'ts it, I'm sold !
>>
>>65964279
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?
>>
>>65964332
c# by far
>>
>>65963738
post error message or something, how does it fuck up
>>
>>65963862
Haskell is the purest form of anime
>>
>>65964332
sql
>>
>>65963738
might be because b'aaaa' == 'aaaa' is true on python2.7 and false on python3.4
>>
>>65964332
Elisp.
Just tell everyone that you will fix, optimize, and trim useless stuff from their init.el or .emacs for a fee.
>>
>>65964332
js
>>
>>65964332
>easy
visual basic
>>
>>65964339
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 <module>
for block in iter(lambda: keybin.read(0x20), ""):
File "FunKeyCIA.py", line 286, in <lambda>
for block in iter(lambda: keybin.read(0x20), ""):
KeyboardInterrupt

>>65964400
Thanks, I'm not sure which of those lines it's doing the check on, I'll have a look
>>
>>65964494
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
>>
>>65964357
>>65963884
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?
>>
>>65964561
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)
>>
>>65964681
>do'ing outside marriage
>>
>>65964561
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#.
>>
https://sourceforge.net/projects/win-agui/?source=directory
>>
>>65964736
Qt + C++
>>
>>65964694
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
>>
>>65964736
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.
>>
>>65964776
My job uses C++. It's even government work.
>>
>>65963926
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
>>
>>65964712
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
>>
>>65964736
>visual c#
i know c#, but dafuq is visual c#?
>>
>>65964681
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
>>
>>65964808
Visual C# is Microsoft's implementation of the C# language. It's a branding.
>>
>>65964833
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?
>>
>>65964792
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 ='http://hentaihaven.org/ajax.php?action=pukka_infinite_scroll&page_no={}&grid_params=infinite_scroll=on&infinite_page={}&infinite_more=true&current_page=home&front_page_cats=&inner_grid%5Buse_inner_grid%5D=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 'http://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)
>>
File: 1525891708311.png (6 KB, 229x220)
6 KB
6 KB PNG
>type inference is a coping mechanism
>>
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.");
}
}
}
>>
>>65964909
your printing it 12 times per name
>>
>>65964888
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
>>
>>65964945
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

https://my.mixtape.moe/mzexqk.7z
>>
>>65964909
Are you retarded. Of course it will print it 13*12 times.
>>
>>65964971
>download
hell no
>>
>>65964971
>share binary
nice try
>>
>>65964971
go to facebook
join a programming group with lots of pajeets
do your shit there
???
profit
>>
>>65964956
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.

>>65964971
that looks neat but I am definitely not downloading a binary from fucking 4chan. post the source code or post a webm.
>>
>>65964332
Python, Java, C#, Ruby
Take your pick based on local demand.
>>
>>65965028
>applying premature optimization to compilers
Fuck off you cretinous slug.
>>
>>65965047
PHP is the hottest programming language in my country. I hate PHP. People Hate PHP. Stack overflow caused by PHP.
>>
>>65965056
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.
>>
>>65965111
Did you respond to the wrong person?
>>
File: 1526502207929.png (803 KB, 2358x2526)
803 KB
803 KB PNG
>>65965125
>>
>>65965155
dumb frogposter
>>
File: output.webm (2.57 MB, 720x480)
2.57 MB
2.57 MB WEBM
>>65963715
>What are you working on?
20x12 RGB LED matrix. I think I have everything completed including the inverter box and everything.
>>
>>65964879
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.
>>
File: terryflip.png (154 KB, 509x414)
154 KB
154 KB PNG
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.

https://youtu.be/tEM9eNzXLIM
>>
>>65965063
In that case, make your own language and target PHP.
>>
>>65965047
>>65965299
How do I find a job near me? Can someone help
>>
>>65965281
>2018
>not using node
>>
>>65965315
>https://whoishiring.io/
>>
>>65965175
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.

>>65965281
did you buy a new microphone yet? I'll only watch your stream if your audio quality is better.
>>
File: box.png (547 KB, 720x480)
547 KB
547 KB PNG
>>65965175
Even added a fan to my inverter box since it was getting very very toasty.

>>65965364
>weren't you making some demoscene effects? I wanna see those.
Yes, I'll make you a webm with what I have so far.
>>
>>65965281
4/10, get a better hairstyle and a stronger chin
>>
>>65965403
>inverter
>leds
??? ok ignoring that, wouldn't running mains voltage through a transformer be more efficient and hence cooler?
>>
>>65964786
“Hard way” books are shit.
If you know another language use “modern Python cookbook”.
https://www.packtpub.com/application-development/modern-python-cookbook

If you don’t know programming use
https://automatetheboringstuff.com
>>
File: plasma_still.png (474 KB, 720x480)
474 KB
474 KB PNG
>>65965439
Transformer is what I meant by inverter.

I shot some videos, just making them into webms now.
>>
how can I use opengl with qt? I've found a bunch of old stuff but nothing about opengl 4.5+
>>
>>65965550
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.
>>
>>65965550
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.
>>
>>65965587
you mean this but with QOpenGLFunctions_4_5_Core Class instead of QOpenGLFunctions?
http://doc.qt.io/qt-5/qtgui-openglwindow-example.html

>>65965572
what would you advice instead?
>>
File: done.jpg (126 KB, 444x460)
126 KB
126 KB JPG
>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...
>>
>>65965757
learn Haskell
>>
File: fN_RjNgI.jpg (32 KB, 500x500)
32 KB
32 KB JPG
>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
>>
File: output2.webm (2.6 MB, 360x240)
2.6 MB
2.6 MB WEBM
>>65965364
>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.
>>
>>65965784
500000 I mean lmao
>>
>>65965784
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?
>>65965791
That is really sweet. shit can get ya laid for sure.
>>
>>65965842
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.
>>
>>65965784
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).
>>
File: ThinkThanos 2.png (155 KB, 478x483)
155 KB
155 KB PNG
>>65963715
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]<<8*3)|(str[1] << 8*2) | (str[2] << 8) | str[3]

const char* IDAT_STR = "IDAT"

enum PNG_Tags{
IDAT_TAG = STR_TO_HEX{IDAT_STR},
...
};


My main question is: Because IDAT_STR is a constant, will the compiler optimize and not have to recalculate STR_TO_HEX each time I call the code?
>>
>>65965904
You are use wrong datastructure use one tree, insertions in list are O(n)
>>
>>65965930
Should be parentheses instead of brackets, sorry.
>>
>>65965063

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

its guaranteed work
>>
>>65965904
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 anon. O(n^2) vs O(n log n) makes a comically huge difference here.
>>
>>65965941
>>65965930
If you turn on optimizations it should recognize that it's a constant expression and fold it. However as with all optimizations you should compile and inspect the output if it matters to you.


also nest the whole thing in another layer of parentheses to make it a bit more hygienic.
>>
>>65965953
Yes it's insertion sort!

Thing is: how do you speed it up in a brilliant way
>>
>>65965971
Read all the lines into a single unsorted linked list. Do mergesort. Should expect around 45000x give or take a few magnitudes speedup.
>>
>>65966008

I know exactly the winnings...

3hours vs 0,3 seconds

comical right?

If implement the thingy I listed here:
>>65965904

I get around 1h


I will find a way to reduce it to sub-1min
>>
File: dead_inside.jpg (360 KB, 1024x1359)
360 KB
360 KB JPG
How do you implement the repository pattern when the "getAll" cannot return a collection of the same type as the "getSpecific" returns.

Option 1, I define a new type and return a collection of that new type. The new type models the same thing as the "getSpecific" return type.

Option 2, I return a collection of the same type as the "getSpecific", but each instance is only partially initialized. I am unsure as to how to reliably communicate the partially initialized fact to any developer using the Repository


/* Database has a Persons table with columns
* Id, FirstName, LastName, LifeStory.
*
* There is a stored procedure that takes an Id
* and returns a row from the table.
*
* There is another stored procedure that returns
* every Id and Name of every Person in the
* Persons table via a cursor.
*/

public class Person {
public int id;
public String firstName;
public String lastName;
public String lifeStory;
}

public class PersonSummary {
public int id;
public String firstName;
}

public class PersonRepository {

public Person getPerson(int id) {
//something
}

//Option 1
public List<PersonSummary> getPersons() {
//code
}

//Option 2
public List<Person> getPersons() {
//code
}

}
>>
>>65965734
hmm can't say how for sure. many years ago I did opengl with qt. Probably! I use SDL these days but I don't know if you also want widgets other than just a window to draw in.
>>
>>65966054
Why even bother with a collection of new types in "getSpecific" case
I would just return a map of id->string instead.
>>
how hard would it be to create an ML algorithm that could identify businesses that a particular figure-head is invested in?

input: Elon Musk

output: SpaceX, Tesla, Boring Company, etc...
>>
>>65966125
Do you even know what ML is?
>>
>>65966125
it's called google faggot
>>
>>65966125
Really hard because ML does pattern recognition and repetition, whereas what you are asking for would require a web crawler instead.
Get on my level n00|3
>>
>>65966123
It is just an example. I tried to keep it simple.

The "getSpecific"'s backing stored procedure has 50 something cursors that carry the data to populate the single returned object.

The "getAll"'s backing stored procedure also has many cursors carrying a subset of data for each object in a table.
>>
>>65966164
Maybe I'm going the wrong way with ML.

I know I need to make a web crawler and an algo to detect the companies that person owns/heavily invested in. Basically I'd want the return to be companies and not things like Ted talks / public appearances, but only by supplying the persons name and nothing else.
>>
>>65966125
lol
>>
>>65966225
US companies are listed in databases in official state websites. Cross reference nouns each of the silicon celebrities are associated against those databases. Here is Texas's
https://mycpa.cpa.state.tx.us/coa/
>>
i'm working on the worst fizzbuzz i can conjure, recently giving Fizz/Buzz/FizzBuzz from seeding the prng and choose a consonant and a vowel, then adding "zz" to the end

https://github.com/chinatsu/justpythonthings/blob/master/fizzbuzz.py
>>
>>65966258
Neat, thank you.
>>
>>65964332
PowerShell
>>
>>65965028
>Interesting that lisp is still faster than hasklel even though common lisp is only 4 years hasklel's senior.
blatant lie
>>
>>65966278
write it in malbolge.
>>
File: speed.png (72 KB, 645x376)
72 KB
72 KB PNG
>>65966403
>blatant lie
off by two years, but nevertheless the truth hurts doesn't it? Even more embarrassing when you factor in the AI winter. A dead language runs circles around something with the full backing of autistic wankers.

The slowest lisp benchmark is faster than the 25th percentile of hasklel programs. And the 25th percentile of lisp programs is faster than the median of hasklel programs. Don't think for a moment they didn't try though. The hasklel nerds put way more effort in their programs, with many more revisions than the lisp ones.
>>
I just finished a book on C++. The farthest the book covered was the standard template library and bitwise operations. I think I have a good undertstanding of object oriented programming. Now I'm a bit confused where I should go next, but I know that I want to build something practical. Should I learn python and web development or java and android development? Is there something learn in C++ that could allow me to build something useful and not purely in the command prompt? I'm open to any suggestions, but my ultimate goal is to have interesting projects to put on job applications.
>>
File: output3.webm (2.87 MB, 720x480)
2.87 MB
2.87 MB WEBM
FizzBuzz on led matrix
>>
What do you think about using malloc and goto in C++?
>>
>>65966607
goto is useful of course. The only reason I can think of using malloc in C++ for is if you're doing the struct hack. otherwise just new yeah?
>>
>>65966539
>job
Build websites in Django python or Java.
Learn JavaScript and some frameworks as react.js.
>>
>>65966607
No reason to use malloc in C++, as for goto, I can only think of one good use case but it's quite pointless in C++ because of RAII.
>>
>>65966643
that's what I was leaning toward, thanks
>>
>>65966642
>The only reason I can think of using malloc in C++ for is if you're doing the struct hack
I had the idea of using malloc with different sized structs that have common members as a kind of binary interface, unlike using virtual functions.
>>
If someone has the title "researcher" what do they do? We have a bunch at my office but they're a different secret department.
>>
>>65966687
dangerous! for a safer way of what you're doing, check out the linux kernel: https://kernelnewbies.org/FAQ/LinkedLists
>>
>>65966741
dangerous! for a safer way of what you're doing, check out the Rust programming language: https://www.rust-lang.org/
>>
File: 1502250977544.jpg (16 KB, 480x459)
16 KB
16 KB JPG
How to make local apps with web based GUIs? Does one have to run an instance of Apache/NodeJS on localhost?
>>
>>65966719
orgies
>>
>>65966849
Yeah some sort of built-in server, not really apache though.
>>
>>65964332
If you're design and user experience oriented, JS. Plenty of jobs as long as you can prove yourself.

If you're more data/cs oriented, Python. Same deal.
>>
>>65966830
>mimicking a nocaps poster
>can't help but capitalize zer's precious rust
rustlet safety is different and unwanted.
>>
File: 1525833700031.png (104 KB, 265x265)
104 KB
104 KB PNG
Other than project euler autism and dpt-roll larping, what are some beginner friendly programming practice questions?
>>
>>65966858
What kind of server do you recommend for local apps?
>>
>>65966830
Last I heard, Rust doesn't properly let you do linked lists
>>
>>65966919
a monad is a _ in the category of _
>>
>>65966921
It depends entirely on what you want to achieve, if it's purely UI and some basic file reading and shit then you don't need a web server but what you need instead is Electron cancer. It's really hard to tell without any context.
>>
File: mib.jpg (29 KB, 767x431)
29 KB
29 KB JPG
>>65966719
>>
>>65966921
golang's http pkg
>>
>>65966923
You can do basic singly-linked lists just fine, but to have a tail pointer or double links you have to enter unsafe territory.
>>
Please stop calling me gay
>>
>>65966962
stop being gay
>>
>>65966962
quit being a faggot then
>>
>>65966962
Stop inviting me over.
>>
>>65966919
http://www.spoj.com
>>
>>65964986
>>65964996
>>65965028
This is why webshit is so popular. People won't download your random dodgy binaries these days.
>>
>>65967224
I'd download his source code.
>>
I'm 25 and I'm just now learning how to code, I can implement simple solution to problems of like Code Jam and so on, but I lack any real world knowledge. I find C and C++ a lot more interesting than webdev, but it seems that the entry barrier of web shit is a lot lower, since I'm a average dude behind the wave it seems that studying webdev would be a much smarter choice. Thoughts? Can one be a mediocre C++ dev and find jobs?
>>
>>65967252
See >>65966886
>>
>>65967252
>can't program his way out of a wet paper bag
>calls web shit

lmfao
>>
File: 1526495833816.png (18 KB, 1446x2048)
18 KB
18 KB PNG
>>65963715
your png is now optimized
>>
>>65967427
stop stealing the souls of images you fiend
>>
>>65964561
$ 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 <module>
for block in iter(lambda: keybin.read(0x20), ""):
File "FunKeyCIA.py", line 286, in <lambda>
for block in iter(lambda: keybin.read(0x20), ""):
KeyboardInterrupt
>>
>>65964909
Why does allocateDesk take a String a but never use it? I'm not sure what you are trying to do, but if you just call allocateDesk from main instead of allocateAllDesks, it should print 12 times. You're not even using your arrays though.
>>
>>65966539
why would you read a book on c++ if you want to build something in python/javascript or java?
>>
is there a way to make qt documentation show up in qt creator or visual studio?
for example, showing the description of a function when I hover the mouse over it
>>
>>65967563
It was required for the class on object oriented programming I was taking
>>
When you're trying to see if two bools have the same value, is there a performance difference between
bool result = bool1 == bool2

or
bool result = !(bool1 ^ bool2)

?
>>
>>65968195
The latter would be slower if anything, but on any decent compiler they should turn out to be the same thing. You have to remember that CPUs have dedicated comparison instructions (e.g. TEST and CMP on x86).
>>
>>65967785
I think F1 shows docs in QtCreator?
Maybe F10

Go fuck yourself with MSVC docs though
>>
>>65967252
>Can one be a mediocre C++ dev and find jobs?
This almost seems like a pointless question, because if you're at least passable with a C/C++ compiler, you can blend into the fabric of a lot of companies and do mediocre work there.
>>
>>65968195
>pinhole optimizations
don't bother. the compiler can do that easily. In case you were wondering, the compiler compiles both expressions down to cmpb. I have no idea what cmpb is but it sounds similar to cmp
>>
>>65967252
Any Job with C or C++ is typically master degree only with 10+ years of experience.

but there are rare outliers.
>>
>>65966607
No reason to do either.

>malloc
You should be using new, or an allocator method like std::make_shared

>goto
Your program is structured poorly if you have to use goto
>>
>>65968231
Cool, thanks!

>>65968258
Well I'm going to be doing millions of these, so I wanted to make sure.
>>
>>65966539
>The farthest the book covered was the standard template library and bitwise operations.
That sounds like C++98 only.

You should learn lambdas, auto keywords, creating templated types, move semantics, perfect forwarding, r-value references, etc...
>>
>>65968317
sepples has shit lambda syntax
>>
reminder to use vert.x
>>
>>65968392
It could have been worse like PHP
>>
>>65964332
Java. It's the "get shit done" language and in high demand everywhere. Don't listen to webshits recommending JS, you will have to fight with hundreds of shitty bootcamp grad over shitty frontend jobs
>>
>>65965329
>2018
>using node and not vert.x
>>
>>65968300
rule of thumb: if it's a simple optimization you can apply "everywhere," the compiler can do it better. So next time you
x << 1 + x
, consider a x * 3 instead you degenerate speedmonkey.
>>
>>65966539
Java and web development
>>
what exactly is node js useful for and where is the place to start on it
>>
>>65968530
It's javascript used server side. Start here: https://nodejs.org/en/docs/
>>
>>65968530
idk what the typical use case is.

but i use node to run js in my console to test code logic on the pc.
since js is a web thing only w/out node.
>>
>>65968463
No, I mean it's part of an inner inner inner inner loop.
>>
>>65968540
but why is this useful? would i manage a database in node js, or write application logic in node js? is that better than say current server side java applications or managing a database with mysql?
>>
>>65968530
Network latency is thousands of times larger than latency due to slow code, so the idea is that you can get much better performance for networked applications by using concurrency. Node.js does this by using something called the "event loop".
>>
>>65968579
https://www.youtube.com/watch?v=dlfrWbYk1v0&list=PLRAV69dS1uWTSu9cVg8jjXW8jndOYYJPP
>>
>>65965315
Look on Indeed and just search languages and frameworks you know.
You may have to be willing to relocate.
>>
>>65968317
All of those you mentioned were covered besides perfect forwarding, the book was just in a weird order for some reason.
>>
>>65968611
ah now it makes sense. client sends stuff via javascript to a node application on server, and node sends stuff back via javacsript which is smoother than going js -> php -> sql -> php -> js. is there a significant performance difference?

also, unrelated, how is npm related to nodejs? is it just a way to manage different node based applications? i've installed stuff via npm before but didnt know what i was doing really lol
>>
>>65968676
Google "package manager"
>>
what is the /g/ approved book to learn C++?
>>
>>65968734
yes but how does npm relate to nodejs specifically. how does it differ from other package managers such as apt-get
>>
>>65968579
No. It's worse in a lot of ways. The advantage of node is that you don't have to hurt your wittle mind learning something else. Don't get me wrong, this is a huge advantage: make or break at certain companies who have hired themselves vast collections of brainlet employees.
>>
>>65968813
By managing node packages
>>
>>65968745
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list
>>
>>65968813
It lets you download and install libraries in an easy/intuitive way. Once you
npm install somelibrary
then you can
var Library = require('somelibrary')
>>
If you guys could go back and start from square one next, what languages would you have focused on and what would you have avoided? I'm in school right now and in the process of learning c++, but I won't be taking another programming class until next spring. I'm thinking of learning C# and JavaScript since I've seen a lot of job listings with a desire for those languages, but is going by what companies want a bad measure? Am I better off sticking to c++ or trying to find stuff I really like working with? Also is web design worth getting into or is it a meme?
>>
>>65968392
what's so bad about it?

auto partial =
[](auto f, auto... x)
{
return [=](auto... y)
{
return f(x..., y...);
};
};


come on, you could do a lot worse than that
>>
>>65968898
Probably start with C instead. I spent too much time on Java and it turned out to be a dead end.
>>
What's the daily programming discord?
>>
>>65968908
Where do you live? I'm in the NYC area and almost every job listing I've seen wants some JavaScript experience. I was thinking of learning js anyway but I'd like some opinions
>>
>>65968898
C, Python, Haskell
>>
>>65968898
>>65968908
Oh I see you mean in terms of jobs. Definitely javascript. It lets you do both browser and server side work. A close second would be python.
>>
>>65968922
discord uses names
4chan is anonymous
why would dpt have a discord?

certain languages/frameworks have their own discord channels though. google them.
>>
>>65968947
>why would dpt have a discord?
why indeed :^)
>>
>>65968977
>>>/reddit/
>>
>>65968947
>certain languages/frameworks have their own discord
but those would be full of non-4channers and im willing to bet they'd all be super experienced individuals working in the industry and i'd feel really stupid asking for babby help
>>
>>65968989
your link didn't work
>>
>>65968908
>>65968937
Why C instead of C#?
>>
>>65968610
ahhh oh god this is so wrong

Please educate before psoting wrong info.

The node.js event loop is NOT concurrent, it is single threaded, single core. All operations in node.js are non blocking, asynch, they get passed to handlers that are registered on the event loop.

Btw. vert.x does the same thing but has double the performance on a single instance AND can multithreading, which node.js cannot.

Check these benchmark out:
https://github.com/mach-kernel/vertx-polyglot-counter#benchmarks
https://www.techempower.com/benchmarks/#section=data-r15&hw=ph&test=db

If you want fast, realiable, reactive web applications / microservices, use vert.x
>>
>>65969040
performance?
>>
what has a better (and modern) job market? c++ or go
>>
>>65968908
How the fuck is Java a dead end
>>
File: 1513815326858.jpg (12 KB, 182x268)
12 KB
12 KB JPG
>>65969041
Pajeet pls. Learn the difference between concurrency and parallelism.
>>
>>65969019
>4channers
You'll fit right in
>>
>>65969040
>>65969072
C will teach more about how computing actually works. Java and C#, while acceptable-tier starter languages, will turn you into a pajeet if you stick with them too long. What I mean by that is that you'll approach problems by gluing together someone else's code that you don't understand and just generally spewing out tens of thousands of lines of low quality code until something finally sticks.
>>
>>65969160
gluing together some else's code allows you to write less code
>>
>>65969218
With enough experience you will eventually discover that's not always the case. Using someone else's code introduces a nonzero amount of complexity into your application, and you need to make sure that the benefit of using it outweighs the cost. Otherwise you can end up working with AbstractFactoryListenerBeanFactories, and turn simple problems into disgusting piles of unnecessary interfaces and abstraction.
>>
File: thunk.png (155 KB, 600x600)
155 KB
155 KB PNG
>>65963715
what is a tensor?
what is a cost function?
does gradient descent optimize the cost function or the model formula itself?
how does gradient descent work when you don't have a continuous model formula/cost function?
why is logistic regression also called linear classification?
why is tensorflow so fucking obtuse?
where can i brush up on my linear algebra and calculus?
>>
>>65968898
i started out in high school with Java (briefly) because it was the only programming class available, but before long i realized C# was much better and never looked back. knowing it even helped me land a contract position at Microsoft when i was 19 lol. then eventually i transitioned to mainly C++ due to working on performance-critical stuff, but i still use C# all the time for tools, tests, prototypes/proofs of concept, toy projects, stuff like that. only thing i'd change if i could go back would be skipping Java. can't recommend C# enough; it's easy to learn and perpetually nice to work with, but also surprisingly powerful when you need it (low floor with a high ceiling). it's gaining a lot of traction in the industry lately too, now that MS has finally opened it up (it was once only officially supported on MS platforms but it's open-source/cross-platform/permissively-licensed now). i know people at a couple well-known game companies where they use it for all their internal tools, tests/automation, asset pipelines, servers, etc
>>
>>65969331
>what is a tensor?
An n-dimensional array.
>what is a cost function?
Cost function is a bad name, I prefer to call it the error function because it tells you how "wrong" your results are. You differentiate with respect to this function in order to minimize it, giving you a mostly error-free, correct solution.
>does gradient descent optimize the cost function or the model formula itself?
What did he mean by this?
>how does gradient descent work when you don't have a continuous model formula/cost function?
It's a numerical algorithm. It multiplies the gradient by a constant amount (the "learning rate") and applies it as an update to the weights, thus reducing the value of the error function slightly.
>why is logistic regression also called linear classification?
ML is just new fancy name for statistics. All you're doing is fitting a regression surface (sort of like fitting a line), to some data that you've collected.
>why is tensorflow so fucking obtuse?
Because python is slow, so what it actually does is compile the graph that you build in python down to efficient code for either the GPU or CPU.
>where can i brush up on my linear algebra and calculus?
If you don't understand matrix multiplication or what a derivative is, then I am seriously concerned. Really that's all you need to know.
>>
File: komachan.jpg (24 KB, 600x337)
24 KB
24 KB JPG
>>65969160
been coding in c# for 10 years
i'm a pajeet now
>>
Just did this readme,suggestions?
first time seriously doing a readme, instead of writing "lol just werks xd"

https://github.com/GalateaEngine/Galatea/tree/emotion_classifier_microservice/src/microservices/modules/emotion
>>
>>65969160
What kind of jobs would be available if I develop a solid foundation in C? Is it just a good idea to bounce around between c, c++ and c# or should I solely focus on one and then learn front end?
>>65969339
How long have you been in the industry and where do you live now? I really want to have some kind of job prospects when I graduate community college next year, even if it's only part time while I get my BS. Anymore advice you can offer would be great
>>
>>65969409
thanks for the info
>Cost function is a bad name, I prefer to call it the error function because it tells you how "wrong" your results are. You differentiate with respect to this function in order to minimize it, giving you a mostly error-free, correct solution.
and this minimization procedure is called gradient descent?
>What did he mean by this?
a linear regression can be represented by y=w1x1 + w2x2 + w3x3... right? does gradient descent take the partial derivatives of this function with respect to each x_n or does it do that for the cost function?
>It's a numerical algorithm. It multiplies the gradient by a constant amount (the "learning rate") and applies it as an update to the weights, thus reducing the value of the error function slightly.
I see, but I'm having a hard time visualizing this. Do you know of any books/tutorials that would guide me through this whole learning+optimization process on pen and paper? I think that would help me understand it the best
>ML is just new fancy name for statistics. All you're doing is fitting a regression surface (sort of like fitting a line), to some data that you've collected.
but i thought logistic regression creates a sigmoid function, i don't see what's linear about that
>If you don't understand matrix multiplication or what a derivative is, then I am seriously concerned. Really that's all you need to know.
i understand both, but i eventually want to be able to read and understand ML papers, and they seem to use more calculus than i'm familiar with
>>
>>65966580
how would I go about making something like this anon?
>>
File: 1470792067398.png (36 KB, 268x237)
36 KB
36 KB PNG
Employed Haskell programmer here
>>
>>65969521
i assume you mean the led matrix

get an arduino and an 8x8 led matrix i2c , there are a shit-ton of examples out there
>>
>>65969331
https://github.com/cangxuexiao/Linear-Algebra/blob/master/Linear%20Algebra%20with%20Applications%205th%20Edition%20Otto%20Bretsch%20.pdf
>>
>>65969160
>gluing together someone else's code that you don't understand
never quite understood how that worked. I mean, I can understand not maybe knowing the hard math behind the code, but there's no reason you shouldn't know what the code is doing, unless you're doing something retarded like copying an entire framework.
>>
>>65969507
>and this minimization procedure is called gradient descent?
Yep!
>a linear regression can be represented by y=w1x1 + w2x2 + w3x3... right? does gradient descent take the partial derivatives of this function with respect to each x_n or does it do that for the cost function?
Both. It uses the chain rule to backpropagate the gradient from the error/cost function from all the way up through the network. Maybe read up on automatic differentiation if you're curious about how this works. It's a lot simpler than it sounds.
>I see, but I'm having a hard time visualizing this. Do you know of any books/tutorials that would guide me through this whole learning+optimization process on pen and paper? I think that would help me understand it the best
Let's say I blindfold you and put you on a hill. Your goal is to reach the top of the hill, but all you are able to detect is how steep the hill is at your current location. So what you can do is take one step in the direction of the incline, and then see where the steepest incline is at your new location. You then take another step and repeat this process until you eventually arrive at the top of the hill where there is no more incline. That's gradient ascent, but you can do the same with derivatives for gradient descent.
>but i thought logistic regression creates a sigmoid function, i don't see what's linear about that
I wouldn't get too hung up terminology. The field is pretty new, so it's not entirely standardized yet.
>i understand both, but i eventually want to be able to read and understand ML papers, and they seem to use more calculus than i'm familiar with
Do you have an example?
>>
>>65969492
>What kind of jobs would be available if I develop a solid foundation in C? Is it just a good idea to bounce around between c, c++ and c# or should I solely focus on one and then learn front end?
What's your background. I would recommend C only as an instructional language, or if there's a reason you need it for high performance computing or embedded development. If you want employability then I recommend javascript.
>>
>>65969591
that makes sense, t hanks. i'll check out automatic differentiation.

>Do you have an example?
i saw this earlier today: https://arxiv.org/pdf/1804.00308.pdf
i don't even understand what all the variables mean on the theorem on page 16, let alone how everything fits together
>>
>>65969614
The only background I have is strictly schoolwork, so basically c++ at this moment. That's pretty much what I'm wondering if I should focus on stuff that can land me a job in the nearby future. I'm definitely interested in staying in this job market(NYC) for now. Im really not that interested in machine language at all though I have heard it's in high demand right now
>>
>>65969634
i recommend you to do a nice proyect to have in your github to show.
that always helps
>>
>>65969630
That proof is a lot more statistics than calculus. But for the majority of cases I don't think that's representative of what you need to know.
>>
>>65969634
>The only background I have is strictly schoolwork
What's your major?
>>
>>65969160
t. doesnt know how to use java properly
>>
>>65969794
wtf is "t."?
>>
>>65969801
you need to go back
>>
>>65969801
finnish for "signed"
its a meme
how new r u
Probably as new as you are to java in a professional context
>>
File: 1456116993975.gif (697 KB, 176x119)
697 KB
697 KB GIF
>>65969794
https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

Dear sirs,

This project reminded me of you.

Thankfulness most graciously,
Ranjesh - Certified Enterprise JAVA Developer
>>
File: 601.jpg (24 KB, 657x527)
24 KB
24 KB JPG
>>65969809
>t.
>finnish for "signed"
>>
>>65969837
terveisin
>>
>>65969713
Computer science
>>
>>65969906
which means regards
>>
Anyone here familiar with ActionScript and whether or not it's worth putting any time into?
>>
>>65965063
malaysia?
>>
>>65966919
do all the questions in leetcode
>>
Using my fuckoff time at work to learn a new skill. Which runs better on Windows 10 Enterprise: Vim or Emacs?
>>
File: 1476819420830.jpg (45 KB, 1500x1500)
45 KB
45 KB JPG
Best way to copy the sign of one integer onto another?
>>
File: 1495955773766.png (304 KB, 1920x1080)
304 KB
304 KB PNG
Post programming challenges.
>>
>>65970105
Visual Studio 2017
or
VS Code
>>
>>65970142
x *= y < 0 ? -1 : 1;
>>
>>65970142
a *= signum(b);
>>
>>65970152
>>65970160
Any that don't use a multiplication or comparison?
>jesus christ these fucking captchas
>>
>>65970142
if ((int1 > 0 && int2 < 0) || (int1 < 0 && int2 > 0)) int2 *= -1
>>
>>65970152
>>65970160
This doesn't work if a is already negative.
>>
>>65970151
I use both of these daily.
>>
>>65970173
>>65970202
x *= x < 0 != y < 0 ? -1 : 1;
>>
>>65970152
>>65970160
>>65970183
>>65970238
Would this work?
if (x<0 != y<0) x = ~x;

It relies on the fact that they're represented by two's complement. Also does someone more knowledgeable than me know if this would introduce a branch instruction or not?
>>
>>65970323
just do x = -x
>>
>>65970323
The if statement will work but it's unclear what it's trying to do at first glance. Don't think it follows best practices. Flipping x may not provide you with the correct answer. If you flip 30, you get -31.
>>
File: 1517214197486.jpg (14 KB, 287x315)
14 KB
14 KB JPG
>starts taking online classes of programming
>realizes should've learned data structures and cauculus before programming
>shit's kind of fun but not nearly as fun to study as actual programming
why didn't you let me know anons
>>
>>65970323
this compiles to a branch in gcc but not in clang
>>65970238
>>
>>65970384
I disagree. Calculus won't help you with everyday programming.

As for data structures, you *will* use them with everyday programming, but you crawl before you walk. Don't get bogged down in the conceptual.
>>
>>65970384
You don't necessarily have to understand calculus and data structures to start learning programming. A lot of the more simple, basic data structures like 1D/2D array and linked list are pretty intuitive once you start actually coding projects that use them.

Usually the order goes basic programming and calculus ==> Discrete/Data Structures ==> more advanced software development and hardware/systems
>>
>>65970146
wtf is Nentendo Oil Panic you absolute space nigger?
>>
>>65970323
>>65970365
>>65970382
>>65970420
What about
x = ((x ^ y) >> 31 ) ?  -x : x;

Ternary ought to avoid the branch, and it checks to see if the sign bits are different directly.
>>
File: 1453590480680.png (411 KB, 494x795)
411 KB
411 KB PNG
>>65970084
Okay but leetcode doesn't have rust options so I'm just posting it here
https://leetcode.com/problems/two-sum/description/
fn two_sums<'a, T>(v: &'a [T], t: &'a T) -> Option<(usize, usize)>
where
T: ::std::cmp::Eq,
&'a T: std::ops::Add<&'a T, Output = T>,
{
for (i, v1) in v.iter().enumerate() {
for (j, v2) in v.iter().enumerate() {
if v1 + v2 == *t {
return Some((i, j));
}
}
}
None
}

fn main() {
let v = vec![2, 7, 11, 15];
let target = 9;
let result = ::two_sums(&v, &target);
match result {
Some((a, b)) => println!("{} + {} = {}", a, b, target),
None => println!("No result found,"),
}
}
>>
>>65970456
>avoid the branch
>ternary expression
>>
>>65970547
Doesn't it convert it to a cmov? What's a better way to do it?
>>
File: 1500261941880.jpg (115 KB, 818x1500)
115 KB
115 KB JPG
Anybody have experience with ``Learn Python 3 the Hard Way'' by Zed Shaw? It was on the recommended book list on the Wiki so I decided to give it a try.

I'm wondering whether the book gets any better. I'm not far in, but this far I hate how ``casual'' all of the instruction is. I hate how the author does not explain any of the deeper underlying concepts that would influence design decisions. Everything feels like ``it just werks.'' Maybe this is the spirit of Python?

I have only a little programming experience and haven't touched coding in perhaps 5 years or so, but I was hoping for something far more rigorous while still suitable for beginners.
>>
>>65970076
Almost right. Neighbor of it.
>>
>>65970555
https://godbolt.org/
test it yourself
>>
>>65970638
Neat. Well I guess I'm just going to have to accept the penalty of a branch. I'll use comparison with zero instead of bitshifting for readability though.
int copysign(int x, int y) {
return ((x ^ y) < 0) ? -x : x;
}
>>
File: 1526287249738.png (726 KB, 952x1064)
726 KB
726 KB PNG
>>65970725
i'm a brainlet about bitwise thing. pls explain this bitwise magic for me.
>>
File: 1519908680190.png (262 KB, 510x474)
262 KB
262 KB PNG
>>65970783
help appreciated :)
>>
>>65970725
If you really want bitfuckery, consider this:
return (x & (~0 >> 1)) | (y & (1 << 31));
>>
>>65970529
You don't need to annotate the lifetime there
>>
>>65970857
How does this work? Also what about
int copySign(int x, int y) {
bool oppositeSign = (x ^ y) < 0;
return (x ^ -oppositeSign) + oppositeSign;
}

from http://graphics.stanford.edu/~seander/bithacks.html#ConditionalNegate

>>65970761
By xoring the sign bits together, you can test whether they both have the same sign in a single operation.
>>
>>65970802
nvm not needed
>>65970905
Oh yeah, I just noticed. thanks.
>>
>>65970916
>How does this work?
Retain everything from x except for sign bit (make it zero). Copy sign bit from y.
It avoids any sort of branching and compiles down to 2 instructions.
>>
>>65970942
Won't that give you incorrect answers because of two's complement?
>>
>>65970916
thank you senpai
>>
>time and space efficient
>arrays must be preserved
hmmm
>>
>>65971049
>>
File: 1526449401289.jpg (18 KB, 432x403)
18 KB
18 KB JPG
>>65970142
>>65970152
>>65970160
>>65970173
>>65970183
>>65970202
>>65970238
>>65970323
>>65970365
>>65970382
>>65970420
>>65970456
>>65970547
>>65970555
>>65970638
>>65970725
>>65970761
>>65970857
>>65970916
>>65970942
>>65970959
>>65971015
Who fucking knew such a simple operation would be so god damn complicated. Why isn't there a built-in function to do this?
>>
>>65971087
It exists for floating point in C.
>>
>>65970959
Ah, right. I really fucked up. Then this:
int ySign = (y & (1 << 31));
int xSign = (x & (1 << 31));
int xNeg = (unsigned int)(xSign >> 31);
int yNeg = (unsigned int)(ySign >> 31);
int diffSign = xNeg ^ yNeg;

int xsCompl = (~x + 1);
return xsCompl * diffSign + x * (1 - diffSign);

Left the code verbose, compiler shrank it down to 6 instructions.
>>
>>65969837
dumb frogposter
>>
>>65971125
how dou you know what the compiler turned it into?
>>
>>65971139
See >>65970638
>>
>>65971139
Godbolt. Alternatively, pass -S to compiler for assembly output.
>>
>>65963715
>posting lost in 0.2018*10^4 AD
>>
>>65971125
Oops, it's
(unsigned int)(xSign) >> 31
and below, too. Made a typo when I retyped it from my laptop.
>>
>>65971125
>compiler shrank it down to 6 instructions
H-how? I'm getting over 30.
>>
>>65971201
Pass -O1 or -O2.
>>
File: RHSWzm1.jpg (36 KB, 540x304)
36 KB
36 KB JPG
for some reason this python3 program doesn't work anyone know why
def displaymenu():
input32=int(input("1) Run experiment\n2) Exit"))
return input32


def cal1(we,woc,wa):
wala=we*woc(wa-woc)
return wala

def cal2(wo,woh):
wolo=24*wo*woh*wa
return wolo

def cal3(wa,woc):
wele=wa**2+woc(wa-woc)
return wele

def beamere(wala,wolo,wele):
y=(wala/wolo)*wele
return y

input32 = displaymenu()
while input32 is not 2:

if input32 == 1:
we= int(input("enter your width"))
wo= int(input("enter what ever this is"))
woh=int(input("enter this thing"))
wa= int(input("i really should stop calling my varibles random sylibles"))
woc=int(input("enter your woc"))
wala = cal1(we,woc,wa)
wolo = cal2(wo,woh)
wele = cal3(wa,woc)
y = beamere(wala,wolo,wele)
print(y)



elif input32 == 2:


print("learn english")
break
else:
input32 = displaymenu()
>>
>>65971201
Hmm, neat. Also this is what I'm getting for >>65970916 with -O1-3:
copySign:
xor esi, edi
shr esi, 31
mov eax, esi
neg eax
xor eax, edi
add eax, esi
ret
>>
>>65965155
destiny?
>>
>>65971220
Start by figuring out at what point this is misbehaving. Also use
 markup to post coffee here
>>
File: sad_feet.png (360 KB, 610x1000)
360 KB
360 KB PNG
Explain CMake. Is it useless with an IDE?
>>
>>65971201
>>65971210
>>65971243
Hrm, actually it got rid of the branch in >>65970725 after I turned on optimizations.
copysign:
mov edx, edi
mov eax, edi
neg edx
xor esi, edi
cmovs eax, edx
ret
>>
>>65971276
CMake is a shitty build system.
Use something nicer, like Meson.
>>
>>65970142
>>65970173
>>65970202
>>65971087

$int1.sign.subst: '1', '' ~ $int2.abs;


:^)
>>
>>65971471
What absolute cancer is this?
>>
>>65971503
It does what anon asked, takes the sign of one variable and copies it to the other
>>
>>65971461
Ooooh, nice.
>>
>>65971471
what langfu is this? php?
>>
Can someone explain why including the second loop will crash my calculation ?
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define num_steps 10000
#define N 2

const double omega = 1.0; // frequency
const double tau = 0.1;

double y[N][num_steps+1];

double y_0[N] = {1.0 , 0.0}; // inital conditions


int main(int argc, char **aargv)
{
printf("Hello World\n");
int i1, i2;


for( i1 = 0; i1 < N; i1++)
y[i1][0] = y_0[i1];


for( i1 = 1; i1 <= num_steps; i1++)
{

double k1[N];

k1[0] = y[1][i1-1] *tau;
k1[i1] = -pow(omega, 2.0) * y[0][i1-1] *tau;


double k2[N];
k2[0] = ( y[1][i1-1] + 0.5* k1[0]) *tau;
k2[1] = -pow(omega,2.0)* ( y[0][i1-1] +0.5 *k1[0] ) *tau;

for( i2 = 0; i2 < N; i2++) y[i2][i1] = y[i2][i1-1] +k2[i2];

}

for( i1 = 0; i1 <= num_steps; i1++)
{
double t = i1*tau;
if( i1 %1000 == 0)
printf("%9.6lf %9.6lf %9.6lf\n", t, y[0][i1], y[0][i1] -cos(t));

}


return EXIT_SUCCESS;
}


>>
>>65971723
I think I found a few errors.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define num_steps 10000
#define N 2

const double omega = 1.0; // frequency
const double tau = 0.1;

double y[N][num_steps+1];

double y_0[N] = {1.0 , 0.0}; // inital conditions


int main(int argc, char **aargv)
{
printf("Hello World\n");
int i1, i2;


for( i1 = 0; i1 < N; i1++)
y[i1][0] = y_0[i1];


for( i1 = 1; i1 <= num_steps; i1++)
{

double k1[N];

k1[0] = y[1][i1-1] *tau;
k1[1] = -pow(omega, 2.0) * y[0][i1-1] *tau;


double k2[N];
k2[0] = ( y[1][i1-1] + 0.5* k1[0]) *tau;
k2[1] = -pow(omega,2.0)* ( y[0][i1-1] +0.5 *k1[0] ) *tau;

for( i2 = 0; i2 < N; i2++) y[i2][i1-1] = y[i2][i1-1] +k2[i2];

}

for( i1 = 0; i1 <= num_steps; i1++)
{
double t = i1*tau;
if( i1 %1000 == 0)
printf("%9.6lf %9.6lf %9.6lf\n", t, y[0][i1], y[0][i1] -cos(t));

}


return EXIT_SUCCESS;
}
>>
>>65971811
>>65971811




Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

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.