[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
/dpt/ - Daily Programming Thread
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 255
Thread images: 30
File: tsm.jpg (15 KB, 329x206) Image search: [Google]
tsm.jpg
15 KB, 329x206
Graph theory edition

Old: >>52006792

First for D.

What research problems are you working on /g/?
>>
>>52014970
how to make a browser
>>
The hardest part of programming is naming or namespacing your functions and variables.
>>
>>52014996
You import the
QWebView
widget

Bonus points for using PyQt. Python is good at importing things.
>>
rolling my own VPN killswitch
>>
>>52015009
>pulling in qt
wew

winapi, opengl maybe vulkan because muh acceleration
>>
Want the source?

https://play.google.com/store/apps/details?id=com.terminaltwofourty.rmgsoftware
>>
File: chart-example.png (51 KB, 718x428) Image search: [Google]
chart-example.png
51 KB, 718x428
>>52015049
>2015
>not having a qtpie widget
>>
>>52014970
Efficient verifiable mixnets; indistinguishable transport protocols (with IND-CCA2 security proofs); protocol masquerading for censorship evasion; efficient consensus protocols; Sybil-resilient distributed hash tables/Bloom filters.

Long road behind. Long road ahead.
>>
>>52014970
Combining generative unsupervised feature extraction SOTA with discriminative frameworks to improve the performance of pixelwise classification.
>>
>>52015082
>>52015089
Markov chains are related to graph theory
Nice contribution
>>
Wanted to try Ruby.
Had to make a Rest API for a project, so I though I could use Sinatra. Sinatra compatible with ActiveRecord 2.0, current version is 4.x, if you dont downgrade it doesn't work. Sinatra sucks, Ruby sucks. Will use Python. That shit works.
>>
For OCaml, is there a comprehensive comparison, including performance benchmarks, of the competing standard libraries (batteries and core)? Batteries has nice features like using the same operators for any kind of number, but is it as polished as core, and more importantly, is it as fast?
Also, if I understand correctly, the way battery's unified operators work, you have to specify the kind of numbers you operate on anyway, so you can't do
f :: 'a * 'a -> 'a
fun f x y = x + y
and need to change the 'a to Int or Float or somesuch. Is that true? Is there even a point in unified operators then?
>>
I thought about doing some webdev today.

The fuck is wrong with me?
>>
Finished the wrapper for aubio_sink_t. Any suggestions on how to decrease SLOC or improve readability? I try to keep the code style and naming convention similar to the aubio library.
package aubio

// #cgo LDFLAGS: -laubio
// #include <aubio/aubio.h>
import "C"

import (
"errors"
)

// aubio_sink_t
type Sink struct {
d *C.aubio_sink_t // Native ref.
}

// new_aubio_sink
func NewSink(uri string, samplerate uint) (*Sink, error) {
auri := as(uri)
defer fas(auri)

d := C.new_aubio_sink(
auri,
au(samplerate),
)
if d == nil {
return nil, errs("new_aubio_sink", "nil")
}

return &Sink{
d: d,
}, nil
}

// del_aubio_sink
func (s *Sink) Del() {
C.del_aubio_sink(s.d)
}

// aubio_sink_close
func (s *Sink) Close() error {
rval := gu(C.aubio_sink_close(s.d))
if rval != success {
return erru("aubio_sink_close, rval", rval)
}

return nil
}

// aubio_sink_do
func (s *Sink) Do(writeData *C.fvec_t, write uint) {
C.aubio_sink_do(s.d, writeData, au(write))
}

// aubio_sink_do_multi
func (s *Sink) DoMulti(writeData *C.fmat_t, write uint) {
C.aubio_sink_do_multi(s.d, writeData, au(write))
}

// aubio_sink_get_channels
func (s *Sink) GetChannels() uint {
return gu(C.aubio_sink_get_channels(s.d))
}

// aubio_sink_get_samplerate
func (s *Sink) GetSamplerate() uint {
return gu(C.aubio_sink_get_samplerate(s.d))
}

// aubio_sink_preset_channels
func (s *Sink) PresetChannels(channels uint) error {
rval := gu(C.aubio_sink_preset_channels(s.d, au(channels)))
if rval != success {
return erru("aubio_sink_preset_channels", rval)
}

return nil
}

// aubio_sink_preset_samplerate
func (s *Sink) PresetSamplerate(samplerate uint) error {
rval := gu(C.aubio_sink_preset_samplerate(s.d, au(samplerate)))
if rval != success {
return erru("aubio_sink_preset_samplerate", rval)
}

return nil
}
>>
I'm trying to learn OpenGL with Ada.
Am I retarded?
>>
>>52015289
No, don't believe in what they say. You are a special snowflake.
>>
>>52015314
I have a pathological fear of curly braces, so I can only use wirthian languages and python.
>>
>OCaml int32 values overflow and underflow
>int64 values error out instead of overflowing or underflowing
Literally what the fuck?
And how come there's no type promotion?
>>
Working on a multitouch gesture recognition framework based on linear classifiers that allows designing custom gesture sets with minimal overhead.
>>
>>52014970
Is there an infographic with books or .pdfs I can read on current C programming?
>>
>>52015742
What language are you using?
>>
>>52014970
Traveling Salesman: Fastest path? Why not ask all the customers to tell the other customers?

>bittorrent
>>
su priest -c 'touch children'
>>
>>52015799
Yes, it will come to you if you breathe in enough helium.
>>
>>52015827
html
>>
>>52014970
>What research problems are you working on /g/?
Well, I am currently building an automated theorem prover for first order logic with equality. I plan on using machine learning for optimizing some very important heuristic parts of it. Should be interesting.
>>
>>52015289
Do the Ada bindings support OpenGL 3+?
>>
>>52015270
>aubio
Why?
>>
>>52016283
It's less misogynistic with a reverse d.
>>
>>52016147
Read Symbolic Computing with Lisp.
>>
>>52016236
https://flyx.github.io/OpenGLAda/index.html
>>
>>52015838
This doesn't actually solve the problem by having it capable of splitting, it just speeds up the distribution.
>>
>>52016356
That book doesn't seem to have much to do with what I am working on. Could you enlighten me a bit on why do you think it is important?
>>
>>52015263
It's perfectly natural to want to express your feminine side from time to time, just don't let it take over your life.
>>
File: scumbagcat.webm (727 KB, 480x360) Image search: [Google]
scumbagcat.webm
727 KB, 480x360
Ask your beloved programming literate anything.

>>52015289
yes. i did some opengl stuffs with Ada, the typing is too painful.
>>
File: a mighty ruff victory.jpg (55 KB, 540x292) Image search: [Google]
a mighty ruff victory.jpg
55 KB, 540x292
>>52016509
Why haven't you offed yourself yet, faggot?
>>
File: space.webm (700 KB, 1280x719) Image search: [Google]
space.webm
700 KB, 1280x719
I'm working on a lil space game on C

It's pure gdi for now.

I have a question if anyone knows :

To control the frame rate I do this

timeBeginPeriod(1)
Sleep(ms to cap at 60fps)
timeEndPeriod(1)

It seems to be working fine but msdn says that timebeginperiod is a systemwide change so i dunno how i feel about that, but without it sleep doesn't have the precision i want, and it often sleeps for longer.
>>
>>52016677
>can't even maintain 60 FPS
Wow, just off yourself now.
>>
without the cap it goes around 200fps, it's the wonky sleep thing + the recorder that make it not stable
>>
>>52016695
He's probably running it on his ThinkPad T21
>>
>>52016727
Even a thinkpad should be able to maintain it.
>>
what's a good application for this

f.s
        global f
default rel
section .text
f:
movsd xmm0, [a]
mov rax, [b]

ret

section .data
a: dq 6.28
b: dd 42


main.c
#include <stdio.h>

int f(void);

int main(void)
{
printf("%.2f\n", ((double (*)(void))f)());
printf("%d\n", f());

return 0;
}


output:
$ nasm -felf64 f.s && gcc f.o main.c -o main && ./main
6.28
42
>>
>>52016763
Bricking your computer with no surviving data.
>>
>>52016740
Not if he is using the latest hip framework

>tfw all these kids who don't know what matrix multiplication is are making games
>>
Anyone C#/WPF here?

I'm trying to make a binding between a variable "currentVolume" and a slider on the UI. I have absolutely no idea how to implement this at all.

What I've got is essentially worthless so I won't even bother posting the code.
>>
>>52016805
>pure GDI
He is using the oldest cancerous framework.
>>
>>52016811
I should say that I have a "mediaPlayer" which has the property "volume".

Ideally I'd like to just bind it directly to mediaPlayer.Volume two-way and then set the user default at runtime.

But I have no idea how in the fuck I'm supposed to hook it up.
>>
>>52016862
currentvolume.volume = mediaplayer.volume on change?
>>
>>52016881
I guess that's the only real way to do it without trying to implement a direct binding.
>>
>>52016677
don't sleep, just render, use vsync for capping the frame rate
>>
>>52017094

thanks, that sounds like an option i'll have to look at when i move from gdi to opengl or directx, as i don't think you can do that in gdi? I guess i should move from it soon
>>
>>52015155
both are about equal but I tend to use Core because I get access to Core.Async which a lot of the libraries I use depend on. If I'm using LWT then I'll stick with Batteries Included.
If you want a good unified syntax for numbers, I highly recommend using the Modular Implicits branch, which you can get with OPAM. Run `opam switch 4.02.0+modular-implicits` (and switch back with `opam switch system`). It basically adds Haskell type classes to OCaml through the module system.
module type Num = sig
type t
val (+) : t -> t -> t
end
implicit module Int = struct
type t = int
let (+) = Pervasives.(+)
end
let (+) (implicit N : Num) = N.(+)

once you do that then you have (+) work for ints, but you can add the same for floats, etc. and for the other operators. you can also define other type classes like that too~
>>
>>52017165
That requires a fuckload of boilerplate to get going as opposed to batteries supposing it already has the boilerplate included as it seems to.
>>
>>52016509
But the typing is the whole point of using it.
>>
>>52017192
yeah, but once you've done it you don't need to write type annotations for all your functions. ocamllabs has a lot of the boilerplate code here https://github.com/ocamllabs/imp.
>>
My wife's son wants to learn programming. What should I start him off with? Scratch looks interesting, but it looks like it could teach him some bad programming habits.

Or should I just jump straight into C with him?
>>
File: led.png (2 MB, 1920x1080) Image search: [Google]
led.png
2 MB, 1920x1080
Made a relatively simple LED blinking simulation program, and decided to implement my own delay function.
>>
>>52017482
>avoiing bad programming habits
>C
Pick one.
>>
>>52017482
teach him Lisp because it's cool.
>>
I mean I've written some awful code in the past but this is shit I've found is just meme-tier

https://raw.githubusercontent.com/devincurry/RWET/master/Midterm/fivebyfive01.py


>>
>>52017536

what would be a bad programming habit that C would encourage
>>
>>52017482
also
>wife's son

pls keep cuckposting on /pol/
>>
>>52017548
JUST

>what is regex
>>
>>52017484
What window manager is that?
>>
Potential correlations between sentiment analysis of social media posts in a geographic region and violent/nonviolent crime rates
>>
>>52017600
what is the covariance of s m h and f a m with violent crime rate?
>>
>>52017587
dwm
>>
>>52017613
Hang on, let me run the (rudimentary) analysis on tweets containing nigga or some variation
>>
>>52017548
Average python "programmer"
>>
>>52017647
holy shit r = 1 you heard it here first, /g/. I habe scientifically proved without a shadow of a doubt that niggers cause crime
>>
>>52017484
I'm not to C++ programming.

What happens in your sleep function? Do you just delay the program by giving it stuff to do?

like increment 0 to 14001, 14001 times

Why didn't you use the time() function and base sleep() off of how much time has passed?
>>
>>52017482
I like this meme.
>>
>>52017482
teach him Scheme
>>
>>52017753
*I'm new to c++ programming

sorry 14000, but those are 14001 operations
>>
File: PAPER.png (26 KB, 1152x648) Image search: [Google]
PAPER.png
26 KB, 1152x648
>>52017731
>>52017647
>>52017613
here's my results, sorry it took so long. I'm running this on a thinkpad t21
>>
>>52017753
There are two for loops in my sleep function: one of them, has to wait for the other for loop to finish all its iterations. Essentially, that's what causes the delay. Why didn't I use functions from other libs? Well, no real need, this was a pretty simple implementation regardless. When I receive my orange pi, I'm gonna try porting this to the GPIO, and soder some actual LEDs to test this on.

Also, this is C, not C++ kek
>>
>>52007338
But that's wrong.

I'm not going to take English lessons from a country that thinks grouping things into hundreds rather than thousands is a good idea.
i.e. "fourteen hundred" and not "one thousand four-hundred".

The one time you could argue that dropping the "and" makes sense is if there are no hundreds e.g. only thousands and units
If you say "two thousand and two" the repeated "and" sounds fucking stupid. But still less stupid than "twenty hundred two".
>>
>>52017791
>>52017647
>>52017731
something tells me you didn't actually do it
>>
What's a good compiled low level language for personal projects?
Will mostly be doing graphics.

Preference: NO CURLY BRACES
>>
File: simplesm8.jpg (33 KB, 696x386) Image search: [Google]
simplesm8.jpg
33 KB, 696x386
dont have any graph theory, but this is a /dpt/ thread so

im working on a silly project in c++ to recap everything i have learned this semester. i like writing in c++ more than any other language so far, as its rural and i like pointers a lot.

its the bunny project
source: http://www.cplusplus.com/forum/beginner/92473/

I didnt read any of the man's code, in fact the problem is saved on a text file because i need to figure it out myself.

i want to make an array of male names that will remain in memory throughout the length of the program. these names come from a text file.

the static keyword in c++ does exactly that, when the program begins running, the static variable exists in memory until the program completes. cool.

but if i instantiate a bunny, with a static array as a private member of the bunny class, will each bunny have its own array in memory?

am i retarded?
>yes
>of course
>>
>>52017840
Ada
OCaml
>>
>>52017791
WHAT THE FUCK IS THAT FONT RENDERING FUCK
>>
>>52017484
>Opening { on their own line
>For loops with no brackets
>sleep.h includes sleep.h
Absolutely disgusting
>>
>>52017433
Hasn't been touched in a year, tests are embedded in the num module definitions, probably can't do float + int over num (can it?), requires a special branch of the compiler.

Also, is there any way to fix the overflow bullshit? Either always error out when overflowing, or promote types automatically, but I don't want to get both overflow and error depending on which type length I'm working with.
Also I like how 4611686018427387904 is cast to an int32 even though it can't fit, yielding -4611686018427387904. Is there even unsignedness available?
>>
>>52017791
rusemasterLevel=MAX
>>
pic is semi-related, and i posted it because thats where i am currently researching
>streamsize
>c_strings

this is my first time posting in this type of thread
>>
File: cmc.png (187 KB, 639x1278) Image search: [Google]
cmc.png
187 KB, 639x1278
>2016
>despite decades of research, still no high-level language exists that outperforms C in the general case
Jesus christ.
>>
>>52017844
>but if i instantiate a bunny, with a static array as a private member of the bunny class, will each bunny have its own array in memory?

Of course not. C++ doesn't have TLS by default so the array will be "shared".
>>
>>52017840
OCaml.
>>
>>52017874
I use a kernel coding style, with a few tweaks of my own. The for loop doesn't need curly braces there. Also, that's sleep.c, not sleep.h
>>
>>52017894
word thanks.

what is TLS?
>>
>>52017874
>>sleep.h includes sleep.h
Fuck me I was looking at the window filename above and not the one below.

Still, the inconsistent formatting has me 110% triggered.
>>
>>52017482
java or C++
>>
>>52017874
>Opening { on their own line
This should be punishable by death, always.
>For loops with no brackets
This is fucking awful. Not only can it lead to hard to find bugs (see: goto fail), it also means that as soon as you're going to change the content of the for expression to have more than one term, you'll need to add brackets, reducing maintainability by increasing workload needed (this is of course applicable only if the same code-style is applied throughout the code).
>sleep.h includes sleep.h
Truly the mark of a retard.
I suggest nobody ever replies to >>52017484 ever again.
>>
>>52017915
Thread local storage.
https://en.wikipedia.org/wiki/Thread-local_storage
>>
>>52017892
There are many actually.
>>
>>52017915
>>52017942
Also keep in mind that I'm retarded because it doesn't matter here at all, I confused it initially with something else but I figured I'd link anyway since you asked what TLS is.
>>
File: lrg.jpg (108 KB, 500x656) Image search: [Google]
lrg.jpg
108 KB, 500x656
Is this the best JavaScript book, /g/?
>>
>>52017911
>else and if on separate lines
>no linebreak before else statements

I could keep going
>>
>>52017956

I saw some discussion about threading when I searched this on stack overflow but didn't quite understand it. Thanks for the link.
>>
>>52017874
>>52017923
>>52017931
>>52017982
I suggest you read this before you shitpost:
https://www.kernel.org/doc/Documentation/CodingStyle
>>
>>52018019
Sorry that you're pantsu on head in ass on pants retarded, m8.
>>
>>52017931
>>sleep.h includes sleep.h
Yeah no that was me not reading the filenames correctly: >>52017923

The funny thing is, I do like putting the opening { for a class declaration on a new line in Java etc. but then the class declaration looks a lot different to a method.

For some reason having C functions with { on a new line just looks weird, even though it makes sense really.
>>
>>52018019
So you're proud of not respecting the kernel styleguide? I don't get it.
>>
>>52017844
> but if i instantiate a bunny, with a static array as a private member of the bunny class, will each bunny have its own array in memory?
No. Within a class definition, "static" means that the variable is part of the class (effectively a global variable, but within the class' namespace), not part of each instance.
>>
>>52018019
Where does it say in the kerneldoc to use:

else
if (led == OFF)


I understand the argument for not using braces for single line conditionals, but there is no harm in doing so and it actually makes things more consistent.
As long as the opening { is next to the conditional and not also on it's own line, because then it's just stupid.
>>
>>52018133
>I use a kernel coding style, with a few tweaks of my own.
Whatever man, I'm just using whatever's easier for me to read. Using braces when there's no need for them just makes the code more verbose.
>>
File: sponge.jpg (79 KB, 480x478) Image search: [Google]
sponge.jpg
79 KB, 480x478
can someone explain why atoi() atof() etc functions in C all use 'a' in the function name? does it stand for anything?
>>
>>52018170
Just means a string, I think they used a because it's an array of chars
>>
>>52018170
The "a" stands for ascii
it's "ascii to int"
>>
>>52018160
>Putting braces in makes the code more verbose
>Putting else statements, separate from the if, on newlines doesn't

You are in no fit state to make "tweaks" to the kernel style, especially if the things you are going to change make no goddamn sense.
>>
>>52018192
That actually makes more sense, ignore:>>52018187
>>
>>52014998
unappreciated post
>>
File: kirby.jpg (182 KB, 500x267) Image search: [Google]
kirby.jpg
182 KB, 500x267
>>52018192
much thank
>>
>>52018170

http://stackoverflow.com/questions/2909768/where-did-the-name-atoi-come-from
>>
>>52018233
i cant even name my functions well
>>
>>52014998
This see
>>52018170
>>
>>52018302
I have a great way to fuck with java maintainers.

Have a method called getData() or whatever.

Except it returns a status int, and the data is actually some global variables in the parent class that are now available to use if the status int was 0.

Why make structs when I can just abuse global namespace instead?
>>
Just smoked some hash, about an [8] right now. What should I program while high?
>>
>>52018441
The solution to how to kill yourself the fastest without bothering anyone else.
>>
File: imgur-2015_12_23-22:36:47.png (87 KB, 214x258) Image search: [Google]
imgur-2015_12_23-22:36:47.png
87 KB, 214x258
>>52018451
>>
File: 1449902877554.png (1 MB, 2560x1440) Image search: [Google]
1449902877554.png
1 MB, 2560x1440
I was told to make this output 1 in place for true and 0 in place for false.

// Goal is to replace true and false with 1 and 0
public class JPRACT {

public static void main(String[] args) {
boolean p, q;

System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");

p = true; q = true;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));

p = true; q = false;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));

p = false; q = true;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));

p = false; q = false;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (!p));
}
}


I'm trying to figure this out on my own, just started learning, but came here for a hint. Peeked back into the chapter I read, and something tells me I'll be casting incompatible types?
>(target type) expression
or something?
>>
I am working on an Android app and I'm using the TextToSpeech class. After initializing an instance of that I use the getVoice() method to get the current (default) voice but it returns null. However, I can use the instance just fine and turn text into speech. Does this make any sense at all?
>>
>>52018170
It stands for 'anscii to integer'.

Also, the 'f' in printf() is for 'print formatted'.
>>
>>52018482
yo jamal this test hard you got the anscii
>>
>>52018477
This is something that should be obvious to you if you just ran the program.
>>
>>52018441
Hash tables senpai.
>>
>>52018441
>tfw weed will never be legal in my country in my lifetime
>>
>>52018477
look through the operators java has at your disposal
>>
>>52018525
yeah, not in mine either
/home/ed/Pictures/imgur-2015_11_04-22:53:18.png
>>
>>52018556
or actually you can just change the types of p and q
>>
>>52014970
I'm trying to give my circle drawing algorithm the equivalent of 256x MSAA
But I only want to check 2-3 points for it instead of 256
>>
File: 084.png (102 KB, 300x256) Image search: [Google]
084.png
102 KB, 300x256
>>52018583
>I'm trying to give my circle drawing algorithm the equivalent of 256x MSAA
>But I only want to check 2-3 points for it instead of 256
>>
>>52018570
Hi Ed!
>>
File: 1449232147147.jpg (408 KB, 1920x1080) Image search: [Google]
1449232147147.jpg
408 KB, 1920x1080
>>52018514
>>52018556
Got it, thanks anons.

>>52018572
But what about
(!p))


Sorry if I'm a bit slow here guys, have to practice critical thinking more often.

Also, I cheated:
public class JPRACT {

public static void main(String[] args) {
byte p, q;


System.out.println("P\tQ\tAND\tOR\tXOR\tNOT");

p = 1; q = 1;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (0));

p = 1; q = 0;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (0));

p = 0; q = 1;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (1));

p = 0; q = 0;
System.out.print(p + "\t" + q +"\t");
System.out.print((p&q) + "\t" + (p|q) + "\t");
System.out.println((p^q) + "\t" + (1));
}
}
>>
>>52018583
Good luck with that.
>>
>>52018634
for (!p) you can use (p^1) or (~p&1)

!p like C/C++ allows for integers as well as booleans would be convenient for this but java's strong typing is a good thing
>>
>>52017892
Two words: development time.

People hours are generally more expensive than tiny bits of improvement.

Obviously, any time where performance is determined to be significantly impacted by a project architect, then a lower-level language will be used.

I made something over the last 2 days that I guarantee couldn't be done reasonable in a week in C, if it's even possible.
>>
>>52018668
>!p like C/C++ allows for integers
actually !p would implicitly convert to bool which can then get implicitly converted back to integer
>>
>>52018607
>>52018642
It is possible with circles and I already know how to do it manually
Only making it work for every weird intersection is a bit over my head
>>
For every new there must be at least one delete, right? Does that mean if I write new in a function's parameters, I need to write delete somewhere?
>>
>>52018634
also with the booleans you can do ((p & q) ? 1 : 0)

it's called the ternary operator
>>
>>52018770
Depends. But usually, yes. It's best to get in the habit.
>>
gimme a FUCKIN project /dpt/
>>
>>52018770
It's poor form to have a function manage the lifetime of its parameters unless you're using smart pointers, which make it explicit. So you should be doing this:
[/code]
// BAD
foo(new Bar());

// GOOD
Bar *bar = new Bar();
foo(bar);
delete bar;

// BETTER
Bar bar;
foo(&bar);
[/code]
>>
What's to prevent me from fucking up with C scanf parameters?

Is there a secure version of the function?
>>
>>52018748
if you have a plain solid background or you're doing alpha blending or someshit then sure but it'll take more math than just sampling 2-3 points
>>
>>52018809
Write them correctly the first time.
Any item you don't want to ignore must be preceded with %
>>
>>52018802

What about killing yourself fucboi?
>>
>>52018806
Oops.
// BAD
foo(new Bar());

// GOOD
Bar *bar = new Bar();
foo(bar);
delete bar;

// BETTER
Bar bar;
foo(&bar);
>>
In Scala, why can you do
val foo = List(1, 2, 3)

but with your own classes you have to put a new keyword like
val foo = new MyClass(1, 2, 3)
>>
>>52018861
because fags
>>
>>52014970
Use google maps

(jk)
>>
>>52018829
I'm of course talking about 2-3 points per pixel, not in total
>>
Why don't you fags have jobs yet
>>
>>52018954
all the jobs listings want 3+ years experience and a college degree
>>
>>52018933
i'm also talking 2-3 points per pixel
>>
I wanna make something rad over the winter break what should I do?
>>
>>52018954
i'm going for self-employment, not interested in having a normal job
>>
>>52018976
What's stopping you fag. I already have an offer and I'm graduating with a 2.9
>>
>>52019013
>I'm graduating with a 2.9

Sorry about your head injury, lad.
>>
Hey /g/uys!
I finally learnd how to program. I chose to program in Python because it has a bad ass name and was easy to learn.
I made this program which returns the word "guitar" in alphabetical order.
Pretty cool, huh?
def start():
question()
def reverser(n):
if n=="guitar":
print("agirtu")
else:
print("wrong input :-DDDD")
question()
def question():
n = input("Please type \"guitar\"\n")
reverser(n)
start()
>>
>>52018983
Just google "Xiaolin Wu's circle algorithm"
I'm using a very similar approach that is +-1% to the original 256x MSAA result
>>
>>52019022
It's alright my job has full coverage and they're paying me six figures.
>>
>>52019013

>I already have an offer

From?
>>
>>52019178
McDonald's
>>
File: 1450246461790.jpg (188 KB, 600x1067) Image search: [Google]
1450246461790.jpg
188 KB, 600x1067
somebody post the updated programming challanges
>>
>>52019090
interdasting
>>
>>52019178
An Internet coupon company
>>
File: 1448962932992.png (378 KB, 1450x1080) Image search: [Google]
1448962932992.png
378 KB, 1450x1080
>>52019210
>>
#!/usr/bin/env python
import os, sys

stock = "tsla.csv"

with open ("csvOut.csv", "w+") as csvOut, open(stock, "r+") as csvIn:
for line in csvIn:
csvOut.write(line)
csvOut.seek(0,0)



I want to print each line in tsla.csv in reverse order and save that into another file. But this ends up writing only the very last line. Help?
>>
>>52019235
so your a web dev
>>
>>52014998
Kinda wanna agree.
>>
File: 1439416122849.jpg (351 KB, 1280x720) Image search: [Google]
1439416122849.jpg
351 KB, 1280x720
512 byte blocks or 4K byte blocks for disks?
I'm writing a VM so it's programming related.
>>
>>52019284
all modern hdd/ssd are 4k internally
>>
>>52019244
import os, sys

res = []
for line in open('tsla.csv'):
res.append(line)

res = res[::-1]
with open('tsla_out.csv', 'w+') as f:
for entry in res:
f.write(entry)
>>
>>52018833
no a programming project sillly
>>
"SpngList" throws a null reference exception. How do I call the SongList so it's actually fuckin' accessible?

    public partial class MusickLibrary
{
public MusickLibrary()
{
InitializeComponent();
this.DataContext = this;
}

public ObservableCollection<Song> SongList;

private void btnBrowse_Click(object sender, RoutedEventArgs e)
{
FolderBrowserDialog selectFolder = new FolderBrowserDialog();
DialogResult result = selectFolder.ShowDialog();

if(result.ToString() == "OK")
{
foreach (var file in Directory.GetFiles(selectFolder.SelectedPath))
{
if(file.Contains(".mp3"))
{
var tempFile = TagLib.File.Create(file);
SongList.Add(new Song(file.ToString(), tempFile.Tag.Title, tempFile.Tag.FirstPerformer, tempFile.Tag.Album, tempFile.Tag.FirstGenre, tempFile.Tag.Year.ToString()));
}
}
}
}
>>
>>52019090
but it seems to only be for solid backgrounds like i said? otherwise it surely won't give the same result as 256x MSAA since the circle segment can obscure different-colored sub-pixel elements of the background
>>
>>52019085
Now make it sort any word in alphabetical order. Challenge yourself.
>>
>>52019315
Is there a benefit for being 4k instead of 512?
The block address is 32bit which allows me to address up to 2TB, so addressable space isn't a problem. Performance?
>>
>>52019366
>Performance?
Yes
>>
>>52019327
can it be done without using an array as a buffer?
>>
>>52019379
How?
Remember, this is just a hobby VM, what kind of performance gains are we talking here?
>>
>>52019244
open('csv_out.csv', 'w').writelines([reverse(open('csv_in.csv', 'r').readlines())])
>>
>>52019403
Less I/O operations to read the same amount of data.
>>
>>52019410
oops i thought reverse was built in for some reason

open('csv_out.csv', 'w').writelines(open('csv_in.csv', 'r').readlines()[::-1])
>>
>>52017796
Have you ever heard of the term "busy waiting"?
>>
>>52019344
public ObservableCollection<Song> SongList = new ObservableCollection<Song>();


Well done me.
>>
>>52014970
I am not the smartest guy so I would just calculate all available paths and then see which one is shortest/fastest (if I had the computer)

If mathematical solution is required then it would take me while.


I am currently trying to program very simple AI.
>>
>>52019497
that is pretty much the only way to do it correctly, but even with DP optimization it's still O(n^2 * 2^n), which is ridiculous.

One fun thing to do is write a genetic algorithm to solve it. It will find a pretty good solution in much less time.
>>
>>52019497
That would take a prohibitive amount of time as the number of nodes increases. Look up NP completeness if these types of problems interest you.
>>
>>52019351
There seems to be an misunderstanding
I'm drawing circles to a raw pixel buffer, no 3d rendering
The background color doesn't matter because I can simply read each pixel and blend it accordingly
Result is exactly the same as hardware MSAA
>>
>>52019403
data locality
data within a single block is guaranteed to be coherent, while it cannot be assured that multiple blocks are not fragmented
obviously, when things are fragmented, more effort is required to look things up, especially with FSes that have local inode tables instead of a global inode table
the downside is that most fses have a constant block size (rightfully so), with only one file per block (also a decision that gains you other advantages), so with a larger block size, even smaller files take up the size of the block size
>>
>>52019403
Assume a disk where the minimum addressable amount of data is 512 bytes (a sector).

If your file system's block size is 512 bytes, and you have a 4Kb file, then to read it all in sequence you'll possibly have to issue 8 reads to the disk (if they happen to be strewn across the disk). If your file system's block size is 4Kb, then you're more likely to have those blocks all nice and sequential, needing only 1 read to get them all into memory. But if the block size is too big, you're wasting lots of memory ("lots") every time your file is small.

The right block size depends on the hardware, the size/amount of files you intend to have on your file system and the size of your frames and pages.

Some of this might not be correct since it's been a while since I studied this.
>>
stfu
>>
going to develop a web application using a MEAN stack
>>
Really interesting article for the people who like compilers:
http://joeduffyblog.com/2015/12/19/safe-native-code/
>>
>>52019634
Not programming related, go back to /wdg/.
>>
>Trying to make media player because I'm a novice
>Testing stuff out in my library
>Works fine
>Want to see what happens if one of the tags isn't set
>All of my music is too well organised and they have all been tagged perfectly

Fucking hell.

Who /OCD/ here? How do you deal with testing broken things?
>>
>>52019730
Start by being a good tester. That requires an overwhelming sense of pessimism.
>>
>>52019729
>not programming related

what is javascript?
>>
>>52019794
>what is javascript?
Not programming.
>>
>>52019803
It is though, as much as you hate to hear it.
>>
>>52019820
Even if we agree that it is you're still in the wrong general.
>>
>>52017840
>NO CURLY BRACES

C U

C K
>>
Hey guys, I'm a fucking noob and don't know what the fuck I'm doing. Can some of you Code-Magicians help me out? I know some HTML, but no chance with JS.

So I want various divs to be visible only when Javascript is enabled. So I threw them all in one class, set them to display:none in the stylesheet, and tried this to change the visibility if Javascript is on:
>>
>>52019873
>PLEASE ENABLE JS TO VIEW THIS PAGE
fuck off
>>
>>52019803
>Javascript is not programming
how so?
>>
>>52019896
scripting is not programming
>>
>>52019873
write a script that sets them all to visible, and run this when the page loads.
>>
>>52019882
That's not it, I swear man. I code the whole page to work without JS, that's why I need to hide stuff if JS is off so it doesn't break/404.

Looks like the system thinks my code is spam lol.
What am I doing wrong /g/?
>>
>>52016283
Bit late to the party.
Why not aubio? If you have a better library for onset tracking please share.
>>
>>52019904
oh sorry.


what is programming then?
>>
>>52019904
wrong
>>
Who else here /46starclub/ in adventofcode?

Finally got the right solution for day 22 and with some smart optimizations, my running time went from 30+seconds to less than 1 second
>>
>>52019915
>write a script that sets them all to visible, and run this when the page loads.

Thanks, that's exactly what I want to do - I got that far. But as I said, I don't know how to code that, could you maybe give me a line that works?
>>
>>52019936
Endlessly debugging a meme language until you find out the STL is broken.
>>
>>52019941
sorry
non-compiled languages is not programming
>>
>>52019950
>>>/wdg/
or >>>/suicide/
>>
>>52019954
>Ruby: Not programming
>Crystal: Programming

nice meme


>>52019950
idk javascript m8. You know logically what you want to do. Get every item with that class id, and change their display property.
>>
>>52019987
writing scripting code for an interpreter is not programming
>>
These lecture notes are pretty based desu

http://jeffe.cs.illinois.edu/teaching/algorithms/everything.pdf

This is the best intro to CS text

http://i.stanford.edu/~ullman/focs.html

SICP is pretty decent too

https://mitpress.mit.edu/sicp/full-text/book/book.html

CLRS is the best intro to algorithms text but I do not condone piracy so I won't link to that
>>
>>52019987
>meme
>not meme
>fact
>meme
Nice maymay.
>>
>>52019998
but writing the exact same code, and then compiling it, and then running it is programming?
>>
>>52020013
Yes.
>>
>>52017482
>>52017542

Along these lines, you can use Racket and the book Realm of Racket
>>
>>52020027
nice meme

what if I write an interpreter that compiles the code, runs it, and then deletes the executable.

still programming?
>>
>everything's a meme
>>
>>52020056
The executable can be copied and run multiple times after, before it is deleted; thus yes. If there was magic protection against that such that one would have to compile everytime before running, then no.
>>
How do I code a virus /g/?
>>
>>52020147
HTML
>>
>>52020147
write a self-replicating worm first
>>
>>52018809
Fuck scanf, just do fgets and then sscanf it. There is a safer function scanf_s in C11. Also make sure you check the return, people never do that shit and it's VERY important.
>>
>>52020056
Stop feeding the trolls/retards.
>>
>>52019987
>idk javascript m8. You know logically what you want to do. Get every item with that class id, and change their display property.

K, thanks anyway. Does anybody else have any ideas?
This is my last attempt to /r/, won't bother you guys with my incompetence any longer now.
>>
Post top tier music from top tier tech shows

https://www.youtube.com/watch?v=Ksgw79s5vE0
>>
>>52020271
fuck off retard

I told you what to do. eloquentjavascript.net if you don't know javascript
>>
>>52020183
Ok. How do I share it? If I put the .EXE on 4chan will you download it senpai?
>>
>>52019928
Please anon, I hope you're still there.
What's wrong with aubio? If there's a better alternative, please post so I can stop porting aubio.
>>
>>52020340
no
make a popular multiplayer indie game and use it to deliver the worm payload to a few initial players, then remove the payload from the source and let infected players spread the infection over mp
>>
the fuck is wrong with 4chan's servers? fix this shit you cunts
>>
>>52020340
Go steal of a video of someone using CS:GO hacks.
Put it on youtube saying that it's a video demoing your CS:GO hacking program.
Distribute your virus to idiots.
>>
I want to use .json for my settings in WPF/C#.

How in the fuck do I even begin? I can't even work out how to create a JSON file, let alone get to work on one.

Any ideas?
>>
>>52020345
I did some research before deciding to go with aubio. Audacity uses aubio indirectly by using the vamp sdk. If you look at piem.org (website of the developer), he's not your average neckbeard. Beside using the Go bindings myself, I hope it'll benefit others too. There're not many libraries available for Go not related to networking.
>>
>>52020473
use a library
google.com 'C# json'
>>
>>52020473
I'm sure dozens of Cshart JSON libraries exist.
>>
>tfw ddosing 4chan
>>
File: reported.png (131 KB, 1920x1024) Image search: [Google]
reported.png
131 KB, 1920x1024
>>52020508
>>
>>52020483
>There're not many libraries available for Go not related to networking.
That's because Go has nothing going for it outside of networking and it doesn't even excel at that. Go was a mistake.
>>
>>52020591
Every language falls into the category 'should do x well, but fails at the rest' by the perspective of a hater.
>>
>>52020591
This. At least it distracted a bunch of shitty gullible programmers away from good languages. Less odds of me having to work with them some day.

...

Maybe that was the whole point of Go?
>>
>>52020473
install JSON.NET from nuget. It's the single most popular package afair.
>>
>>52020591
>>52020652
OK, please enlighten me with the holy grail of programming language.
>>
>>52020685
haskell
Thread replies: 255
Thread images: 30

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

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.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.