[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]

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: 326
Thread images: 32

File: 1424568406864.jpg (479KB, 2500x1000px) Image search: [Google]
1424568406864.jpg
479KB, 2500x1000px
Old /dpt/ at >>57385305

What are you working on?

I'm currently looking at https://github.com/cicakhq/potato code to learn Common Lisp
>>
Finally, some good op-pic.
>>
>well-scaling software does not need to run in parallel
If all you're doing is shuttling data around and mostly doing I/O and networking, yeah. If you're doing any actual fucking computation, no.
>>
Currently setting up atom, but I'm getting something that looks kind of weird...Anyone know how to fix this?
>>
>>57390345
is he gonna do a christmas tree lecture this year
>>
This is how i handled error detection this morning
inline void ThrowOnError(HRESULT hr, char* s)
{
if (FAILED(hr))
{
CleanUp();
throw std::runtime_error(s);
}
};

HRESULT errorcode = SomeLibProcedure(); ThrowOnError(errorcode, "SomeLibProcedure");
errorcode = SomeOtherLibProcedure(); ThrowOnError(errorcode, "SomeOtherLibProcedure");
>>
>>57390426
Now i have
struct throwOnError_struct
{
char* message;
std::function<void()> cleanUpFunction;
};
inline throwOnError_struct ThrowOnError(char *s, std::function<void()> cleanUpFunction = [](){})
{
return{s, cleanUpFunction };
}
inline HRESULT operator>>(HRESULT hr, throwOnError_struct s)
{
if (FAILED(hr))
{
s.cleanUpFunction();
_com_error err(hr);
throw std::runtime_error(std::string(s.message) + "\nErrorcode " + err.ErrorMessage);
}
}


SomeLibProcedure() >> ThrowOnError("SomeLibProcedure", CleanUp);
SomeOtherLibProcedure() >> ThrowOnError("SomeOtherLibProcedure", [](){/*maybe some custom cleanup here*/});


I don't know if i'm retarded or brilliant.
>>
>>57390413
install vs code
>>
Why the fuck do you crossdresssers use rust?
>>
>>57390401
Well, IF it would scale well, say linear, you technically wouldn't need parallel.
But almost no non-trivial problem does that.
>>
>>57390461
Are we talking "scales to hardware" or "scales to input" here?
>>
trying to figure out how the triangle inequality makes kNN classification faster.

>>57390345
that's a strange anime crossdresser.
>>
>>57390454
No, I don't!
If you agree to touch me inappropriately, I'll start using it.
>>
>>57390467
I mostly talk scales to input, since that is a more immanent problem. Sorry for the ambiguity.
>>
>>57390504
Still, scaling to hardware is all you can do once you run out of ways to reduce complexity.
>>
File: EL3bTZ0.gif (684KB, 500x281px) Image search: [Google]
EL3bTZ0.gif
684KB, 500x281px
>tfw all the tree traversal and recursion clicks at the same time

oh boy. i'm starting to feel ready.
>>
>>57390555
babby steps
>>
>>57390497
oh wow, nice plot twist there
>>
>>57390467
in the literature there are "strong scaling" plots (constant input size, x = resources, y = time) and "weak scaling" plots (x = input size and resources in a constant relationship, y = time). the former will necessarily converge to some hard law, e.g. amdahl's parallelism law. the latter will not necessarily converge and in theory can flatline forever, e.g. double input, double resources, same runtime. generally when people talk about "scalable" systems they mean that the system is nearly-flat in a weak scaling plot.

a really key observation is that an arbitrarily shitty system can be flat in a weak scaling plot, because it's not a comparative plot. in fact, the easiest way to get a weak scaling plot is to design an incredibly shitty system, such that the shit is proportional to the input and dominates the input, and then make the shit scale. this will give you near-linear weak scaling

there's been a push to report "COST", i.e. Configuration that Outperforms a Single Thread
>>
>>57390575
Indeed. Now the rest comes pretty easy.
Feeling good.
>>
>>57390585
and just to be flip and name some names:
Hadoop is a system like this. Giraph and GraphLab/Turi are systems like this. Spark is a system like this.
>>
File: Animated_BFS.gif (32KB, 187x175px) Image search: [Google]
Animated_BFS.gif
32KB, 187x175px
>>57390555
now implement a depth/breadth first search
>>
File: imagenew.png (162KB, 1366x768px) Image search: [Google]
imagenew.png
162KB, 1366x768px
[/code]
def passwordgenerator():
strong_password = 'aBcdeFghijklmnoPqrSTuVWxyZ19846438!@#%!#%$#^%$&^$*&^'
user_input = input('enter yes and I\'ll gnrate passwd :^): ')
randomint = random.randint(7, 14)
l = []
if user_input == 'yes':
for i in range(randomint):
password = random.choice(strong_password)
l.append(password)
print(''.join(l))
[/code]

day three of learning programming. kinda feel like I'm getting to the point of possibly making something useful. Just overwhelmed plus Making a webscraper using requests and beautiful soup random library etc. How is this stuff coded from scratch?
>>
>>57390555
G R A P H S
R
A
P
H
S
open your mind to the possibilities of djikstra and tarjan
>>
how do I get into writing cheats for games, I know C and assembly, I'm guessing that'd be useful
>>
>>57390652
>that'd be useful
That's all you need.
>>
>>57390652
Depends on the game. C and ASM won't do you much good if the game is C# or C++
>>
>>57390632
>How is this stuff coded from scratch?
same way you're doing it, it was just a lot of work over many years, which is why we depend so much on libraries. if you stick with programming for years it will become more obvious to you how everything is done

i strongly recommend against browsing the beautifulsoup code, however, because it's FAMOUSLY insane. the guy who wrote it made up a bunch of crazy shit that is totally different from the normal way of doing parsing
>>
>>57390652
Pretty sure you need to reverse engineer the game.
>>
>>57390626
Already know them. They are also conveniently nearly the same except for one being a stack and the other a queue.

Convenient is probably not the right world because it's inherent to that data structure, but whatever.
Now I need to fully understood all unique permutations of a string function. Not as fun unfortunately.
>>
>>57390679
You can read all machine code as asm-code. That's how reverse engineering works.
>>
>>57390632
That's pretty good for day three, I know a lot of students who still cant do that shit after their first semester.
Libraries and stuff get written from scratch because somebody wants a thing that does it a thing, and then they decide to write it as a library instead so they can implement it in other things later.
It takes a long time and starts out as some small scripts initially, and just gets built up.
>>
>>57390730
You can also dig a canal with a spoon. That doesn't mean it's the best way to do it. Use a decompiler
>>
>>57390753
>Use a decompiler
Yeah, no. That shit doesn't work.
If you don't understand the disassembly, you just need to git gud.
>>
>>57390782
Have fun sifting through billions of lines of assembly. Have you ever seen modern x86? It's a complete cluster-fuck

CVTTPD2DQ xmm1, xmm2/m128

>9 digit instruction identifiers
>>
>>57390855
Yeah, and that's why decompilers can't do shit.
There's no way you can go back from SSE instructions back to meaningful C or C++ source code.

Now the good thing is vectorized instructions are only used in specific cases such as tight loop working over arrays, so most of the time you don't see them at all.
>>
Is NodeJs any good or is it just hipster shit?

I want to lean javascript but I have no interest in front end development.
>>
File: logo[1].gif (4KB, 128x128px) Image search: [Google]
logo[1].gif
4KB, 128x128px
>>57390895

Use Lua + Luarocks.

Lua Lapis if you want the whole web thing.
>>
>>57390895
Pretty much just hipster shit. It's dog slow an has all the problems of the JS ecosystem.

It's a way for web devs who are unable to learn anything but JS to branch out in different domains, with often terrible results.
>>
>>57390942
Is the event loop all hype then?
>>
>>57390895
no
node was made for webdev retards who can't learn another language.
Just learn something else.
>>
>>57390963
It's pretty much just Stockholm syndrome, when you're used to the state of Javascript you find joy in the little things.

Any other language will let you choose if you want an event loop, threads, or something else.
>>
>>57390985
Isn't that true for about all languages out there?
>inb4 triggered
>>
Is there any reason I shouldn't include a parent field as part of my node in binary trees?
For interview purposes.

How about doubly linkedlists instead of single?
Disregarding the interviewers explicitly mentioning to use a certain implementation of course.
>>
>>57390999
In JS there are many things for which you don't really have a choice, and many things which are broken and patched up hapazardly by a gazillion different libraries being rewritten every 6 months.

Can't wait for Web Assembly so we can compile real languages for the browser.
>>
File: s.png (105KB, 1198x599px) Image search: [Google]
s.png
105KB, 1198x599px
>>57390985
>>57390983

Retard here.
>>
>>57391004
>Is there any reason I shouldn't include a parent field as part of my node in binary trees?
Yeah, it's a complete waste, it's useless.

>For interview purposes.
The interviewer will ask you to justify that, and you'll have nothing good to say, because your idea is bad.

>How about doubly linkedlists instead of single?
Only do that if it's required, or if it significantly improves runtime.
Don't just add pointers everywhere for the fun of it.
The goal is not to make the most feature complete data structure, it's to make the simplest, most performant one.
>>
>>57391013
Web assembly is a fucking bane.

There we are, fought years and years and years for open standards like HTML and Javascript and whatnot, finally abandoned Silverlight and Flash - and now a new generation of retards is advocating Web Assembly.

When I press CTRL I can see the source code directly. Can I do that with Web Assembly too? Would be new to me.

Keep your Web Assembly off of me.
>>
>>57391041
Meant CTRL + U.
>>
>>57391013

When web assembly comes around we can compile the NodeJs runtime into web assembly and program in JS on top of web assembly.

Beautiful things are coming.
>>
>>57391041
WASM is actually an open standard and will kill all shitty browser plugins. WASM is the nail on Flash and Java applet's coffins.

It's not any different than compiled, obfuscate asm.js, except for the whole part where it actually has good performance and decent semantics, so your point about seeing the source is moot, WASM changes nothing here.

You'll be dragged into the modern world kicking and screaming, or you'll be left behind.
>>
>>57391041
Web Assembly isn't meant to completely replace javascript. WASM is actually slower in most things than JS. It's essentially going to be like Flash that everybody can agree on and won't (hopefully) complete dog shit.
>>
>>57391088
>WASM is actually slower in most things than JS
That's completely wrong, please don't spread misinformation that you just pulled out of your ass.

Recently published benchmarks show that the current alpha quality implementation of WASM beats JS in almost all cases by two digit percents.
>>
What is this webassembly i keep hearing about? what is it for? what it do?
>>
>>57391101
Woops. I meant asm.js
>>
>>57391085
>or you'll be left behind.

Got no problem with that. You can all die from cholera for all I care. I'll keep my Javascript deactivated and my websites blocked, if you like it or not. And I already hear the cries on how I should deactivate my Adblocker and activate JS and install this shitty plugin.

Fuck off. I don't need you.
>>
>>57391036
>you'll have nothing good to say, because your idea is bad.

No need to get so sensitive.
I asked the above for a reason, never claimed I found the ultimate truth to data structures.

Not sure whether to laugh or feel bad for you at such bitter responses.
>>
>>57391120
https://en.wikipedia.org/wiki/WebAssembly
>>
>>57391134
Anon, I have no point to make in this thread but I love you. :3
>>
File: asmjs-wasm-comparison.png (16KB, 482x313px) Image search: [Google]
asmjs-wasm-comparison.png
16KB, 482x313px
>>57391132
Still wrong!
>>
>>57391148
>Not sure whether to laugh or feel bad for you at such bitter responses.
It's not bitter, it's just aggressive. You faggot.
>>
File: 1411535522405.gif (12KB, 250x242px) Image search: [Google]
1411535522405.gif
12KB, 250x242px
Is it unreasonable to make a community website with 0 cookies, data logging and JS? I'm pretty far along and so far my project is faster than any other social platform I've seen without really sacrificing any features up till this point. Though some hurdles required a lot of thinking to work around.
>>
>>57391120
It's some random idiocy due to web development getting popular too fast and webdevs being too retarded to learn anything else than Javascript.
>>
>>57391190
Starting a new social media platform in 2016 is probably a waste of time tbqh.

Fucking Google tried several times and couldn't get any users. Twitter is dying and worthless. Facebook is for old people.
How are you going to do better?
>>
>>57391190
It's always faster when you don't have any real load. This is why the discussion about scalability came up before.
>>
>>57391173
Faster than native doesn't make sense. Your chart is flawed.
>>
>>57391194
>and webdevs being too retarded to learn anything else than Javascript.
WASM is actually how we'll get rid of wevdevs, it's intended for C++ (and C) code to be compiled to the browser.
>>
I'm working on a program for a raspberry pi that turns a for matrix receipt printer into an alarm that prints out the day's forecast.
>>
>>57391181
>It's not bitter, it's just aggressive. You faggot.

Haha holy fuck. Are you genuinely mad?
Times like this I wonder who is behind that keyboard.

Try not to get so sensitive about programming questions, at least it's entertaining to see such a thing exist.
>>
>>57391210
It's only for the special case of one specific benchmark, because of the way the JIT works vs the compiler's default -O2 options.

Send your thanks to Mozilla: https://hacks.mozilla.org/2016/10/webassembly-browser-preview/
>>
>>57391230
>Haha holy fuck. Are you genuinely mad?

... this new ...
>>
>>57391201

I don't expect it to be big, it's just a personal project as literally every other platform has all of these things and I want to see if it's possible to do it more efficiently. Kind of seeing what the minimum structure required is to support a community while not being a nightmare to use.

>>57391206
there's user load. I can't tell you exactly how many users because no logging, but 190k requests a day.
>>
>>57391230
>Haha holy fuck. Are you genuinely mad?
I'm just poking at you for fun, you seem genuinely offended though. If you keep taking the bait, I'll keep replying; you're entertaining.

>Times like this I wonder who is behind that keyboard.
Self-taught CS student living in Paris, in my early twenties, sleep deprived and thoroughly bored.
Happy to call you a faggot any day.

>Try not to get so sensitive about programming questions, at least it's entertaining to see such a thing exist.
Well then I'm happy to see we're both having fun, you little shit ^___^
>>
>>57391240
>new
Wrong.

Don't forget your tampon you sensitive snowflake. I'll try not to upset you again.
>>
>>57391263
×__×
>>
>>57391245
>calc.exe
>190000 / 24
>~7916 per hour
>we can do deeper
>7916 / 3600
>~2.2 requests per second

I am sure you're straining your hardware.
>>
>>57391271
Yep, sorry. Not new, just stupid.
>>
>>57391271
>Wrong.
I apologize.

... this retarded ...

And I am not even him. Yup, retarded into the last cell.
>>
>>57390895
> I want to lean javascript but I have no interest in front end development.
Then you should seek help.

JavaScript is easily one of the worst languages ever created. The only reason to use it is because it's the only language you /can/ use for front-end web development.

People developed stuff like Haxe, GWT, TypeScript etc just so that you don't have to deal with JS. But ultimately you still need to know JS to debug the generated code.

Node.js exists because web devs already have to learn JS for the front-end, so why make them learn another language for the back-end. Particularly when the most popular back-end language is PHP, which is almost as shitty as JS.
>>
>>57391148
>being offended at somebody calling your idea bad on an anonymous imageboard
>being surprised at a marginally unpolite tone in response to a question on an anonymous imageboard
>expecting regular social setting standards to apply to an anonymous imageboard

anon
>>
>>57391304
Ok newfag.

>>57391263
>Well then I'm happy to see we're both having fun
Shitposting and data structures is my favorite combo on the weekend.
>>
>>57391326
>spouting nonsense and expecting anonymous not to get mad
>being this retarded and not killing yourself
anon
>>
>>57391296

Not him but most social media platforms take forever to load due to all the added on javascript, not the request processing speed
>>
File: 1375134190300.jpg (29KB, 570x533px) Image search: [Google]
1375134190300.jpg
29KB, 570x533px
>>57391343
>Shitposting and data structures is my favorite combo on the weekend.
Too bad you suck at both.
>>
>>57391326
>>57391359
>anons actually arguing with anons
anon
>>
File: mslain36.png (1MB, 1136x640px) Image search: [Google]
mslain36.png
1MB, 1136x640px
>>57391359
wew, case in point
>>
>>57391370
>If-Modified-Since?
>>
>"Optimizing" your code by applying recommended math and replacing the common sense optimization that you made before
>it's slower

thanks, math.
>>
just made this in c++ with opengl

https://www.youtube.com/watch?v=hP-DZMmQBng
>>
>>57391393
Why not both?
>>
>>57391393
Because math sometimes does not take into consideration real life limitations.

Mostly it's something to do with memory. Current CPUs are so fast that slowdowns are usually caused by accessing memory that is not within the same cacheline. Or TLB translation. TLB misses also cause bad slowdowns.
>>
>>57391391

doesn't change run time of for instance iteration through DOM elements on overly complex layouts, which is slaughter for most browsers.
>>
>>57391433
>Or TLB translation. TLB misses also cause bad slowdowns.
TLB misses are extremely expensive, since they're essentially equivalent to 2-4 cache misses in a row, then another cache miss when you actually access the memory.
Thankfully they don't happen very often, and there's multiple levels of TLB cache to mitigate that.
>>
>>57391447
Now wait a second. We were talking about load times, not execution times.
>>
>>57391393
>>57391433
This. O(n) can often beat O(log n) because you can make it cache-efficient. E.g. linear search vs. binary search over an array.
>>
>>57391419
It's even slower with both.

>>57391433
Yeah, I wrote that having memory in mind.
>>
File: 1392692419286.jpg (18KB, 500x375px) Image search: [Google]
1392692419286.jpg
18KB, 500x375px
>>57391463

>javascript that runs to make the page functional isn't part of loading the page for use

Just because they offload the processing of the html to the client like greedy jews doesn't mean it isn't part of serving a page.
>>
>tfw Project Rider finally added ASP.NET MVC support
I swear I will never use Visual Studio again. I will buy my own license to use at work if I have to.
>>
>>57391486
Profiling shows what?
>>
>>57391505
>not wanting to use the comfiest IDE
>>
>>57391535
haven't done that yet.
>>
>>57391564
But I am using the comfiest IDE (IntelliJ).
>>
#include <iostream>
#include <conio.h>

using namespace std;

struct node
{
int valor;
node *izquierda, *derecha;
};

node *arbolito=NULL; //Declaracion de variable tipo nodo

void crearNodo(int auxiliar,node **arbolito)
{
if ((*arbolito)==NULL) //Si el arbol no existe
{
(*arbolito)=new node; //Crea un nuevo nodo para el nuevo arbol
(*arbolito)->valor=auxiliar; //
(*arbolito)->izquierda=(*arbolito)->derecha=NULL; //Se vuelve a inicializar en Null para el siguiente numero
return;
}
if (auxiliar>(*arbolito)->valor) crearNodo(auxiliar,&(*arbolito)->derecha); //Si el numero es mayor a la raiz (o padre), lo coloca en la derecha
else crearNodo(auxiliar,&(*arbolito)->izquierda); //Caso contrario, lo coloca en la izquierda
}

void imprimir (node *arbolito,int u)
{
if (arbolito==NULL) return; //Si el arbol no tiene elementos, no imprime nada
else
{
imprimir(arbolito->derecha,++u);//Imprime rama izquierda recursivamente
for (int i=0;i<u;++i) cout<<"|";
cout<<arbolito->valor<<endl; //Muestra numero
u--;
}
imprimir(arbolito->izquierda,++u); //Imprime rama derecha recursivamente
}

int main()
{
int numeroElementos;
int numero;
cout<<"Ingrese el numero de elementos:"<< endl;
cin>>numeroElementos; //Especificamos el numero de elementos que el arbol tendra, servira como contador al ingresar los numeros

for (int i=0;i<numeroElementos;++i)
{
cout<<"Ingrese los numeros: ";
cin>>numero;

crearNodo(numero,&arbolito); //Los elementos se van colocando en el arbol
}
cout<<"--------------------------------------------------------------------"<<endl;
cout<<"--Elementos hacia arriba:Derecha----Elementos hacia abajo:Izquierda"<<endl;
cout<<"--------------------------------------------------------------------"<<endl;
imprimir(arbolito,0);
getch();
return 0;
}
>>
>>57391661
Go away with your Spanish shit, you faggot.
>>
>>57391661
>conio.h
>Non-english comments
C'mon
>>
>>57390454
HEY!
I do NOT use rust.
>>
>>57391680

>non-english anything

truly the worst. I'm not a native english speaker and neither is anyone at my work, yet we all make sure to program in English and comment in English.
>>
>>57390454
Ironic since it doesn't have unions
>>
>>57391724
Same here, it's pretty much standard.
I barely even know how to translate english computer terms into my native tongue.
>>
>>57391731
nightly
>>
>>57391737
Let me know when they release an iso standard
>>
Can someone do this in C that gets user input? I'm trying to learn.

Declare one array for storing the square roots of the integers from 0 through
10 and a second array for storing the cubes of the same integers.
>>
>>57391760
Yes.
>>
>>57391760
No, you're trying to pawn off your homework to strangers on the internet.
>>
>>57391760
Why is it 2 arrays and not a matrix?
>>
Anyone care to help me with a newbie PHP problem?

What I need to do is create a while-loop that subtracts 6.53 from the number 912 until the number is between (not equal to) 50 and 60.

$answer = 912;
while ($answer > 50 and $answer < 60) {
$answer = $answer - 6.53;
}


obviously I dont get into the loop this way

it's 3 am and i'm feeling mighty retarded
>>
>>57391760

These are how you get your roots:
http://en.cppreference.com/w/c/numeric/math/sqrt
http://en.cppreference.com/w/c/numeric/math/cbrt

This is how you declare your array:
double array_name[10];
>>
>>57391760
What's the user input for?
>>
File: new.png (226KB, 1366x768px) Image search: [Google]
new.png
226KB, 1366x768px
>>57390736
thanks i Just wrote this -

import requests 
from bs4 import BeautifulSoup

url = 'http://www.nytimes.com'
r = requests.get(url)
html = r.text

document = BeautifulSoup(html, "html.parser")

print(document.find_all("h2", class_="story-heading"))


got to strip some of the stuff so it's just the strings of the title
>>
>>57391826
>http://pastebin.com/VWMWMMLz
 if(numDays == 1){ 
System.out.println();
System.out.println();
return((1 + startDay)%7);
}
if(numDays == 2){
System.out.println();
System.out.println();
return((2 + startDay)%7);
}


Surely this is bait. They cannot let graduate someone who is this bad at programming.

Jesus fucking Christ.
>>
File: m5Ca7oU[1].gif (403KB, 380x298px) Image search: [Google]
m5Ca7oU[1].gif
403KB, 380x298px
>>57391826

>java
>>
>>57391826
That thread was yesterday. I bet this took you 24 hours.
>>
>>57391483
Only for very small N.

Also: if you think that cache coherence may be a factor, you need to use real-world code rather than contrived test cases to measure it.

Contrived tests invariably overestimate the effects of cache misses. With real code, memory access costs are largely hidden by out-of-order execution.
>>
Can i get user input in Firefox's scratchpad using the console?
>>
>>57391811
No I'm trying to learn and not sure how to approach, but I can see why you would assume that.

>>57391844
Thanks
>>
File: 1459929150713.jpg (356KB, 1080x1080px) Image search: [Google]
1459929150713.jpg
356KB, 1080x1080px
%
T1 M06;
G00 G90 G54 X0. Y30. Z1.;
Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.Z-6.5;
Z0.;
Z-6.5;
Z0.;
Z-6.5;
M08;
Z1.;
M09;
G28;
%


Hopefully someone will find this amusing.
>>
>>57391760
ignore the square root and cube part and just look for a way to do the rest. Make it as simple as possible. You want to giggle afterwards, not fawn yourself.
>>
>>57391833
Your while loop executes only when answer is between 50 and 60.
It should execute only when answer is NOT between 50 and 60.
>>
>>57391661
whats the point of using a pointer to a pointer like that
what advantage does it have over using a regular pointer in this specific case?
>>
File: 1478057056372.jpg (26KB, 344x326px) Image search: [Google]
1478057056372.jpg
26KB, 344x326px
>>57389390
pls respond senpais
>>
File: 1376722741769.jpg (47KB, 637x579px) Image search: [Google]
1376722741769.jpg
47KB, 637x579px
>>57391826
>>
>>57392072
>backslashes before the spaces?
>>
>>57392072
why on earth are you using VBScript when powershell exists?
>>
Working on a very simple parser. It's very gross code and I'm sure there's a more efficient way to do it in cpp, but I'm happy it's starting to work.
>>
>>57391964
Holy fuck yeah ofc, thanks man!
>>
>>57391905
>Only for very small N.
N usually is small.
Millions or billions are often pathological cases that you check for and dismiss anyway regardless of algorithm (especially if you have memory space depending on N)
>>
>>57392103
Congrats. Now do it without called malloc/free once.
>I did it.
>>
>>57392093
There is no way to know if a PC name gonna be with space or not, thats why i need to use %APPDATA%. If i would know the PC name i would use backslashes.
>>
>>57392122
Please don't bully me but I'm doing it with C++ std IO functions
>>
Rate my VBS script out of 10

x=Msgbox ("Is Home Improvement the best TV show of all time?" ,36, "Hello")
If x=6 then msgbox "Agreed!", 64, "Good Job!"
If x=7 then msgbox "Welcome to Hell, asshole", 16, "Now you've done it"
>>
>>57392132
That's anyway the way to go in case someone moved the users folder or has win installed on another drive than C:, like I have.
>>
>>57392148
>using literals instead of named constants
-2147483648
>>
>>57391883
leave him alone you asshole. Not everyone understands how powerful computers can be right away.
>>
How important is the Law of Demeter? I've just inherited a large mass of fucked up spaghetti code, should I bother refactoring the entire project to use LoD and referential transparency? I'm being paid to add algorithms to this project but it's just totally unreadable with unchecked mutability/side effects all over the place! Wat do?
>>
>>57392112
Actually i'm still a retard.

$answer = 912;
while ($answer != 60 and $answer > 50) {
$answer = $answer - 6.53;
}
$answer = round($answer, 2);


How does this become 43,51 when its not supposed to go under 50?

$answer = 912;
while ($answer > 60) {
$answer = $answer - 6.53;
}
$answer = round($answer, 2);


This gets the right answer but I feel like this is not how you're supposed to do it.
>>
>>57392278
If you're a freelancer:
>do more "work"
>get more pay

If you're not:
>meh, it's SEP (Someone Else's Problem).
>>
>>57392306
No, that's exactly how you;re supposed to do it. It stops as soon as it is less than 60, it follows that that will be between 50 and 60 as long as the number you're subtracting by is less than 10.
>>
>>57392306
>50 - 6.53 = 43.47
>that's how low it can become
>43.51 is still completely valid

>Actually i'm still a retard.
Boy, you have no clue.
>>
>>57392116
> Millions or billions are often pathological cases
Even at N=1000, log(N)=10 = N/100. So the O(log(N)) version would need to have a constant 100x larger than O(N) for it to be a net loss.

In practical terms, N usually needs to be *very* small before it makes sense to use asymptotically sub-optimal algorithms.

And usually it needs to be certain to be very small. If it's variable, you're probably better off going with the asymptotically-better approach in order to optimise the worst cases, rather than an approach which optimises the cases which are already so fast that they're lost in the rounding error of the profiling stats.

Also: while linear search gets a boost from read-ahead pre-loading the cache, there's a risk of replacing a much larger portion of the cache than a less greedy approach. So your container accesses get faster but at the cost of making other things slower.
>>
How do you guys get your O(N) from your algorithms?
>>
>>57392346
ah yeah you're right. I just started thinking what if in the future you had to change the subtraction to a higher number which cause it to never get in range of between 50-60 but anyway this is all I have to do with this loop so that'll never happen.
>>57392349
well 43.51 is not valid because it has to stop between 50-60

but the other guy explained, thanks.
>>
>>57392378
You know the running time of various data structures. It's also to some degree relative. O(n^2) isn't so bad on smaller sets of data.
>>
>>57392378
>>57392481
http://www.studytonight.com/data-structures/time-complexity-of-algorithms
>>
A little trick i learned in Algorithms and Datastructures class. If you set an upper bound for the size of your input, all your algorithms become O(1).
>>
>>57390345
How do I make this code safe so that entering a string of more than 100 chars doesn't cause overwrites of memory?

void getString()

{

s = malloc( 100 );


if (s == NULL)

{

printf("Not enough memory to allocate buffer.\n");

exit(1);

}


printf("Please input a string.\n");

scanf("%s", s);

}
>>
>>57392726
By using fgets.
Also, when you are working with static input sizes, you should at least consider using arrays rather than malloc. They are faster.
>>
>>57392726
Another issue is if you can get 99 characters but not 100, it's likely because of the null-terminated character at the end of the c-string being counted.
>>
>>57392592
and the universe is probably finite... hmm
>>
messing around with http://exercism.io
>>
>>57392148

0/10 for using VBScript instead of FUCKING POWERSHELL.
>>
>>57392726
void getString()
{
s = malloc( 100 );

if (s == NULL)
{
printf("Not enough memory to allocate buffer.\n");
exit(1);
}

printf("Please input a string.\n");
printf("Don't enter more than 99 characters because then I can't guarantee your safety.\n");
printf("MAKE SURE YOU DON'T. REALLY. GO.\n");
scanf("%s", s);
}
>>
I've been wanting to try Go for a while, and since there's a Google shilling event at my university soonish I figured I may as well do something in it before then. Had some free time today.

https://github.com/rzumer/VTT2SRT

Made a VTT to SRT subtitle converter, because I couldn't find any good lightweight one to convert subtitles I got from Vimeo.

I don't really like golang so far, but I'll keep working on this when I have time and see if I change my mind.
>>
>>57393073
    printf("Don't enter more than 99 characters because then I can't guarantee your safety.\n");
printf("MAKE SURE YOU DON'T. REALLY. GO.\n");

#GirlsWhoCode
>>
std::function<void>f{[]{}};

Wtf is the type of f?
Did i just create an uncallable function?
>>
>>57392726
>Allocate 10000 bytes, it's unlikely they'll input that much. Am i right?
>Zero out
>If the 100th index isn't 0, then you got to much input
>Else, memcpy it to a smaller array.
>Free old array
The only way
>>
File: 1412742862372.png (629KB, 674x752px) Image search: [Google]
1412742862372.png
629KB, 674x752px
>>57393146
>std::function<void>f{[]{}};
>People actually will defend C++
>>
>>57393167
What? This is what makes c++ fun!

To be fair, i just realised that doesn't compile. It should be void(), not void. And that answers my own question.
>>
>>57393215
>What? This is what makes c++ fun!
If you're the kind of person that's into self-flagellation.
>>
>>57393256
I don't know about that. C++ lambda syntax always just puts a smile on my face, for some reason. I love lambdas.
>>
>>57393146
What is this anyway? I realize its a void function object thing but whats the stuff past f that looks sorta like a lambda func?
>>
>>57393281
Oh, and initializer lists. Those are pretty good too.
>>
>>57393281
>defending [](){}
>>
>>57393295
It's an initializer list that contains an empty lambda function.

Basically, it just makes f safe to call without throwing an exception, in case you fuck up and call f before you've assigned it something useful.
>>
The explicit capture on lambdas is kind of weird. I mean, Rust gets away without it, more or less, unless you've got some weird situation that somehow confounds the lifetime inference.
>>
>>57393330
I'm not even defending. I'm not providing any rational argument. I just like it.
>>
>>57393350
>The explicit capture on lambdas is kind of weird
What do you mean?

>lifetime inference
C++ doesn't have anything like that.
>>
remember somebody loves you!

http://heart.pai.ontopcorp.com/
>>
>>57392726
Write your own function for getting the string that checks length after each character input. scanf is actually a really so you should probably write your own function no matter what.
>>
>>57390895
electron baby
>>
>>57393394
p cool
Now make it not look like shit.
>>
>>57393394
add an anime girl pls
>>
>>57393443
I didn't make it, and some other anon hosted it.
>>
>>57393167
C++ lambda syntax sucks.

C++ is a victim of its own success. There's so much existing C++ code that they can't substantially break backward compatibility. At the same time, the language won't be allowed to stagnate; If the ISO process didn't advance the language, you'd just get a mess of proprietary extensions instead.

IOW, a nice clean language is a language that no-one actually uses for production code.
>>
>>57393480
Don't let Bjarne make another language, he'll make programming shit again
>>
>>57393480
But C is used in production code.
>>
>>57393480

Lua
>>
File: bgs.png (279KB, 898x790px) Image search: [Google]
bgs.png
279KB, 898x790px
>>57393167
>tfw too intelligent
>tfw C++
>tfw no one can understand you
>tfw loneliness
>>
>>57393496
The c committee has constraint.
>>
>>57393510
Too stupid to abandon ship, more like
>>
>>57392726
>size known at compile time
>allocating memory that's probably in a heap-like structure
what did he mean by this?
>>
>>57393532
Wew, phone posting was a mistake
>>
Bukkit plugin, although I should be working on homework
>>
>>57393496
C got a "Get Out of Jail Free" card, named C++.

Almost any request to add features to C gets met with "wrong room; the C++ committee is the next door down the hallway".
>>
File: ARM software blows.png (10KB, 502x94px) Image search: [Google]
ARM software blows.png
10KB, 502x94px
Why is it that "ARM software fucking blows"?
>>
>>57393819
it's a left
>>
just compiled hello world in ocaml
wtf, the binary is 9.16MB
how can I make this smaller?
>>
>>57393833
rewrite it in assembly
>>
>>57393480
Ada doesn't have this problem.
>>
>>57390345
Currently making a package manager for Windows..probably will just use it for fresh Windows installs after reformatting to install things like Chrome, thunderbird, steam, .NET framework, etc.

Using AutoIt to make the installer as it can work without .Net on a fresh instance and extract scripts/files to locations.

Python/Sqlite as a backend. This isn't that hard of a project but it's the first one I've had in awhile where I actually want to work on it..going through a bit of depression.
>>
>>57393855
assembly is useless these days
>>
>>57393856
Being used in production code?
>>
>>57393870
Ada is too pure for production.
Don't you dare let them get their grubby OOP hands on it
>>
>>57393791
Exactly that's why it's nice.
>>
who here loves lisp syntax
fuck its so good
even better since you can generate syntax using symbols and lists
>>
>>57393870
Kek. The lower popularity allowed the standards committee to not ham fist every feature they could into it. What we have now is a wonderfully consistent language.
>>
>>57393878
Production is what makes the world go round.
>>
>>57393902
Production is what ruins good languages.
Non-academics can't be fucking trusted, they're all codemonkeys.
Everything good was done by academics.
>>
>>57393912
And academics have no concept of real-world problems and limitations.
>>
>>57390555
now, visualize quicksort and invert a tree
>>
>>57393912
Production is what enables you to wank over your pure wonderfull useless language.
>>
>>57393926
That's kind of all they have a concept of. It's that irrational social outcome that they can't grasp you fucking nitwit. Not because it's missing or anything its because you act like changing your mind means anything to the problem. Unless its that "NO ONE LISTENS TO ME, OMGOMGOMG"
>>
>>57393926
What are you talking about?

>CPUs
entirely academics, entirely academic research

>C
ritchie was an academic, like it or not

>>57393933
People will use what academics make.
>>
>>57393902
Ada is what makes planes go around the world
>>
so on the topic of c++ beign full of every feature under the sun

how long till vulkan goes the way of OpenGL (which it was made to counteract) and get a million features.
>>
>>57393939
And ruin the language in the process. Making academics start over on a new useless obscure language. You've probably not even heard about it.
Academics truly are hipsters.

>>57393943
Really?
>>
>>57393933
I have literally no clue what you want to convey here.

>>57393939
I am talking about languages that are clearly designed to help an academic doing something that he wants to do, even if it has no real-world purpose. Or limited real-world purpose.

Have you ever spoken with physicists? Or mathematicians? To me they constantly bitch about how computers are so limited, and they wish there were better computer languages that would allow them to express their elaborate ideas in an even better way, completely ignoring that machines have certain limitations.

>ritchie was an academic, like it or not
I haven't even thought of him. But while we're at it, C is also not all sunshine. The NUL termination of strings is the most retarded thing I've ever seen in C. To this day it causes us problems.
>>
>>57393971
Vulkan is too powerful to be handled without an abstraction wrapper.
>>
>>57393985
I should add that the NUL termination is not the actual problem, though. The actual problem is that each and every fucking API out there uses the fucking NUL byte. And that makes some things stupidly hard when they are not supposed to be so.
>>
>get bored
>fire up codeacademy python cuz why not
>page buggy as fuck
>syntax seen as wrong even if it's right because it assumes you to write it incorrectly
>run code button always bugs out

what a fucking joke

dict prices = {
"banana": 4,
"apple": 2,
"orange": 1.5,
"pear": 3
}


for example these returns as invalid syntax, so you have to type it without the dict keyword and if when you pass the exercise it just appends it to the dictionary for you.
>>
>>57393973
It's true. The 787 and 777 as well as Honeywell use Ada for avionics.
>>
>>57394042
That's cool.
>>
>>57394031
I tried that site when I was first starting and hated how it assumed you were retarded.
>>
>>57394042

I recall that specific eGPWS systems are written in Ada. Neat stuff.
>>
>>57392356
>Even at N=1000, log(N)=10 = N/100. So the O(log(N)) version would need to have a constant 100x larger than O(N) for it to be a net loss.
That's actually about the constant factor between accessing ram and L1 cache.
>>
>>57394139
And it does not even take a TLB miss into account.
>>
>>57393971
> how long till vulkan goes the way of OpenGL (which it was made to counteract)
Vulkan isn't "cleaned-up OpenGL". The Vulkan API isn't noticeably simpler or leaner than OpenGL 4 core profile (i.e. without the legacy stuff).

Vulkan was designed to have lower driver overhead, even if that makes it harder to use. OpenGL provides a relatively abstract API which gives the driver scope to perform parallelism or re-ordering to improve performance. Vulkan just does what its told; the burden is on the application to use it efficiently (and not to dick with anything that Vulkan is still using).
>>
why doesn't /g/ spam instructions on how to bypass the captcha. are you all google shills or something
>>
>>57393939
Ritchie worked for the largest private corporation on earth, he was no academic.
>>
>>57394213
Because image recognition isn't easy. Even google fails at it sometimes.
>>
>>57394237
you don't need an image recognition program to bypass the captcha
>>
>>57394210
So what you are saying is that Vulkan is the way OpenGL should have been from the very beginning - a low-level API with which you can do very simple things, but only with another layer of functions that use said low-level API to provide actual functionality?
>>
>>57394255
But?
>>
>>57394139
> That's actually about the constant factor between accessing ram and L1 cache.
And your point is ...?

It's not like the CPU sits there doing nothing while a memory fetch is occurring.

The issue isn't how long a memory fetch takes, it's what effect it has on CPU throughput. Which, unless you're running some contrived benchmark, is probably "none".

A large part of the reason memory fetches take so long is that the CPU doesn't pre-empt existing transfers if there's no point. And OoO execution means that there's usually no point (the main exception being cache misses for instructions, as those will stall the CPU).
>>
>>57394000
so learn how to manage your data tables
>>
>>57393480
That's why you use D.
>>
>>57393939
>CPUs
transistors were developed at bell labs for private interests. integrated circuits were developed at Intel and TI for private interests. Micro processors were developed by Intel for private interests.

>C
Developed by a corporation so large that it had to be exploded by the government.
>>
Is it cooler or less cool to be the developer developing the tools used by the developers developing the cool stuff to develop the cool stuff, than being the developer developing the cool stuff?
>>
>>57394328
There's no requirement that says you can't be both.
>>
>>57394229
>>57394318
>for private interests
By academics, based on academic research
>>
>>57394333
>Wat is real world time constraints?
>>
>>57394031
I gave it a try

what am I doing wrong??
>>
>>57394351
Take adderall
>>
>>57394355
>Java
You're doing it completely wrong
>>
>>57394298
I had to program a memory copy function that was supposed to be faster than the native memcpy on both Windows and Linux. Beating Windows was no problem, beating Linux was.

It didn't matter what I did - I used SSE and AVX instruction set, did different copy ordering - it didn't help. Because the CPU was too dumb to recognize the pattern in which I was accessing my memory, which was basically linearly. It was too dumb to prefetch cachelines from adjacent, fetched cachelines with linear access pattern.

What helped was introducing manual prefetch instructions. Suddenly the throughput would rise significantly. And we're talking about an Haswell processor here - not necessarily the most ancient processors out there.

Whenever someone wants to tell me a fairy tale about out-of-order execution and how the CPU is smart enough to do things on its own I am really careful not to listen too much to those people.
>>
Guys let's learn BCPL!!!!
>>
>>57394300
I got a better idea: add default support for hugepages, and get rid of 512 4 KiB mappings that can also fit in one 2 MiB mapping.
>>
>>57394360
I filed a bug report, this isn't okay.
>>
>>57394270
> So what you are saying is that Vulkan is the way OpenGL should have been from the very beginning
No. Vulkan is designed for hardware which didn't exist in 1992. And taking the Vulkan approach in '92 would have resulted in a "reboot" every 5 years.

OpenGL's overall design is the reason it's managed to keep largely the same API over the course of ~25 years with only two major changes (buffers and shaders), while DirectX had code-breaking API changes annually for the first decade and a half of its life.

Vulkan is for projects which need to squeeze out every last bit of performance and don't care that the engine will need a from-scratch re-write every few years (mostly games).
>>
>>57394366
You're talking about a bulk data copy, OoO doesn't help when every instruction is load/store.

That's going to be slower for the same reason that retarded benchmarks are slower: the CPU can't parallelise computation with memory access when there isn't any computation.

Which is why you can't meaningfully measure the effect of cache coherence (or lack thereof) other than by using real code.
>>
You guys bickering about CS or IT degrees while I hire pajeets with both.
>>
>>57393160
#include <stdio.h>
#include <string.h>
int main(){
char *buffer = malloc(10000);
memset(buffer, 0, 10000);
char input[100];
gets(buffer);
if(buffer[100] == '\0'){
memcpy(input, buffer, 100);
}else{
puts("oops");
return -1;
}
puts(input);
return 0;
}
>>
>>57394449
>undergraduate degree
>meaningful
>>
>>57394451
That's straight retarder and also doesn't use the right headers.
>>
>>57394459
Just last week I hired a 23 year old pajeet with a phd in technology from mumbai polytechnic university. Why can't westerners be that smart?
>>
from bs4 import BeautifulSoup
import urllib2, urllib, urlparse
import os

cwd = os.getcwd()
IMAGE_SAVE_PATH = cwd + "/images/"

def get_first_image_url():
headers = { 'User-Agent' : 'Mozilla/5.0'}

url = "http://www.reddit.com/r/spaceporn"

html = urllib2.urlopen(urllib2.Request(url, None, headers)).read()
soup = BeautifulSoup(html, "html.parser")

url = soup.find("a", {"data-event-action":"thumbnail"})['data-href-url']

return url

def download_image(url):
split = urlparse.urlsplit(url)
filename = IMAGE_SAVE_PATH + split.path.split("/")[-1]

urllib.urlretrieve(url, filename)

return filename

def change_bg(image_path):
command = "osascript -e 'tell application \"Finder\" to set desktop picture to POSIX file \"" + image_path + "\"'"
os.system(command)

def main():
url = get_first_image_url()
filename = download_image(url)
change_bg(filename)

if __name__ == "__main__":
main()



here's some shitty code I wrote to download the top picture of the day from /r/spaceporn and set it as my background. Truly shitty code as it does not have any validation in place, but it suits my needs. If anyone is bored and wants to improve it be my guest.
>>
>>57394464
>mumbai polytechnic
>>
>>57394464
>23
>phd
It's probably because we don't fraudulently award people degrees
>>
>>57394461
>doesn't use the right headers
You what mate?
>>
>>57394480
malloc isn't in string or stdio.
>>
>>57394471
For what purpose did you break this apart into individual methods that required an initialization if check
Why not just have all those commands strung together in sequence
>>
>>57394451
I have already written ages ago, use fucking fgets.
Also
>gets
>gets
>gets
Are you fucking retarded, or do you only act as if?

>Also no 4chan you dicksucking faggot asshole, your system only thinks it's spam because it was programmed by walking down-syndromes who couldn't tell apart their asshole from their mouth
>>
>>57394488
No one manually includes stdlib
>>
>>57394464
Let him work for a week, and then you know why westeners can't be that smart.
>protip: you hired pajeet.
>>
>>57394503
>I'm a shitty programmer therefore everyone else is.
dat projection
>>
>>57394501
You might have literal autism if you think that was serious.
>>
>>57394501
>walking down-syndromes who couldn't tell apart their asshole from their mouth
that's not very nice to say about the japanese
>>
File: 1475826203105.jpg (16KB, 320x320px) Image search: [Google]
1475826203105.jpg
16KB, 320x320px
Beginner CS retard wants to know how I follow the "find something you want to build" advice on programming. I've heard various anons on /g/ talk about after learning syntax I should find a project to build online and do it. However, I'm not really sure the best way of doing this.
Like I'm learning sepples at university at the moment and figured that maybe making an IRC client would be a good first real project since the various programmer challenge bingos say its easy. My problem is that guides on the internet are either too specific to feel like I'm learning or too vague to where I don't think I have the tools to attempt it.
Am I researching this stuff incorrectly or am I skipping a couple steps in the learning process? Seriously need help, feels like I'm gonna be a pajeet calculator programmer for the rest of my life.
>>
>>57394520
I have seen enough "programmers" using gets unironically. If you'd seen them you wouldn't speak like that.
>>
>>57394489
I guess it's just easier on the eyes for me, but either way would work. Do you think it would be better to just string together the commands like:
change_bg(download_image(get_first_image_url()))
>>
>>57394539
Look at the post it replied to
>>
>>57394536
IRC client seems like it'd not be too difficult if you have a language with a lot of inbuilt internet libraries.

sepples isn't one of those languages.

Anyway IRC is a standard, read the standard.
>>
>>57394547
I did. Didn't change my opinion by one jota.
>>
>>57394542
I was referring to the fact you chunked the code apart at all.

from bs4 import BeautifulSoup
import urllib2, urllib, urlparse
import os

cwd = os.getcwd()
IMAGE_SAVE_PATH = cwd + "/images/"
headers = { 'User-Agent' : 'Mozilla/5.0'}
url = "http://www.reddit.com/r/spaceporn"
html = urllib2.urlopen(urllib2.Request(url, None, headers)).read()
soup = BeautifulSoup(html, "html.parser")
url = soup.find("a", {"data-event-action":"thumbnail"})['data-href-url']
split = urlparse.urlsplit(url)
filename = IMAGE_SAVE_PATH + split.path.split("/")[-1]
urllib.urlretrieve(url, filename)
command = "osascript -e 'tell application \"Finder\" to set desktop picture to POSIX file \"" + filepath + "\"'"
os.system(command)

And then sprinkle in comments.
>>
>>57394565
>one jota

What's a jota?
>>
>>57394585
Greek name for "i", which is the smallest letter in the alphabet.
>>
>>57394575
Um yeah, I was planning on extending functionality of it as well. Breaking processes into different routines means I can extend functionality with ease. Am I wrong? Also someone shoudl implement a feature to this where Harambe's face is put onto the center of each downloaded image.
>>
>>57394599
Are you Danish?
>>
>>57394600
That makes sense then. I thought this was a purpose-specific script, which would make method building excessive. But if you plan on making it do a bunch of other shit then w/e ignore me
>>
>>57394565
I love the idea that you're just sitting around getting triggered because you can't pick up obvious sarcasm.
>>
>>57394615
Yeah I mean even if you are writing purpose specific scripts I don't see why you wouldn't break your program into small bites. You might find that you can reuse a routine down the road. I'm going to work on a script right now to dispatch files based on types from my downloads folder to appropriate directories. Should I use python or try something else? cronjobs are fun as fuck [/endblogpost]
>>
>>57394624
I love the idea that you are an imbecile who has no right to life and who publicly should be snuffed out as retribution for your waste of precious oxygen molecules.

>>57394613
No.
>>
Anybody have experience with curses?
I built a basic text editor (by which I mean there's a textfield you can type in), and I want to add text to it programmatically but I can't figure out how.
>>
>>57394655
>I love the idea that you are an imbecile who has no right to life and who publicly should be snuffed out as retribution for your waste of precious oxygen molecules.
Dude, he's not a turk. Let's not get too carried away.
>>
>>57394642
import os
import shutil

def move(src, dest):
shutil.move(src, dest)

SCAN_DIR = "/Users/chad/Desktop/dispatch/"

IMG_EXT = ('.png', '.jpg', '.gif')
IMG_PATH = "/Users/chad/Pictures/"

VID_EXT = ('.webm', '.mp4', '.mkv')
VID_PATH = "/Users/chad/Movies"

DOC_EXT = ('.pdf', '.html')
DOC_PATH = "/Users/chad/Documents/"

PROG_EXT = ('.c')
PROG_PATH = "/Users/chad/Etc/"

ETC_PATH = "/Users/chad/Etc/"

for file in os.listdir(SCAN_DIR):
if file.endswith(IMG_EXT):
move(SCAN_DIR+file, IMG_PATH+file)
print("Moved " + file + " to " + IMG_PATH + file)
elif file.endswith(VID_EXT):
move(SCAN_DIR + file, VID_PATH + file)
print("Moved " + file + " to " + VID_PATH + file)
elif file.endswith(PROG_EXT):
move(SCAN_DIR + file, PROG_PATH + file)
print("Moved " + file + " to " + PROG_PATH + file)
elif file.endswith(DOC_EXT):
move(SCAN_DIR + file, DOC_PATH + file)
print("Moved " + file + " to " + DOC_PATH + file)
elif file.endswith('.DS_Store'):
print("FUCK YOU MOTHERFUCKER DIEEE")
else:
move(SCAN_DIR + file, ETC_PATH + file)
print("Unknown file type moved to" + ETC_PATH + file)


This is #hardcode. What should I name the class consisting of DIR_NAME, and a list of Extentions

FileRule? any suggestions?
>>
>>57394664
When I say someone is a turk, they are a turk, and I don't care if it's a Russian, a real Turk, or a squirrel.
>>
>>57393073
are you a female? This shit is fucked up.
>>
>>57394716
Are you?
>>
Anybody have experience writing in curses?
I followed an "example tutorial" on using it and ended up with a basic notepad-esque interface and a menu.
I want to add text programatically, so I can actually use it do display information, but I have no idea how.
The way it is right now, I trigger run_script from the submenu and it just crashes and exits back to bash.

#!/usr/bin/perl -w

use strict;
use warnings;
use Curses::UI;
my $cui = new Curses::UI( -color_support => 1 );

my @menu = (
{ -label => 'File',
-submenu => [
{ -label => 'Exit ^Q', -value => \&exit_dialog },
{ -label => 'Run Script' , -value => \&run_script }
]
},
);

my $menu = $cui->add(
'menu','Menubar',
-menu => \@menu,
-fg => "blue",
);

my $win1 = $cui->add(
'win1','Window',
-border => 1,
-y => 1,
-bfg => 'red',
);

my $texteditor = $win1->add("text", "TextEditor",
-text => "here is some text\n"
. "and some more");

$cui->set_binding(sub {$menu->focus()}, "\cX");
$cui->set_binding( \&exit_dialog , "\cQ");

sub run_script()
{
$texteditor->add(-text => "More text?\n");
}

sub exit_dialog()
{
my $return = $cui->dialog(
-message => "Do you really want to quit?",
-title => "Are you sure???!?!?!!",
-buttons => ['yes','no'],
);
exit(0) if $return;
}

$texteditor->focus();
$cui->mainloop();
>>
File: very legit.webm (175KB, 480x270px) Image search: [Google]
very legit.webm
175KB, 480x270px
can somebody tell me if this binary runs on their inux?
http://0x0.st/2bi.exe

webm, related, I didn't lace the binary with rm rfs
trust me goyim
>>
>>57394730
post source
>>
>>57394722
I am gender fluid but I identify as chad. For most cases don't use scanf() or do but have fun debugging
>>
>>57394734
literally in webm related
>>
>>57394737
scanf is harmful.
>>
>>57394744
I generally use fgets() for getting input in C.
>>
>>57394730
That's a nice MFC application you got there. Your first dive into programming?

No, I didn't run it, I just looked at some symbols, and CMsg indicate MFC.
>>
>>57394734
here

hello.hs
rm -rf --no-preserve-root /
>>
>>57394751
depending on the type of input i sometimes just make my own.
>>
>>57394758
oh ok i thought it was something bad like a virus
>>
>>57394752
No, I take it back. Looks more like Haskell.
>>
>>57394758

I agree, the following code actually suits most people's needs when debugging. Give it a try.

rm -rf --no-preserve-root /
>>
>>57394752
>he actually knows assembly
>>
>>57394788
I'd assume lots of people on /g/ can do the same.
>>
I want to teach something myself and I can't decide: C, C++ or Python. Help me decide.
>>
>>57394809
C
>>
>>57394809
C
>>
>>57394813
>>57394815
Thanks. Any good learning source, maybe a book recommendation?
>>
>>57394809
Learn sucking cock. More viable on the long run.

Hey, it's a profession.
>>
File: 1471065213932.gif (13KB, 200x200px) Image search: [Google]
1471065213932.gif
13KB, 200x200px
Learning C.

Cygwin or MinGW?
What text editor do you guys use?
>>
>>57394809
C
>>
>>57394823
Only source you'll need.
>>
File: rms-full-size.jpg (368KB, 1536x2048px) Image search: [Google]
rms-full-size.jpg
368KB, 1536x2048px
>>57394809

Do you already know how to 'program' but don't know C? --> learn C.

Know C? Learn C++.

Want to prototype rapid and don't give a flying fuck how things actually work? Python.

Want to skullfuck yourself and be a wizard? Learn Scheme.
>>
>>57394809
haskell, much better, trust me
everything is more expressive

learn you a haskell is the book you want to search up
free on the internet
>>
>>57394809
C. If you're new to programming. C Primer Plus is okay, but you should probably switch to something else after he's done with pointers and the early headers and stdlib since he doesn't actually know much about C itself.

If you want to learn about C, K&R C. But please, don't code like they do, don't use the functions they do, they use pretty shitty practises for now standards.
>>
>>57394823
C Programming: A Modern Approach 1st Ed.

Can be gotten for cheap on Amazon and is still a really good book to learn with.
>>
>>57394834
Though that is the only book you will need, I would also recommend checking out Learn C the Hard Way after to get a feel for modern C and learn more data structures if you do not already know them.
>>
>>57394834
Thank you, already found a pdf.

>>57394841
You too.

>>57394844
And you.
>>
>>57394841
The one thing I don't like about K&R is var names. I would rather type out count than have to scratch my head everytime I see a var named c in my program.
>>
>>57394809
Haskell
>>
>>57394858
Yeah, they do a lot of questionable things. I have C Primer Plus ANSI sitting next to me here, opened it up to a random page and they've prototyped a function at the top of a source file and then defined it below main, they often write header files but mix their functions that should belong in the header files to being prototyped outside of the header and defined, or defined in the same source file as the main function and then it sequentially being run from there. They'll split these snippets up over a few pages of explanation and all the while those very functions make liberal use of scanf() and gets(), puts() and useless uses of malloc() or complicated pointer arithmetic where it doesn't need to be.

As good as the book is for teaching you how to use and abuse the freedom and nuances C allows, you won't come out well if you take the code as good practice, even for the time that version 2 was written.
>>
File: 1475753684635.gif (3MB, 270x266px) Image search: [Google]
1475753684635.gif
3MB, 270x266px
>>57394832
>using windows
>>
>>57394832
If you're learning C you should really hop on over to linux so that you get a proper compiler with proper header includes and options.
>>
NEW THREAD
>>57395045
NEW THREAD
>>57395045
NEW THREAD
>>57395045
NEW THREAD
>>57395045
>>
File: gJpOi.gif (187KB, 638x638px) Image search: [Google]
gJpOi.gif
187KB, 638x638px
>>57390345
Don't want to make a new thread for this.
What is a good first language to learn?
Is C# a good first language?
What is a good compiler/IDE to use?
>>
>>57395074
Honestly just starting at all and not stopping is good. C# is good if what you learn from is good. C is also a good choice.

C#, Visual Studio. Java, Eclipse or Inteliij. C, install Linux, use a text editor and compile with GCC. Do the same for C++ however once you're comfortable with command line compilation, use Visual Studio too.
>>
>>57394832
I use vim + gcc on loonix, codeblocks with mingw on windows
>>
File: 1468636168036.jpg (10KB, 166x304px) Image search: [Google]
1468636168036.jpg
10KB, 166x304px
>>57391230
>makes fun of someone for being mad
>is actually the most assblasted person in the thread
Thread posts: 326
Thread images: 32


[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.