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

/dpt/ - Daily Programming Thread

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 340
Thread images: 34

File: 1473996249702.png (389KB, 934x1000px) Image search: [Google]
1473996249702.png
389KB, 934x1000px
Previous Thread; >>56658381

What are you working on, /g/?
>>
>>56665168
at the beach and also on dpt
>>
haskell is bad and you should FEEL bad!
>>
We will witness >>56666666 soon
>>
>tfw using WinAPI for a personal project

I always forget how terrible this is.
Why does every function need 20 parameters, and why are there so many typedefs?
>>
>>56665248
Well how else is one supposed to pass a long pointer?
>>
>>56665168
anime is the best...
>>
File: ebenis.gif (479KB, 618x444px) Image search: [Google]
ebenis.gif
479KB, 618x444px
Procrastinating with BGI.
>>
>>56665168
>not using ARM logo for thread
I'm disappointed in you, new OP.
>>
Dynamic typing is shit
>>
>What are you working on, /g/?

Still doing this: GPUDirect RDMA benchmarking utility for InfiniBand and some proprietary PCIe-based interconnect.

And not making pancakes, as the other anon thought.
>>
Working on my blogging platform but i am not inspired at all because Im not going to blog.
>>
>>56665406
Start small, start tweeting.
>>
>>56665406
Monetize it and get other people to start blogging
>>
>>56665168
at least post cute traps in the op
>>
sharing dick pics with cute bubble butt bi boys on kik
>>
I'm on-call for about another 6 more hours.
>>
Is there a good resource for learning more about machine learning?

Is the Stanford Mooc on coursera good?
>>
>>56665716
wrong thread bucko
>>
hi do u lik my reverse
void
reverse(char *s)
{
size_t p = strlen(s);
char c;

while (p > strlen(s)>>1) {
char c = s[strlen(s) - p];
s[strlen(s) - p] = s[p];
s[p] = c;
--p;
}
}

size_t
strlen(const char *s)
{
size_t i = 0;
while (s[++i]);
return i - 1;
}
>>
>>56665893
>implementing your own strlen
why?
>>
>>56665948
I wanted 1 less than the standard strlen returns
?
obviously
?
>>
>>56665975
.........................
>>
>>56665861
how's your aspergers going?
>>
>>56665975
strlen(s)-1
??????
>>
>>56666033
fuck off with java code retard
>>
>>56666044
Fuck off with you're cursing. /g/ is a Christian board
>>
File: really.png (108KB, 400x381px) Image search: [Google]
really.png
108KB, 400x381px
>>56666044
>cussing
>>
>>56665893
strlen("");
>>
>>56666081
>>56666065
sorry mom
>>
>>56666083
0
>>
>>56666044
Why is it that potty-mouths almost never get their grammar right?
>>
>>56665893
mein Gott, c is so fucking ugly.
>>
>>56666135
>""[1]
>>
>>56665893
Nice variable names bruh.
>>
Im rewriting my toy c++ game engine, so reading lua config file for window settings fps etc, get window and rendering flags. I cast them to bool (sdl takes uint32 xD) and lo and behold it changes my screen resolution and had to kill it manually xD took me a while to catch it..
Funny thing is it works in original version.
>>
>>56666238
>abstractCharacterArrayFactory
>>
>>56666241
>xD
>unironically
>>
>>56666024
first of all i dont have aspergers i just have autism
>>
>>56666264
sorry lol :P
>>
>>56666264
It's okay, we respect everyone in our autism aware community :-)
>>
>>56665893
What trivial functions do I implement with single letter variable names next?
Also, jokes aside, I implemented strlen for fun.
I'm trying to reverse any pajeet-effects caused by extensive exposure to high level languages.
>>
Perl or python for a scripting language, and why?
>>
>>56666603
Python, more people use it
>>
>>56666603
perl if you want to be a cool hacker
>>
>>56665168
Get for D
>>
>>56666603
Ruby, because it's simply less retarded.
>>
>>56666666
>>
>>56665168
Best way to learn ocaml? Anyone know any good books?
>>
>>56666195
I find c not exactly beautiful but quite pleasing to the eye.
>>
>>56666763
http://http://caml.inria.fr/distrib/books/llc.pdf
>>
v0.0.2
void
reverse(char *s)
{
size_t p = strlen(s) - 1;
size_t q = p;
char c;

while (p > q / 2) {
char c = s[q - p];
s[q - p] = s[p];
s[p] = c;
--p;
}
}

>>56666555
pls respond
>>
>>56666797
>http://http://caml.inria.fr/distrib/books/llc.pdf
english please
>>
I made an Electron app that scrapes Putlocker for mp4 streams and lets you play, download, or get a link to them.
>>
>>56666861
You don't like VO?
>>
Looking over dead projects to revive them, including my own MVC framework, made to get a better understanding of how MVC works.

<?php

class Appstrap {

function __construct() {

Session::init();

$url = $this->getUrl();

//print_r($url);

if (empty($url[0]) || $url[0] === 'index.php') {
require _CONTROLLERS_ . 'index.php';
$controller = new Index();
$controller->Index();
return false;
}

$file = _CONTROLLERS_ . $url[0] . '.php';

if (file_exists($file)) {
require $file;
} else {
$this->error();
die();
}

$controller = new $url[0];
$controller->loadModel($url[0]);

$this->methodCalling($controller, $url);
}

function error() {
require _CONTROLLERS_ . 'error.php';
$controller = new Error();
$controller->Index();
return false;
}

function getUrl() {
$url = isset($_GET['url']) ? $_GET['url'] : NULL;
$url = rtrim($url, '/');
$url = explode('/', $url);
return $url;
}

function methodCalling($controller, $url) {
if (isset($url[2])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}($url[2]);
} else {
$this->error();
}
} else {
if (isset($url[1])) {
if (method_exists($controller, $url[1])) {
$controller->{$url[1]}();
} else {
$this->error();
}
} else {
$controller->Index();
}
}
}

}



Also need to change the error class name as PHP 7 now has its own error class...
>>
>>56666666
>>
>go to /dpt/
>nothing but unused meme languages, toy code for school assignments, and retarded NEETs with no actual contact with the industry
Anyone knows some place where actual programmers discuss things? /r/java is an example of a good place, but I need more.
>>
Can someone please give me a project idea that isn't a meme.
>>
>>56667051
What are your interests?
>>
>>56667051
a meme hosting site with facebook integration
>>
File: suns.png (2MB, 1920x1080px) Image search: [Google]
suns.png
2MB, 1920x1080px
from PIL import Image
import math
import random
from functools import partial

R, G, B, A = 0, 1, 2, 3
img_width = 1920
img_height = 1080
img = Image.new('RGB', (img_width, img_height))
img.convert('RGB')
half_width = img_width / 2
half_height = img_height / 2

def dist(vec1, vec2):
return math.sqrt((vec2[0]-vec1[0])**2 + (vec2[1]-vec1[1])**2)

def perpix_img_transform(img, transform_fn):
img_copy = img.copy()
for i in range(0, img.size[0]):
for j in range(0, img.size[1]):
pix = img.getpixel((i, j))
output = (transform_fn(pix[R], i, j, R), transform_fn(pix[G], i, j, G), transform_fn(pix[B], i, j, B))
img_copy.putpixel((i, j), output)
return img_copy

def sunset(i, x, y, RGB, orb_sz=1, point=(img_width/2, img_height), grad_rgb=(5, 1, 0.5), ray_period=80, use_noise=False):
if use_noise:
noise = 5*random.random()
else:
noise = 1

from_point = max(dist((x, y), point), 1.0)
inv_from_point = min(orb_sz * (half_height / from_point), 1)

theta = math.acos((point[0]-x) / from_point)

#sun
i += grad_rgb[RGB] * inv_from_point * 10
i += inv_from_point * math.sin(theta*ray_period + noise) * 5

return int(i)


for i in range(10):
orb_sz = random.random()
point = (random.randrange(1, img_width), random.randrange(1, img_height))
grad_rgb = (5*random.random(), 5*random.random(), 5*random.random())
ray_period = random.random()*80
img = perpix_img_transform(img, partial(sunset, orb_sz=orb_sz, point=point, grad_rgb=grad_rgb, ray_period=ray_period, use_noise=True))

img.show()
>>
File: 1472398597226.jpg (22KB, 261x323px) Image search: [Google]
1472398597226.jpg
22KB, 261x323px
>>56665893
When I lol I lol real hard...
>>
File: 1474054311810.jpg (26KB, 400x462px) Image search: [Google]
1474054311810.jpg
26KB, 400x462px
>>56666147
Perhaps it is a direct result of the vigorous onanism that they use as a substitute for fisting?
>>
why is it so difficult for me to make a fucking TODO list to start a new project?
it sometimes takes me YEARS to even start taking stuff I want to do seriously.
should I be more organized? what should I read to stop procrastinating and being so lazy
>>
>>56666259
Implying there's nothing between f and abstractCharacterArrayFactory
>>
>>56667199
Gow a pair and start doing things.
>>
File: blown-power-supply-caps-3.jpg (106KB, 875x605px) Image search: [Google]
blown-power-supply-caps-3.jpg
106KB, 875x605px
>>56665168
An AI that ASKS QUESTIONS....

Only S.I.M.I.A.N. but it will suffice.
It depends how correlated to the task the inputs are and how dense the neurons... but it seems to be presenting quite well at the moment.

We're promised more training sets by tomorrow.

Have fun...
>>
Just settled down to read K&R to brush up on my C.

Is there plenty of examples and tasks to practice what I learn in the book, or is there a supplement list of things that I can make sure I can achieve before considering myself finished?
>>
Programming noob here: if I wanted to search for the frequency of an integer inside of an ArrayList, would the time complexity of the algorithm be affected by sorting the list? The book I'm reading compares sorting and searching to looking inside of a phonebook, and searching a phonebook is easier because its sorted. But wouldn't a frequency search still require each element of the arraylist to be visited? Shouldn't the time complexity be roughly the same?
>>
File: 1439071205894.png (383KB, 1425x1080px) Image search: [Google]
1439071205894.png
383KB, 1425x1080px
>>56667051
>>
>>56667651
every number is the same, now tell me whats the big o for that
>>
>>56667199
>a journey of a thousand miles begins with a single step
>>
>>56667684
I assume green means easy, yellow is medium and red is hard?
>>
>>56667695
Constant? It knows that every value is the same, thus it does one operation? But if every number is the same, then sorting is useless since the frequency counter does the same thing. Bear in mind, I only just started studying time complexity, so I'm not very good at it yet.
>>
>>56665893

1. Don't call an O(n) function in a loop if its value is not expected to change, or if it is expected to change in a predictable way.

2. Don't implement your own strlen function, and if you do, don't call it strlen, or give it static linking. You may just cause linking conflicts with the C standard library.
>>
>>56667199
Take some drugs. Uppers, preferably. It's what all of the successful people do.
>>
>>56667651
array = [0,2,4,6,8,10,12,14,16,18,20]

For loop to find 12 would take 7 iterations.

array = [20,6,12,16,18,0,4,14,2,8,14]

For loop for finding 12 would take 3 iterations.

So in this scenario, the unsorted array would be quicker when left unsorted, however to sort and then find the int would take a lot more iterations to complete.

What do?
>>
>>56667780
learn2algorithms
>>
File: 1466822419865.png (5KB, 210x261px) Image search: [Google]
1466822419865.png
5KB, 210x261px
A-Am I a programmer now?
>>
>>56667651

> if I wanted to search for the frequency of an integer inside of an ArrayList, would the time complexity of the algorithm be affected by sorting the list?

No. Although one would be able to stop searching as soon as one encounters a number larger than that particular integer, the fact of the matter is, one could end up searching as much as the entire list without being able to make further assumptions. It's O(n) regardless.
>>
>>56667736
yea
>>
>>56667845
Yes, now you don't have to learn anything else
>>
>>56667866
Alright, thank you senpai.
>>
>>56667845
No. Do the same in C with zero bugs and you'll be a coder.
>>
>>56667758
>>56667651

how would it know thats the same number or anything thats inside of it without going through it once.
or take this other example, every value is different but the value its at the very end of the array in the worst case.
>>
>>56666793
well said
>>
>>56667083
slow as fuck.

good job though
>>
>>56667780
I'm the guy who asked the question first: there are many searching algorithms that take advantage of sorted arrays and know how to search a particular value without visiting all the values. As an example, the binary search uses a sorted array and starts near the middle of the array and sees weather the value is larger or smaller than the searched value. In your scenario, it starts by checking 10 (the middle of the array), then the largest value nearest 10, which is 12. Thus it checks 2 values, as opposed to checking the 3 values in your unsorted array.
>>
>>56667893
So in other words, no matter what happens, every element has to be checked once, thus we get O(n) no matter what.
>>
>>56667684
Is there a suggested language?

Some of these require graphics, so I'm guessing a language that supports graphics, or just import your own library as seen fit?
>>
>>56668018
depends on what u put inside. just use whats best for the situation
>>
Suppose I need to declare two arrays with the same number of slots

Would this be a good way to go for it? Language is java btw:

int a = 25;
String[] n = new String[a];
int[] r = new Int[a];
>>
>>56668052
So if I'm putting inside random numbers, I get the scenario I described?
>>
File: 1469479149401.jpg (73KB, 600x414px) Image search: [Google]
1469479149401.jpg
73KB, 600x414px
>>56665168
I want to learn code. just to know better how computers work and maybe do simple things.
what do?

C->C++->python
C->Python
C++->Python
Just one of the three
>>
>>56668153
>>>/sqt/
>>
>>56668124
How do you declare an array with a desired size?
How do you get the size of an array?
>>
>>56668124
Yes, this is an ok way if you're allowed to create both arrays. If you can only create one of the arrays, see >>56668162
>>
>>56668146
looking through an unsorted array with all different real numbers, won't be the same as looking through one that can have duplicates.

there's all kind of sorting algorithms, just gotta use them suitably
>>
>>56668153
Learn C and/or Python

C is obviously way better if you want to learn how things work. Python does a lot of things for you and lets you focus more on the concept of your program which is why I think it's a great hobby language. I think C++ isn't good for beginners since it's bloated as fuck
>>
>>56667011
Real programmers don't have time for image boards, they have real programming to do.
>>
File: 1456711189441.jpg (53KB, 1024x578px) Image search: [Google]
1456711189441.jpg
53KB, 1024x578px
>>56667011
>/r/java
>Reddit
>Java
>>
>>56668153
To expand upon >>56668329 python lets you practice your algorithms skills better, C makes you learn memory management and other more complicated concepts since C doesn't hold your hand at all. In Java, the compiler tries to not let you shoot yourself in the foot. C lets you shoot your dick off , even unwittingly.
>>
>>56667885
kid confirmed
>>
>>56668380
>anime
>>
>>56668471
Anime website
>>
>>56668489
>>>/a/
>>
>>56668380
Most of the programming subreddits are pretty good.
>>
>>56667885
Heh. I've done that, but with a Sierpinski triangle.
>>
File: 1465788205966.jpg (92KB, 939x752px) Image search: [Google]
1465788205966.jpg
92KB, 939x752px
>>56668501
>/a/ was the first board
>anime is posted everywhere
>404 girl
>anime banners

>"not an anime website"
>>
>>56668124
Assuming that those arrays will hold different characteristics of the same "objects" (not Java Objects!, e.g. name and age of a person) you might want to consider just using one array of Objects instead.
I haven't used Java in forever - is there something like (String, Int) in Java?
>>
>>56668469
code monkey detected
>>
Does CPU pipelining only help in hardware implementations? or could it speed up VM implementations too?
>>
>>56668153
>just to know better how computers work
C. No substitutes.
>>
>>56667684
roll
>>
>>56668564
/b/ was the first board, but it was anime/random.
>>
>>56667684
roll
>>
i ain't here for durations i'm just taking vacations
>>
>>56668023
up to you, just make it happen
>>
>>56668023
C and OpenGL 1.0
>>
I've built an annoyatron, for Windows.

https://drive.google.com/open?id=0BxAwHtIXlHoGRU1ZTk5Fc0tPYnc
>>
File: sadkitty.jpg (188KB, 450x291px) Image search: [Google]
sadkitty.jpg
188KB, 450x291px
Traceback (most recent call last):
File "dogsnatcher.py", line 2, in <module>
from bs4 import BeautifulSoul as bs
ImportError: cannot import name BeautifulSoul
>>
File: 1427325174842.png (98KB, 430x180px) Image search: [Google]
1427325174842.png
98KB, 430x180px
>>56668895
sudo pip install beautifulsoup4
>>
>>56668893
>lostboy.exe
>>
>>56668916
Look again. It was a typo, not a missing module
>>
>>56668895
>BeautifulSoul
>>
>>56668931
holy kek didn't saw that
>>
>>56668893
>windows
>>
>>56668991
>greentext
>>
>>56669008
>not making your applications portable

lol
>>
>>56669025
Maybe in the future.
On that note: How do you make sound on Linux?
>>
>>56669066
very carefully
>>
how did you learn modern c++? is there a good book for it?
>>
File: 12.png (199KB, 769x556px) Image search: [Google]
12.png
199KB, 769x556px
>>56669086
>>
>>56669111
I have it, I just want to know if others use it or if they have advice for learning more
>>
Trying to create queries on multiple tables without INNER JOIN. Im stumped im new i hate sql
>>
>>56668601

So... while I haven't seen the source code to any large scale VMs, I would assume no. Pipelining the way a CPU does it implies that fetching instructions, decoding instructions, and executing instructions occurs both in parallel and in lockstep. Modern parallelism on computers, however, doesn't allow this easily. To force threads to work in lockstep requires the use of mutexes, which will slow down the computer, rather than speeding it up.

Moreover, it is worth noting that for VMs that emulate a foreign ISA, it is common to use dynamic recompilation, rather than interpreting instructions. In this scenario, all of the "pipelining" is left to the host CPU, since it is native code that ends up getting run.
>>
>>56669251
what qualifications do you have? college degree?
>>
>>56669281
How is that relevant?
>>
>>56669302
i see this guy "Ruby" on here all the time, and he seems to know his shit, so i was wondering what qualifications did he have.
>>
New to programming. What should I work on next after I've gotten sick of the for loop lesson that is Project Euler?
>>
>>56669302
He only trusts highly qualified Anons
>>
>>56669196
Can anyone give me a hint? Also im using access 2016.
>>
>>56669348
Maybe you should try actually reading the pdfs after completing a task and educating your dumb ass.
>>
>>56669339
>>56669371
>degree = qualifications
Even as someone currently pursuing a PhD, I find that pretty demeaning and offensive.
>>
>>56669348
>Project Euler
>for loop

you're doing it wrong
>>
>>56669348
Project euler is not about looping, it's about being smart beforehand and doing as little looping as possible.
>>
>>56669384

>the pdfs

Which ones?
>>
>>56669348
Write a program that given two strings A and B, determines if A is a substring of B. Optimize for speed and space.
>>
why don't we ever have programming competitions?
>>
>>56669348
Project Euler is more maths than programming
>>
>>56669395
>Even as someone currently pursuing a PhD
PhD in what?
> I find that pretty demeaning and offensive.
people with college degrees or any certification are more trustworthy than people who don't have any way to show that they know something
>>
>>56669441
>>56669441
Because TDPT contains people with skill levels ranging from implementing fizzbuzz for the first time to >>56665349
>>
>>56669452

Exactly, I want more projects to program and get practice with that are more programming-based and not number-theory based. Any ideas?
>>
>>56669461
>PhD in what?
High-performance computing (computer science)

>people with college degrees or any certification are more trustworthy than people who don't have any way to show that they know something
Are you actually saying that the content of >>56669251 somehow would be less or more "correct" depending on whether or not the poster has a degree or a certification?
>>
>>56669522
>would be less or more "correct" depending on whether or not the poster has a degree or a certification?
Yes. That's obvious.
>>
>>56669483
That depends on the languages you want to use, how much experience you have in different areas, what you are interested in etc.
You can always use something like this >>56667684 for ideas.
>>
File: ?.png (7KB, 120x120px) Image search: [Google]
?.png
7KB, 120x120px
>>56667083
what algorithm was used here to generate those sun rays?

anyone knows?
>>
>>56669281

I have a Bachelor's degree in Computer Science, and am currently studying for my Master's degree.
>>
>>56669571
When you finish your masters will you outgrow the ruby babysitting language?
>>
>>56669565

Using Python right now. Familiar with C++. Want to eventually use Swift.

Programmed enough to get me through a BS in mathematics. Working in a completely unrelated field but want to be able to program enough to get a decent job in the technology field.
>>
>>56669553
So if anon had a degree from Jesus Rules Texas University College, that would somehow make his statements more "correct" than if he, for example, has 20 years of work experience in a relevant industry?

Facts are facts, and errors are errors, no matter who says them or makes them. If I say something wrong, it's not "less wrong" just because I almost have a PhD.

If you base your line of reasoning on argument from authority and/or think that a piece of paper matters when it comes to knowledge, you have a pretty narrow world view.
>>
Anyone here know a good GPU for under 300 dollars for vga passthrough using xen on linux and opencl and stuff?
[spoiler]yeah i know this is off-topic[/spoiler]
>>
>>56669604
>that would somehow make his statements more "correct" than if he, for example, has 20 years of work experience in a relevant industry?
Implying in industry you learn valuable thing. In industry we just learn dirty trick.
>>
>>56669664
Then you work in the wrong industry, my friend.

Source: I'm doing an industry PhD.
>>
>>56669681
Are you doing a master's degree?
>>
>>56669567
I'm just calculating the angle created by the vector from the center to the pixel, and the horizontal, then using it as the argument for sine to get the increasing and decreasing intensity as you go around.
>>
>>56669693
Did you even read my post? I just said that I'm doing a PhD....

I already have a master's degree.
>>
>>56669704
No PhD and you think you're opinion is valuable?
>>
>>56669710
>opinion
Which opinion are you referring to, exactly?
>>
>>56669704
no shit sherlock. you already said you have a PhD in this thread 4 times.
>>
>>56669681
what does industry phd mean

a company is paying you to do your phd?
>>
>>56669729
Then why are you asking me if I'm doing a master's degree? Jesus...
>>
>>56669727
[this is post requires a PhD to be seen]
>>
>>56669727
Yours. You have no PhD, stop arguing.
>>
>>56669196
Anyone know sql? Id like to learn about programming in a programming thread
>>
>>56669735
That's the most common form, yes. In my case, however, I'm merely working in collaboration with a company and my funding comes from a government grant.
>>
File: 1411938566404.jpg (26KB, 559x282px) Image search: [Google]
1411938566404.jpg
26KB, 559x282px
Probably the ugliest piece of shit I have ever written

__declspec(noinline) static int NewMain(int argc, int *argv[]) {
return 123;
}

__declspec(noinline) static void NewMainEnd() {

return;
}


Then
    size_t pointer_NewMain = (size_t)NewMain;
size_t pointer_NewMainEnd = (size_t)NewMainEnd;
function_buffer = new char[pointer_NewMainEnd - pointer_NewMain];
memcpy(function_buffer, reinterpret_cast<char*>(&NewMain), pointer_NewMainEnd - pointer_NewMain);


What it does: Copies a function into a char buffer.
>>
File: spain-fs8.png (582B, 402x402px) Image search: [Google]
spain-fs8.png
582B, 402x402px
>>56669774
just use subqueries bro
>>
>>56669818
>Microsoft code

daily reminder that the reason Windows is closed source is because their code is horrible, and they don't want people to see
>>
>>56669818
>fun1()
>fun2()
>fun2 - fun1
not reliable
>>
>>56669779
That's pretty slick, mind sharing the industry? I do some amateur research outside of the day job but don't want to give up my salary to do it full time in academia.
>>
>>56669818
>Copies a function into a char buffer.
Something deep inside me just died
>>
>>56669819
Thanks famalam
>>
>>56669844
>and they don't want people to see
Like all closed source code.
>>
>>56669851
>That's pretty slick, mind sharing the industry?
I work together with a company that develops PCIe-based interconnects (think InfiniBand, but PCIe all the way instead, so extremely low latency combined with high throughput), and the field ranges from rugged environment to high-performance computer clusters. The guys that discovered "gravity waves" used our technology to run their calculation software, which is pretty neat.

>I do some amateur research outside of the day job but don't want to give up my salary to do it full time in academia.
I get that. I used to work as an embedded developer while I was doing my master's and for a year after I completed my master's before I went back, and I make considerably less money now than before, and it really takes a toll.

However, I feel that I'm compensated in the amount of travels and personal freedom and autonomy I enjoy, so it's not entirely wasted.
>>
>>56669847
Alternative was to use inline assembly and do a bunch of __emits but oh wait... x64 :(

"Inline assembly is not supported on the ARM and x64 processors."
https://msdn.microsoft.com/en-us/library/4ks26t93.aspx

Fuck.
>>
>>56669928
not him but do you a github?
>>
>>56669584

Ruby is a tool, and I'm not going to give up using it for the tasks it is useful for (i.e. everything Python is useful for). Nor am I going to give up C and C++ programming.
>>
>>56669818
How do you execute it?
Windows has no
mprotect 
to mark the page as executable and "call" it.
>>
>>56669951
I do, but I don't have a lot of interesting stuff on it, sadly. Just some personal projects from ages ago when I had time to have personal projects.

https://github.com/enfiskutensykkel
>>
>>56669988
holy shit i think i saw your github not so long ago.
you used to post here months ago?

awesome
>>
>>56670058
>you used to post here months ago?
Yeah, I'm a long time lurker. Been lurking since late 2007 / early 2008 and just stuck around.

You probably saw the Brainfuck compiler thing, I did that the first week of my summer vacation because I had nothing to do and no where to go (which is kinda sad actually).
>>
>>56669981
I don't. I save the function in a new executable section within a different file (PE). I change the entry point of the PE to the copied function.
>>
How do you guys feel about libraries and using other people's code? with permission ofcourse.
>>
>>56669928
Thanks man, your field sounds pretty metal. Sounds like I should stick to the day job until I can find someone to sponsor my research, heh. Besides the hit to salary, everything I've read about post-doc life sound miserable.

Shit is still interesting though, so I guess I'll stick to the amateur bit for a while and see what pans out.
>>
File: pih.jpg (966KB, 1012x1345px) Image search: [Google]
pih.jpg
966KB, 1012x1345px
>>56665168
Got this shit coming in Tuesday
>>
>>56670101
keep on keeping on.

Also, Norway is probably filled with a lot of qt3.14 girls
>>
>>56670112
nothing wrong with that.

they made those libraries to be used by people.
>>
File: book-cover-front.png (214KB, 1530x1980px) Image search: [Google]
book-cover-front.png
214KB, 1530x1980px
>>56670124
why not this?
>>
>>56670160
idk
>>
>>56670116
>Sounds like I should stick to the day job until I can find someone to sponsor my research, heh.
Well, as I said, despite the drastic cut in salary, I still make enough to make payments on my mortgage and afford food on the table (at least for the better part of the month), so it's not too bad. But it's not directly comfortable either, I'll give you that.

>Besides the hit to salary, everything I've read about post-doc life sound miserable.
Yeah, I have no intentions of doing a post-doc. It's pretty miserable and it's a constant struggle to fund your own job by applying to a bunch of projects all the time.

>Shit is still interesting though, so I guess I'll stick to the amateur bit for a while and see what pans out.
Well, best of luck to you then. I mean, you can look around for someone willing to sponsor you for an industry PhD, I guess that would be an ideal situation salary-wise.

What do you do for a living, if I may ask btw?
>>
void
triangles(const int width)
{
int height = width / 2 + 1;
size_t sz = (width + 1) * height + 1;
char *data = malloc(sz * sizeof(char));

for (int i = 0; i < height; ++i) {
int line_start = i * (width + 1);
int cnt = 0;
int lim_spaces = (width - i * 2) / 2;
int lim_sym = lim_spaces + (2 * i) + 1;

for (; cnt < lim_spaces; ++cnt) {
data[line_start + cnt] = ' ';
}
for (; cnt < lim_sym; ++cnt) {
data[line_start + cnt] = '#';
}
for (; cnt < width; ++cnt) {
data[line_start + cnt] = ' ';
}
data[line_start + width] = '\n';
}
data[sz - 1] = '\0';
printf(data);
free(data);
}

>this took me literally in 1 hour
Kiru me, I did it in JS in 3 minutes.
>>
>>56670125
>keep on keeping on.
Cheers.

>Also, Norway is probably filled with a lot of qt3.14 girls
They're too bad to be honest, but too bad I'm an overweight 2/10 turning 30 this year myself. So not exactly the ideal bf for said girls.
>>
In java, how can I use a PrintWriter object inside a method to write in a loop in another class? The .close() doesn't let me continue writing.
>>
>>56670193
If it's any comfort, I like your clean code formatting although
sizeof(char)
really tickles my autism.
>>
>>56670225
What method should be used instead of sizeof()? I don't know much C at the moment.
>>
>>56670204
>They're too bad
Oops. I meant that they're not too bad.
>>
>>56670185
> What do you do for a living, if I may ask btw?

Pretty comfy gig implementing backend infrastructure services for a fortune 100. Pretty standard Java/enterprise shop.

My stuff on the side, however, centers on the Curry-Howard correspondence. Spending a lot of time climbing the abstraction ladder from untyped lambda calculus to the calculus of constructions so I can start doing some original research.
>>
>>56670266
Oh wait, a char is 1 byte right?
>>
>>56670266
No, sizeof is fine (although it's not a method, it's a keyword).

It's just that according to the C standard, sizeof(char) is always 1, so you're basically doing sz * 1.
>>
File: starting-otter-aesthetics.jpg (290KB, 1008x1395px) Image search: [Google]
starting-otter-aesthetics.jpg
290KB, 1008x1395px
>>56670204
>overweight
what about lifting and some exercise? you probably have a strong jaw hidden behind all that fat in your face

you can't go wrong with lifting, imo
>>
>>56670287
Yes, so it's pretty redundant.
If you want to keep it there is also the
sizeof(*data)
option, which is the most sensible.
>>
>>56670272
>Pretty comfy gig implementing backend infrastructure services for a fortune 100. Pretty standard Java/enterprise shop.

As a college student, could you describe what a typical day looks like in your job? i'm learning to be a backend developer so i could use some tips.

if you don't mind of course.
>>
>>56670296
I used to be fit when I was younger (did MMA, kickboxing and taekwondo until ~22, even have a 2nd dan black belt in taekwondo). But I just got insanely sick of exercising. It's just insanely tedious, to be honest.

I guess I should just man up and do it from a health perspective though, since there's a heart condition running in the family.
>>
>>56670355
>>56670296
get a room faggots
>>
>>56670272
>Pretty comfy gig implementing backend infrastructure services for a fortune 100.
Well, I used to do some back-end before I did the embedded stuff, it was fun in its own way and if the PhD thing didn't turn out I would have no problem falling back on that.

>My stuff on the side, however, centers on the Curry-Howard correspondence. Spending a lot of time climbing the abstraction ladder from untyped lambda calculus to the calculus of constructions so I can start doing some original research.
This is way beyond my level, I have about zero knowledge of lambda calculus and I only know the fundamentals of functional programming, which is quite embarrassing seeing how I'm actually doing a PhD in computer science which was born out of that stuff.
>>
>>56670149
doesn't it make you feel like the program is less yours? ownership wise?
>>
>>56670403
Not the guy you're responding to, but no. But then again, I don't really feel that a program is "mine" to begin with. There's a reason why I always use a free license for my programs, and that is that I feel deep down that it really belongs to the public.
>>
>>56670403
depends. if you're using a lot of methods from that library, yes.

if you are using something like, stb_image (a public domain JPEG/PNG reader ) just to load images, its fine
>>
>>56669981

VirtualProtect
https://msdn.microsoft.com/en-us/library/windows/desktop/aa366898(v=vs.85).aspx
>>
I'm trying to use the following Java method
public void printToFile(Object o) throws FileNotFoundException{
File outFile = new File("out.txt");
PrintWriter out = new PrintWriter(outFile);
out.print(o);
out.close();
}

How can I place the out.close() outside this method so I can use it inside a loop? Already tried instantiating the method, but I don't know where to place the out.close().
>>
>>56670483
declare PrintWriter out globally
>>
>>56670483
make a PrintWriterFactory
>>
File: hiroyuki.png (152KB, 600x600px) Image search: [Google]
hiroyuki.png
152KB, 600x600px
can't translate this into python3 for the love of hiroyukichan
strings_to_query = [
"/how_to/build/your/own/gems.rb",
"How to build your google.rb own custom source control",
"Public methods are your grub public API and be",
"this text should be at the end"
]

query = 'grb'
query_reg = /#{query.split('').join('.*?')}/

sorted = []
strings_to_query.each do |string|
match = query_reg.match string
sorted << {string: string, rank: match.to_s.length} if match
end

sorted.sort_by! {|i| i[:rank] }

sorted.each do |pair|
puts "#{pair[:rank]} : #{pair[:string]}"
end
>>
>>56670336
> could you describe what a typical day looks like in your job?

You will inevitably encounter a flawed implementation of agile/scrum, which is when your platonic ideal of software engineering will be shattered. It'll be a constant source of frustration as management tries to bastardize the agile process to suit their business needs of the day.

On average a third of the day is dedicated to meetings with management and the rest of the day dedicated to achieving poorly defined "sprint goals".

My best advice would be to get _really_ comfortable with ambiguity, because management will rarely give you enough detail/direction to satisfy you. Set goals for yourself. Always learn something new. Ignore the crusty/bitter engineers because they're part of the problem too.

> Well, I used to do some back-end before I did the embedded stuff, it was fun in its own way and if the PhD thing didn't turn out I would have no problem falling back on that.

Yeah, all things considered it's not a bad gig.

> This is way beyond my level, I have about zero knowledge of lambda calculus and I only know the fundamentals of functional programming, which is quite embarrassing seeing how I'm actually doing a PhD in computer science which was born out of that stuff.

Untyped lambda calculus is actually pretty easy to pick up, and imho changes the way you think about how you describe programs. I wouldn't be embarrassed about not knowing enough about the theoretical side of CS. There's plenty about physics I don't understand, despite it being pretty fundamental to how the circuits in your pc work.
>>
>>56670429
you're kinding
>>
>>56670564
>kinding
Did you mean kidding? Because I'm not. Why do you think free as in freedom software licenses exist?
>>
>>56670579
can you repair my car too?
>>
>>56670429

That sounds like internalized communism.
>>
>>56670594
>>56670612
I don't work for free (or for others) even though I give a way code for free. Those are different things.
>>
>>56670501
You mean as a public instance variable?
>>
File: 7bc.jpg (48KB, 344x512px) Image search: [Google]
7bc.jpg
48KB, 344x512px
>>56670631

Sounds like you are working for free.
>>
sudo have sex with me
>>
>>56670673
sudo: sex: command not found
>>
>>56670673

>>56669387
>>
>>56670673

Username not in sudoers file. This incident will be reported.
>>
>>56670644
Are you actually claiming that effort and product of that effort are the same thing? Are you saying that spending two years designing a chair is the same thing as the physical, mass-produced chair?

What mental gymnastics and logical fallacies did you do to come to this conclusion?
>>
>>56670296
>suggest lifting
>sully your suggestion with meme-tier bodyweight

Don't do this program. Either lift, or do "real" bodyweight (i.e. pullup bar and pushup variation intensive). Or just go to /fit/ and make things easier.

Also, how about that technology, eh?
>>
>>56670631
you do work and you give it out for free
>>
>>56670718
>>56670644
Or another example: A composer spending years writing a song is the same thing as the thousandth cover band playing that song.
>>
File: pepe682.jpg (55KB, 500x473px) Image search: [Google]
pepe682.jpg
55KB, 500x473px
>>56670713
>This incident will be reported.
>>
>>56670744
I don't do the work for free, I give the product of the work for free.

Not the same thing. How do you think open source developers make money exactly? I can assure you that Linus Torvalds and the top 50 kernel developers do not work for free and are paid a lot of money for doing what they do.
>>
Reminder that if your language is garbage collected but cannot implement
traverse_
then it is useless.
>>
>>56670791
i could care less
>>
>>56670718
>>56670752

Neither of these are arguments.
>>
>>56670853
shart in mart
>>
File: mfw-dog.jpg (34KB, 575x465px) Image search: [Google]
mfw-dog.jpg
34KB, 575x465px
>mfw proprietary cucks are unable to grasp that free software developers don't work for free

How cucked by communism are you if you think freedom means that nobody gets paid? Capitalism aka economic and individual freedom works. You'd have to be a communist to not understand this.
>>
>>56670853
That's because you based your own arguments on fallacious logic and I'm trying to point that out to you using simple examples, you fucking imbecile.
>>
>>56670877
Communists don't work for free. Are you dumb?
>>
>>56670877
How do they get paid?
>>
>>56670877
communism has never been implemented
>>
>>56670908
>How do they get paid?
Well, many of them are employed by Google and other companies that invest heavily in free software. These companies sees the benefit of the free software as a business model so they pay developers to work on free software projects.

It's simple really.
>>
>>56670908
They don't. They threat their families if they don't work for free
>>
File: hereyougo.gif (88KB, 10000x10000px) Image search: [Google]
hereyougo.gif
88KB, 10000x10000px
can anyone tell me why this script isn't getting the thread names?
#!/usr/bin/env python3.4
import requests, re, time
from bs4 import BeautifulSoup

base_url = 'http://boards.4chan.org/b/catalog'
with requests.Session() as c:
source_code = c.get(base_url)
plain_text = source_code.text
soup = BeautifulSoup(plain_text, "html.parser")
for i in soup.findAll('div', {'class': 'teaser'}):
print(i)

>>
File: communism-tried.jpg (81KB, 543x960px) Image search: [Google]
communism-tried.jpg
81KB, 543x960px
>>56670907
>Communists don't work for free.
Of course, because communism is the opposite of freedom.

>>56670909
>muh real communism has neven been tried
That's the go to argument for every communist teenaged edge lord.
>>
>>56670959
Because you're a retard for not using the API
>>
>>56670501
Didn't work, does exactly the same as having the out.close() inside the method
>>
>>56670959
>html.parser
Use the JSON API, you idiot.
>>
>>56670981
Dont want to use the api
>>56670988
Im new to this, can you explain a little bit?
>>
>>56670997
https://github.com/4chan/4chan-API
>>
>>56671008
I don't want to use the 4chan api
>>
>>56671017
Why the hell not? Do you really think scraping HTML is a better idea than reading JSON?
You can't even argue that it's for learning purposes, because you're using a
import solution
solution.run()

program
>>
>>56671017
>14. The use of scrapers, bots, or other automated posting or downloading scripts is prohibited.
>>
>>56671017
>I don't want to not be retarded.
>>
>>56671017
use the api or gtfo, please.
>>
>>56669979
>ruby is a tool
Yeah he is
>>
>>56671042
You could've just said he's using a python program
>>
>>56670907

They work for stolen money, though. :)
>>
Installing the latest botnet 10 and its taking ages
>>
>>56671180
mine got stuck in an infinite loop and never even did install the update so i deleted windows 10 on my desktop entirely
>>
>>56669630
I just bought the XFX Disappointing3D. Oh well.
>>
why is it so much harder to write a 200 line paper than it is to write a 2 thousand line program
>>
>>56671489
With a program, those 2 thousand lines come naturally as the program expands. With a paper, the professor screams at you to write a 40 paragraph essay and gives you a topic that's only worth a few lines.
>>
>>56671532
make a calculator in 2 thousand lines, you won't
>>
>>56671562
make one that shows proofs
>>
>>56667684
Roll for this
>>
>>56667684
roll
>>
>>56671562
sure i will, i'll just make it text based
>>
I a dumb
How can I have it so that in a CodeBlocks project, the include, lib, src folders are in the project folder?

Also I still can't figure out how to get glad.c to be able to find glad.h.
>>
>>56671489
Because in programming being verbose is generally easier, and usually produces the shittier end result, so it's actually to your benefit to write something smaller.

With a paper, bloat is considered a good thing.
>>
>>56665715
I tried using the sdl2, but it was much slower than the sfml2.
I get around 60fps with sfml2, while sdl was around 25fps.
>>
Has anyone got the most recent challenge roller?

I'm restless and I can't sleep, need something to do.
>>
>>56672000
make the next facebook.
>>
>>56672032
I'm neither a kike nor a thief.

That and social media is literally crowd-sourced spying.
>>
>>56671763
using a GUI lib would add more lines you dip
>>
is it possible to make a dictionary mapped to functions in python?

ex
{"test1": test(arg1,arg2), "test2": test2(arg1,arg2)}


where I can iterate and check if get an instance of test1 I can run test() with my specified parameters?

or something similar to what I'm trying to accomplish?
>>
Trying to build Godot from source. On paper it's straight forward, but I think I've found an edge case.
>>
anyone else considering suicide
>>
File: Probelm.png (51KB, 794x678px) Image search: [Google]
Probelm.png
51KB, 794x678px
Trying to go through 2 chapters of exercises in 3 hours.

I keep getting this error on this one. I don't know how to fix it.
>>
>>56672396
everyday
>>
>>56672401
Can't you read the error message?
http://stackoverflow.com/questions/9138790/cant-use-modulus-on-doubles
>>
File: 1473868801019.jpg (86KB, 600x598px) Image search: [Google]
1473868801019.jpg
86KB, 600x598px
What are good projects to put on a CV/project site? Primary languages are C/C++ so can't put up a website/Android or iPhone apps, etc.
>>
>>56672396
not really these days but i had a "phase" where i seriously contemplated suicide. i guess i've learned to cope with my existence and in most ways i'm not actually as pathetic (compared to most other people) as i'd like to think sometimes. if i get "tfw no gf" i might just need a fap and then i can focus on programming or something.
>>
>>56672561
>so can't put up a website
Why not?
Also, anything that does CRUD.
>>
I'm getting a segmentation fault but I'm not sure why.

Here's a snippet of the code:

void addQueen() {

for (int m = 0; m < arraySize; m++) { // Fill array with queens
queenArray[m] = Queen();
}

queenStack.push(queenArray[0]); // Put the inital Queen in
for (int i = 1; i < arraySize; i++) {
queenStack.push(queenArray[i]); // Push the next queen onto the stack
currentQueen = queenStack.top(); // Make the top queen the current one
validQueens = 0; // Reset the number of valid queens
elementNum = 0;
compareQueens(currentQueen);
} // end for

}

void compareQueens(Queen comparedQueen) {

while (!queenStack.empty()) {
elementNum++;
queenStack.pop(); // Pop the current queen of the stack
previousQueen = queenStack.top(); // Make the top queen the previous one
tempArray[elementNum] = previousQueen; // Queens are temporarily saved in an array after they are popped
if (comparedQueen.getXPos() != previousQueen.getXPos() && comparedQueen.getXPos() - 1 - elementNum != previousQueen.getXPos() && comparedQueen.getXPos() + 1 + elementNum != previousQueen.getXPos()){ // If the current queen isn't directly, or to the immediate left or right above the previous one...
validQueens++; // Add one to the counter of queens that are valid
} // end if
} // end for


The part that is fucking up is the previousQueen = queenStack.top() part of the compareQueens method. I would imagine that this is because the stack is empty but as you can see in the code I push 2 items in the stack and pop one, so there should still be one left. Any ideas?
>>
File: graphix_snatch.jpg (36KB, 382x322px) Image search: [Google]
graphix_snatch.jpg
36KB, 382x322px
is it normal for new programmers to use a lot of if statements

I am working through exercises in a C++ book and while I eventually figure out the exercises, I often up with a shitload of complicated if statements all over the place

I feel like I might be missing the point of some of the exercises, there must be a less tedious way to do this stuff. but I'm not sure if maybe everybody does this in the beginning and later stops relying on it so much
>>
>>56672584
>Why not?
Because I haven't done any Front End shit, and want to specifically get gigs related to C/C++
>CRUD
Have messed around with Sqlite through C, nothing amazing though.
>>
please r8 my first program (be gentle)

#!/usr/bin/env python
import os.path
import datetime

date = datetime.date.today();

##This function writes input data to a text file with today's date as a filename and header
def diary_write():
diary_entry = open(str(date), "w");
diary_entry.write(str(date) + "\n");
dream = input("What did you dream?: \n");
diary_entry.write(dream + "\n");
diary_entry.close();

##This function reads text file contents and prints it for the user to read. It can only read files with
##the correct format (yyyy-mm-yy). Example: 2016-09-18
def diary_read():
read_entry = input("\nWould you like to read diary entries? ")
while read_entry[0].lower() == 'y':
read_entry_yes = input("\nWhat is the date of the entry? (yyyy-mm-yy) If you want to stop reading, type stop: ");
if read_entry_yes == "stop":
print("\nHave a nice day\n");
break
elif os.path.lexists(read_entry_yes) == False:
print("\nYou either did not dream that day or you entered an invalid format");
continue
else:
diary_read = open(read_entry_yes, "r");
print("\n");
print(diary_read.read());
diary_read.close();
else:
print("\nHave a nice day\n");

##Asks the user if they dreamt. If yes, then it won't let them write an entry if they already wrote one.
##If no, or an entry already exists, it will ask if they want to read an entry.
##If no, then the program closes.
answer = input("Did you dream last night? ")
if answer[0].lower() == 'y':
if os.path.lexists(str(date)) == True:
print("\nYou already wrote an entry for today!")
diary_read();
else:
diary_write();
diary_read();
else:
diary_read();


It's an electronic dream journal
>>
so I'm a retard and I'm learning C at the moment

say I have a function that takes in two arrays, is it possible to use an array for the first function argument, then modify the SAME array using another function and use the modified array for the second argument?

so it'd be like

arguments = (array a, modified array a)
>>
>>56672939

Learn LISP instead.
>>
>>56672228
You are thinking of a 1list of 2tuples.

1 is your key word and data structure. When using OOP, think of 1listobject.append() and 1''.del()
Then you can access each piece of the list like you would a regular list object. So at the individual list child objects, you can now look at them as tuples.
I ended up with a data structure like this the other day in WingIDE when debugging in my watch.
I am trying to explain the functionality of the thinking rather than code for you, as you need to understand rather than ask.From what I explained above, you can then google your python x-version list/dict append, del, merge, raw print.
>>
>>56672647
You should be popping after getting the top element. Here, you pop off the last element of the stack and then try to get the top element, which causes a segfault.
>>
>>56672949
th-thanks
>>
>>56672401
% isn't divide, / is
>>
>>56672899
Noticed a typo in one of my comments
Where it says (yyyy-mm-yy) it should be (yyyy-mm-dd)
>>
>>56671971
I guess I'll have to go with CreateDIBSection
>>
>>56672561
>>56672835
I mean, you need some kind of front-end knowledge if you're going to make a full project that you can show people. You can make UI pretty easily using QT; all the real program logic is in C++.
>>
>>56669979
u r a faget
>>
>>56672963

It's easy to manipulate lists in LISP. It's exactly what you want to do.
>>
>>56672989
I have to do this in C
>>
 10 PRINT "Hello World!" 

 20 GOTO 10 
>>
>>56672996

It's simply not possible. You can't even reliably average 2 integers in C.
>>
>>56672939
You could have the other function return the modified array and pass it in as the second argument.

someFunction(a, otherFunction(a));
>>
>>56672899
great stuff man. Start with intermediate stuff that challenges you and go from there.

I would like to challenge you to try writing to SQLite, MySQL, and using a tkinter GUI basic example to map your functions to the GUI calls.
Lastly if you are in windows, try a >10 step distutils compile to EXE so you can port it around.

Maybe its too out there. But give it a go and bite the whale a small bite at a time. You'll be impressed with your own product by the end and get familiar with data structures at the same time.
>>
>>56672978
Sorry, i meant front end in terms of websites and shit. Building a GUI for something, no worries, just don't know what are a good example projects, maybe a Music Visualizer/real-time FTT display? I can code, just don't know what to make to impress employers.
>>
>>56673017
I thought functions in C can't return arrays
>>
>>56672939
You would need to make a copy of the array before you modified it. Or create a new array in that function and return the result. (You would have to be careful about memory leaks with that method though.)

>>56672949 is more relevant than you might think. In Lisp, you could do something like (myFunction myArray (modify myArray))
>>
>>56673049
Not him but you can't return nor pass arrays to functions. You can pass pointers to arrays to workaround that.
>>
>>56673053

If only C had never been invented. There would be no C-likes, we'd all be using LISP-likes.
>>
>>56673029
Yeah, sorry, I don't know about that. I've thought about the same thing myself.

The most recent thing I've made is a desktop app that scrapes putlocker for video streams and provides a much nicer/simpler interface than their website. The problem is it's illegal, or at least in the gray area, so it's not exactly something to highlight to prospective employers. I really only made it for personal use and for some of my friends.
>>
>>56672899
I might add, why don't you try some logging?
Heres some logging I've done if you want to borrow to get you rolling.
import time
import logging
import os
import sys

logdate = time.strftime("Date %m-%d-%y"+"time-H:%H-M:%M" )
str(logdate)
filename = 'dream_journal' + logdate + '.txt'
log = open('C:dream_journal_'+logdate +'.txt', 'w')
logging.basicConfig(level=logging.INFO, filename='email_pylog' + logdate + '.log')
#Im a big fan of emailing logs
logging.info('Starting Program')
logging.info('Use this function to write to your log..')
try:
#there must be a try and except to use the error function
somecode/functionhere()
except ValueError as E_con:
logging.error(E_con + 'some reason the code failed here to append to log')
#If you like my code go ahead and throw a credits comment in your code for the logging:)
>>
>>56673151
No, it would be worse.
We would all be using Pascal-like languages.
>>
>>56673177

Pascal was better than C, though, and it led to safe languages like Ada.
>>
wtf is this and how do i fix
>>
>>56673200
>Ada
Have fun with your masturbatory "safe" languages.
>>
>>56672939

>is it possible to use an array for the first function argument, then modify the SAME array using another function and use the modified array for the second argument?

I am not sure what you are trying to accomplish here, but you will need to allocate memory for both arrays if you want them to exist in memory at the same time. But yes, it is possible to make a function with two array arguments, and it is possible to use a function to produce a mutated version of an existing array, either by returning a pointer to a buffer containing the new array, or taking a buffer as an argument and outputting to that buffer. Something like this might be an example:

#include <stdio.h>

typedef int (*intfunc)(int);

void map_ints(const int* input, int* output, size_t n, intfunc f)
{
for (size_t i = 0; i < n; ++i)
output[i] = f(input[i]);
}

int add_two(int n)
{
return n + 2;
}

int main(void)
{
int foo[5] = { 1, 2, 3, 4, 5 };
int bar[5];

map_ints(foo, bar, 5, add_two);
for (size_t i = 0; i < 5; ++i)
printf("%d\n", bar[i]);
return 0;
}


>>56673049

Functions in C can return pointers. You can malloc memory for an array, and return a pointer to the buffer. That said, you should make sure that the buffer you allocated gets freed before it leaves scope.
>>
>>56672794
i'd say it's normal, but maybe they're trying to teach you OOP or something, if you post an example we might be able to help
>>
>>56673233
>Java
You can't fix it rajeesh, also you can't divide a string and an int.
>>
>>56673258
how do fix
>>
>>56673162
What advantages would I get from having logging? I'm not entirely familiar with logging, just a little bit of research about it. My program is so simple that I don't see any errors happening, but I might be missing the point
>>
>>56673233
Not overly familiar with java- but you need to calm down first before looking at the code. Be Spock- if you get emotionally compromised/startled then the mission is jeopardized.

You can't divide a string (grade4) by an integer(number, in this case grade 4). Try turning all grades into numbers before dividing.
Also your compiler is always honest with you. Change the color from red to something less threatening:-)
>>
>>56673233
you need to parse the string into a number
>>
>>56673241

eat poop.
>>
File: drill.png (33KB, 809x211px) Image search: [Google]
drill.png
33KB, 809x211px
>>56673246
pic is the beginning of a set of several drills (which continue to make further checks such as if the integers are equal and so on, and ultimately ends up being a program that converts a bunch of types of measurements into each other)

how I did the first two parts was:

int main()
{
cout<<"Please enter two integers separated by whitespace.\n";
int peanut (0);
int shell (0);
while(cin>>peanut>>shell)
if(peanut>shell){cout<<peanut<<" is greater than "<<shell<<'\n';cout<<shell<<" is less than "<<peanut<<'\n';}
else {cout<<shell<<" is greater than "<<peanut<<'\n';cout<<peanut<<" is less than "<<shell<<'\n';}
}


but I'm wondering if I'm being retarded here and there's some fundamental concept I've missed. I've done most such comparisons this way. note that it is still pretty early in the book though so it might simply be that the appropriate concept hasn't been introduced yet
>>
>>56673291
When something goes wrong with an end user, you can quickly discover how far they got. If journals get deleted, you know when you wrote them. Many details you might not think to include in the journal itself are then chronicled.

It also helps for early termination and catches errors that you might otherwise miss by using try/except. This becomes a critical junction in a professional environment when you are held accountable for your work (if you so choose that path).
>>
Mew thred :3

>>56673422
>>56673422
>>56673422
>>
>>56673339
that's absolutely fine, that's how you'd normally do it (an if statement to do something different based on a comparison)
>>
Just wrote a program that will read in a list of movies with their budget and box office earnings, and will remove and commas and dollar signs, convert the numbers to integers (or floating point) and then will sort them by title and percent profit. Just finished.
>>
>>56673233
nigga you gotta turn that grade + grade + etc into a string
Thread posts: 340
Thread images: 34


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

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
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.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.