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

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

Thread replies: 255
Thread images: 25
File: 20-15-50-maxresdefault.jpg (117 KB, 1280x720) Image search: [Google]
20-15-50-maxresdefault.jpg
117 KB, 1280x720
/dpt/ daily programming thread

Fuck weaboos
Previous - >>55100846

What are you working on, /g/?
>>
DELETE THIS!
>>
>>55105007
>Posted before the bump limit
Report this thread.
Do not post in this thread.

Come on, fuckface, it was only at 297. That's not even close.
>>
>>55105037
>Do not post in this thread.
anon...
>>
>>55105037
>>>55105007 (OP)
>>Posted before the bump limit
>Report this thread.
>Do not post in this thread.
>Come on, fuckface, it was only at 297. That's not even close.
Kek
>>
bamp
>>
>>55105007

Why is java disliked by so many people?
>>
>>55105128
animuuuuuuuuuuuuuuuuu
>>
>>55105037
>>
>>55105007
What OS are you programming on /g/?

I'm using Fedora right now on an older laptop.
>>
>>55105142
>using Fedora
with an anime wallpaper?
>>
File: IMG_20160616_204021_HDR.jpg (1 MB, 4160x3120) Image search: [Google]
IMG_20160616_204021_HDR.jpg
1 MB, 4160x3120
>>55105148
Nope.
>>
>>55105142
Lubuntu.

It works pretty well since I do most my work in the terminal anyways.
>>
>>55105142
Ubuntu mate, it runs great on older hardware.
>>
so gee, ready to get your mouth slapped with a big dick again?
>>
>>55105142
Windows 10.

Only have the one pc and I like video games.
>>
>>55105223
Why not dual boot?
>>
Who /java/ here?
Java is the best programming language.
Also, F# is a meme and nobody uses it.
>>
>>55105235
animuuuuuuuuuuuuuuuuu
>>
>>55105234
I'm not mentally ill.
>>
>>55105234
Because I'm only learning java for uni and eclipse works well in windows.

Currently have no reason to dualboot.

>>55105235
First year java student here.
>>
>2 posts hidden
is the j*va pajeet back?
>>
>>55105135
Kek
>>
>>55105142

Ubuntu, actually, on my System76 Kudu laptop. For all the hate it can get, it's a reasonably comfy distro.
>>
>>55105257
>First year java student here.
do you currently like java
>>
>>55105274
Why does Ubuntu even get so much hate?
I love Ubuntu mate, it's a great distro.
>>
what DE are y'all using with ubuntu?
>>
>>55105304
MATE. It's a great, and lightweight, DE.
>>
>>55105235
i'm java but i am jumping ship to c# because there are very little java jobs going round here compared to c#

wat do u pajeets think of this
>>
>>55105290

Can be bloated, there's some spyware you need to disable (I think), Unity is... different, and /g/ likes things that are hard.

>>55105304

Standard Unity right now. Haven't gotten around to ricing or anything yet.
>>
>>55105304
I used Awesome Tiling window manager (with useless gaps of course) with no DE back when I was on linux
>>
>>55105360
>with useless gaps of course
of course, you're mentally ill
>>
what debuggers do you guys use?
im trying out linux devving for the first time, but i absolutely refuse to use the gdb cli
i like gui's thank you very much
>>
>>55105425
hello paje*t
>>
>All of those false flags in the last thread

>>55105430
Visual Studio's debugging features are all I'll ever use.

Going to anything else is like swapping out your luxury sedan for a dirt bike, and I typically drive on well-paved roads, metaphorically speaking.
>>
>>55105290
Because Canonical likes to reinvent the wheel just for the fuck of doing it diffferently than everyone else and because Ubuntu is the de facto Linux gateway distro so it's usually riddled with newbies that ask a lot of pointless questions because they can't RTFM but sooner or later people using Ubuntu realize that it doesn't really feel any niche and migrate over to better alternative and then act superior to people that still use Ubuntu and so on and so forth (by better alternatives I mean stuff like rolling release distros for desktop and CentOS/Debian/RHEL/SUSE for servers).
>>
>>55105430
gdb -tui
>>
>>55105490
Holy shit.
>>
>>55105490
>RTFM
spotted the virgin
>>
>>55105514
Not this guy but I had no idea this existed thank you so much
>>
>>55105541
you're welcome
this might also interest you: http://darkdust.net/files/GDB%20Cheat%20Sheet.pdf
>>
>>55105430

gdb or good old printf debugging.
>>
>>55105007
>>
>set up my first server
>hundreds of failed login attempts in a day

fucking chinese people
>>
>>55105648
Idgi
>>
>>55105257
>java student
is your program seriosuly called "java"?

    static boolean isOdd(int n){
boolean [] truthTable = new boolean [n+1];
boolean previousEven = false;
for (boolean i: truthTable){
previousEven = (previousEven) ? false : true;
}
return !previousEven;
}
>>
>>55105825
you should have done that recursive
>>
>>55105859
>he fell for the recursion meme
>>
>>55105825
u r a bad person
>>
File: surem8.png (131 KB, 329x281) Image search: [Google]
surem8.png
131 KB, 329x281
>>55105873
>he still can't into it
>>
Does anyone know if VC++ merges identical string literals?
>>
>>55105946
Why do you care? If it's a concern to you, place all your strings as (static) variables at the top your module.
>>
>>55105891
enjoy your bloated stacks
>>
>>55105971
const std::set<const char*> x = { "A", "B", "C" };
>>
I need to tie some key press combinations on Windows to an ios app. Like a remote.

How would /g/ start building such a thing?
>>
>>55105486
gdb has all the features that VS has
>>
>>55106049
Edit and continue?
>>
from time import sleep
from copy import copy
from math import sin, cos
W = 32
H = 30
grid = [0] * (W * H)
ts = 0
def pixel (x, y, p):
if 0 <= x < W and 0 <= y < H:
i = x + y * W
grid[i] = max(grid[i], p)
def clear ():
global grid
grid = [0] * (W * H)
def present ():
global ts
ts += 1
q = str(ts) + "\n"
for i in range(H):
q += " ".join(map(lambda x:".#o"[x], grid[i * W:i * W + W]))
q += "\n"
print(q)
def line (x1, y1, x2, y2):
dx = x2 - x1
dy = y2 - y1
pixel(x1,y1,2)
pixel(x2,y2,2)
if abs(dx) > abs(dy):
if dx < 0:
return line(x2,y2,x1,y1)
for i in range(dx + 1):
x = x1 + i
y = y1 + i * dy // dx
pixel(x, y, 1)
else:
if dy < 0:
return line(x2,y2,x1,y1)
for i in range(dy + 1):
x = x1 + i * dx // dy
y = y1 + i
pixel(x, y, 1)
def project3d (pt):
x,y,z = pt
w = 20 / z
x2 = x * w + W / 2
y2 = y * w + H / 2
return int(x2), int(y2)
def poly (n, pts):
for i in range(n):
x1,y1 = pts[i]
x2,y2 = pts[(i+1)%n]
line(x1, y1, x2, y2)
x = 0#0
z = 13#13
y = 4#4
w = 7#7
theta=0
dong1=True
dong2=5
while True:
if dong1 == True:
z = z-1
dong2 = dong2 + 1
if dong2==6:
dong1 = dong1 - 1
elif dong1 == False:
z = z+1
dong2 = dong2 - 1
if dong2==-10:
dong1 = dong1 + 1
dx,dz = cos(theta) * w, sin(theta) * w
corners2d = [(x+dx,z+dz),(x-dz,z+dx),(x-dx,z-dz),(x+dz,z-dx)]
top,bot = [],[]
for x0,z0 in corners2d:
top.append((x0,-y,z0))
bot.append((x0,y,z0))
clear()
poly(4, list(map(project3d,bot)))
poly(4, list(map(project3d,top)))
for (a,b) in zip(top,bot):
x1,y1 = project3d(a)
x2,y2 = project3d(b)
line(x1,y1,x2,y2)
present()
theta += .1
sleep(1)
>>
>>55106064
I've never heard about that, but reading about it now, yes, you can do that.
>>
>>55106072
Ooops change the sleep(1) to sleep(0.1)
>>
>>55106072
Noice, but I think 1s delay is too much 0.1-0.2 looks way better.
>>
Does having an array of pointers cause a lot of cache misses?
>>
>>55106168
It depends, but it probably will.
>>
>>55106154
Yea I accidently fucked up
and I would like to not take credit for 90% of this code wich is made by other anon
>>
>>55106168
Depends on how the memory the pointers are pointing to was allocated.
>>
>>55106183
Would it though?
Would the CPU do a check on every pointer to check it's in a cache line even though there are 2^32 or 2^64 possibilities?
>>
>>55105304
Openbox.
>>
>>55105037
Newfag here. What's the big deal with making new threads before bump limit? Anyone can post in either one right?
>>
>>55105161
Why not just screenshot?
>>
>>55106465
dont ask
its just a bunch of faggots arguing about completely inane shit
>>
Just got a new computer and I need programming software.
Gonna reinstall the basic Eclipse and shit, what else is there? Don't care about the language, just give me all coding programs.
>>
>>55106465
It splits the thread and encourages posting new threads earlier, also encourages posting multiple threads and posting threads because you don't like the image
>>
>>55105486
Same. Only reason I even have visual studio is the debugger.
>>
>>55106465
You get faggots (like OP for example), who will post their stupid forced memes or other garbage, and then you get competition from a whole bunch of other faggots, leading to threads being made earlier and earlier.
Having two threads up at the same time is not a good thing, wastes board space, and leads to confusion about what thread is supposed to be posted in.
Also, pre-posted threads, and threads with anything (besides the standard /dpt/ template) are rife with shitposting.
>>
>>55106049
I highly doubt this.

Performance profiling, milliseconds between steps, and you can drag back to a specific point in your code and re-run a statement.

Watch lists, locals, autos (with neat things like telling you the result of a function, even if it's not assigned to a variable), stepping into enumerables, etc.
>>
>>55106534
>neat things like telling you the result of a function, even if it's not assigned to a variable
exactly. In gdb I can't even check the size of a c++ vector without assigning it to something.
>>
File: 2016-06-16_08-28-42.webm (269 KB, 426x300) Image search: [Google]
2016-06-16_08-28-42.webm
269 KB, 426x300
>>55106534
Here's an example of drag-and-drop debugging.

Basically, you can just drag the current execution indicator to a line and go back and run it again and try different values for testing, no recompilation needed.

The 'autos' tab is an automatic window that tracks all variables in the current scope.
>>
>>55106596
>autos
Locals*

Autos tracks the last couple of statements, while locals is the entire current scope.
>>
>>55106534
>Performance profiling, milliseconds between steps
That's not a task of a debugger.
>you can drag back to a specific point in your code and re-run a statement.
>Watch lists, locals, autos (with neat things like telling you the result of a function, even if it's not assigned to a variable), stepping into enumerables, etc.
You can do all that.
>>
>>55106596
>step back n statements
>change values on stack/heap/register
>run

Drag-and-dropâ„¢
>>
>>55106679
>what are non-bijective functions
>>
>>55106640
>You can do all that.
GDB does not have all of these features, and some of the implementations are not even close to being as user-friendly.

Some additional things include conditional breakpoints, and breakpoints that do things, such as write to console. You can also have a breakpoint count how many times it had its dick tickled without polluting your code with a counter.
>>
>>55106704
>they are in gdb because its not user friendly enough for me

okay lad
>>
>>55106704
>not even close to being as user-friendly
Subjective.
>conditional breakpoints
>breakpoint count how many times it had its dick tickled without polluting your code with a counter.
gdb has that.
>breakpoints that do things, such as write to console
That's not really applicable to CLI.
>>
>>55106704
I think I'm confused. Do you really think gdb doesn't have conditional breakpoints?
>>
>>55106735
>I'm illiterate and misunderstand basic sentences.

>>55106740
Look, GDB is great, and if you don't have access to Visual Studio with your platform, then GDB is a great choice. There's just no reason to use it if you have access to superior debuggers.

>>55106750
I was just listing nice things from the top of my head. I'm aware that GDB has many of these features, but not all of them.
>>
Only bad programmers need debuggers
>>
>>55106827
Hello there, NEET.
>>
>>55106827
Only bad programmers debug
>>
>>55106842
I have a job, your point is moot.
>>
>>55106866
Only bad programmers write code.
>>
>>55106880
Only bad writers program
>>
>>55106887
Only bad programs write.
>>
>>55106797
Whatever floats your shillboat.
>>
>>55106880

I also figured the best way to write a game is to delete kernel code until I get the result I want.
>>
>>55106072

rewrote

from time import sleep
from math import sin, cos

W,H = 32,30
grid,ts = [0] * (W * H),0
def pixel (x, y, p):
if 0 <= x < W and 0 <= y < H:
i = x + y * W
grid[i] = max(grid[i], p)
def clear ():
global grid
grid = [0] * (W * H)
def present ():
global ts
ts += 1
q = str(ts) + "\n"
for i in range(H):
q += " ".join(map(lambda x:".#o"[x], grid[i * W:i * W + W]))
q += "\n"
print(q)
def line (x1, y1, x2, y2):
dx,dy = x2 - x1,y2-y1
pixel(x1,y1,2),pixel(x2,y2,2)
if abs(dx) > abs(dy):
if dx < 0:
return line(x2,y2,x1,y1)
for i in range(dx + 1):
pixel(x1 + i, y1 + i * dy // dx, 1)
else:
if dy < 0:
return line(x2,y2,x1,y1)
for i in range(dy + 1):
pixel(x1 + i * dx // dy, y1 + i, 1)
def project3d (pt):
x,y,z = pt
return int(x * (20/z) + W / 2), int(y * (20/z) + H / 2)
def poly (n, pts):
for i in range(n):
x1,y1 = pts[i]
x2,y2 = pts[(i+1)%n]
line(x1, y1, x2, y2)
x,z,y,w,theta,dong1,dong2 = 0,13,4,7,0,1,5
while 1:
if dong1:
z -= 1
dong2 += 1
if dong2==6:
dong1 -= 1
elif not dong1:
z += 1
dong2 -= 1
if dong2==-10:
dong1 += 1
dx,dz = cos(theta) * w, sin(theta) * w
corners2d = [(x+dx,z+dz),(x-dz,z+dx),(x-dx,z-dz),(x+dz,z-dx)]
top,bot = [],[]
for x0,z0 in corners2d:
top.append((x0,-y,z0))
bot.append((x0,y,z0))
clear()
poly(4,list(map(project3d,bot))),poly(4,list(map(project3d,top)))
for (a,b) in zip(top,bot):
x1,y1 = project3d(a)
x2,y2 = project3d(b)
line(x1,y1,x2,y2)
present()
theta += .1
sleep(0.1)
>>
>>55106952
looks really nice thats amazing.
>>
I download the source code for an ios app and when I open it it has a bunch of errors. I'm guessing this is because it was made on an older version of xcode or swift or whatever. Why are these errors a thing? Surely each update fucks up a load of old apps.

>>55106952
What is this?
>>
I have a retarded question but I didn't find any answer online.

How can I insert an int value in a int field that will add to number already there ? (in a SQL table )
Let's say I have a table human with his name and his age.
I want to add 23 to robert. His age in the table is 50 so I want it to be 73.
>>
>>55107070
SET `age` = `age` + 23
>>
>>55107083
I feel dumb.
Thanks
>>
>>55107070
UPDATE human
SET age = age + 23
WHERE name=robert;


Obviously, this would occur on all humans named robert, so you're better off using a primary key.
>>
If the socialists have their way & raise the minimum wage to $15/hr, I'll definitely be out of a job. The algorithm for my piss-easy job could very easily be written to a cleaning bot of sorts.

int main()
{
bool MessToClean;
for (int i = 0 ; i < 7 ; i++) {
Gun.login(username,password);
for (int i = 0 ; i < 43 ; i++) {
Gun.scan(barcode);
if (MessToClean == True) {
Broom.sweep();
}
else
continue;
}
Gun.ExitWalk();
Head.ContemplateSuicide();
}

}
>>
>>55107207
>True
>== True
>formatting
>i++
>>
>>55107207
>
else
continue;

and I don't get what your jobs, which involves scanning barcodes, brooming around, and prepping a gun could be.
>>
>>55107246
He's obviously in retail.

The 'gun' is a barcode scanner gun.
>>
File: Programming Shelves.png (952 KB, 2100x1400) Image search: [Google]
Programming Shelves.png
952 KB, 2100x1400
>>55106952
>python

>>55107269
Ban assault barcode scanners
>>
>>55107227
>True
My bad. That's supposed to be all lowercase.
>== True
The == is correct. I usually get errors from using one =.
>i++
It's certainly a better way to increment up than writing out "i = i + 1" or "i+=1".

>>55107246
Clean sweep at a supermarket. I literally get paid $10.50/hr to walk around in circles all day & eradicate messes.
>>
>>55107207
Why clean only when there is mess to clean? Just have a robot cleaning 24/7, they're made for that.
>>
>>55107298
instead of
if (condition == true)

just put
if (condition)
>>
>>55107298
If a field evaluates to true, you don't have to compare it to true. Just put the field in the if statement.
>>
>>55107342
>>55107372
Neat. I'll remember that next time, & save a few bytes!
>>
>>55107422
ignore them, make sure you use

((... == true) == true) == true

just in case
>>
>>55107480
i personally prefer to use
if ((((condition == true) && condition != false) && true != false) && false != true))


just in case my computer is infected with demonic souls
>>
File: EEnEMeme008.jpg (396 KB, 960x720) Image search: [Google]
EEnEMeme008.jpg
396 KB, 960x720
>>55107480
>>55107504
You're making fun of me, aren't ya?
>>
>>55107504
What if your condition is null?
>>
>>55107504
I should make that a macro
#define isTrue(condition) if (((((condition) == true) && (condition) != false) && true != false) && false != true))
>>
>>55107518
>that image macro
>>>facebook

>>55107504
roll your own AST instead
>>
>>55107519
go away satan
>>
File: koding_superpowers.jpg (127 KB, 620x360) Image search: [Google]
koding_superpowers.jpg
127 KB, 620x360
>>55107527
Reminds me of that When Girls Kode vs When Boys Code meme... anyone has it? Also bidding for the Today We Kode shell fiasco
>>
>>55105007
>>55107736
R8 mah BoyCode, /g/
#include <assert.h>
#include <math.h>
#include <stdio.h>

int fac(int m) {
return tgammal(m+1);
}

#define N 5

void enum_perm(int n, int k, int perm[]);
void show_perm(int n, int perm[]);
int main() {
int perm[N];
int i, j;

for (i = 1; i <= N; i++) {
for (j = 0; j < fac(i); j++) {
enum_perm(i, j, perm);
show_perm(i, perm);
}
}
}

// put the k'th permutation of the n first naturals into perm
void enum_perm(int n, int k, int perm[]) {
assert(n > 0);
assert(k >= 0);
assert(k < fac(n));

int i, j, r;
for(i = 0; i < n; i++) perm[i] = -1;

for (i = n; i > 0; i--) {
r = k % i;
k /= i;
for(j = 0; ; j++, j %= n) if(perm[j] == -1) if(r-- == 0) break;
perm[j] = i;
}
}
void show_perm(int n, int perm[]) {
assert(n > 0);

int i;
printf("%d", perm[0]);
for(i = 1; i < n; i++) printf(" %d", perm[i]);
printf("\n");
}
>>
>>55107750
>BoyCode
>not a malloc in sight
>>
>>55107810
>thinking maskulinity means unnecessary overallocation
omegadyke spotted
>>
>>55107833
Manual memory allocation is the first step to real manhood
Once you can master that it won't be long before you're writing everything in assembly like a real man does
>>
>>55105983
>he doesn't know about TCO
>>
>>55107856
And what does a man do when there's absolutely no reason to allocate anything? If you were one, you'd have known...
>>
>>55107875
He allocates everything anyway. The stack is for the weak
>>
>>55107895
You know that's gows who are supposed to be irrational, right?
>>
>>55107920
What?
>>
>>55105007

> tfw I should be doing java but I like python
>>
File: trans.jpg (41 KB, 400x367) Image search: [Google]
trans.jpg
41 KB, 400x367
>>55107962
>obsessed with allocating for fear of being weak
>cold-blooded, calm, reasoned, man
pick one you mad butch
>>
Unit tests are boring to write
>>
>>55107298
>The == is correct. I usually get errors from using one =
I'm being a dumbfuck here by thinking I can explain anything (besides, you already know this) but the reason you'd get errors using a single = is because that tries to make MessToClean equal to true rather than checking whether MessToClean is equal to true.

>>55107305
>Why clean only when there is mess to clean?
The alternative would be to run clean 7*43=301 times rather than less than 301 times.

>>55107342
In other languages, the compiler would throw a fit over the omission of == true.
>>
>>55107207
>else continue;

kys
>>
Making a top down shooter in Python and a raspberry pi kernel in rust
>>
>>55106952
>while 1
>>
>>55108127
>raspberry pi kernel in rust
That's pretty cool, how's it coming along?
>>
File: captain_obvious.jpg (66 KB, 1000x562) Image search: [Google]
captain_obvious.jpg
66 KB, 1000x562
>>55108078
>In other languages, the compiler would throw a fit over the omission of == true.
What other languages? None that I know of. Besides, a conditional statement expects a boolean by definition, and
x == True
evaluates to a boolean, so if your compiler complains you're passing a boolean instead of a boolean, you've got bigger things to worry about than code.

>same guy as
else continue;

No really, you're the Captain Obvious of programming practice.
>>
https://github.com/Microsoft/checkedc

this seems pretty neat as a language extension, rather than a separate language as is trending right now.
>>
>>55108078
>In other languages, the compiler would throw a fit over the omission of == true.

Untrue in pretty much all languages I know and then some, if what you have in the condition is a boolean variable.
If it was an integer variable then maybe yes, but at least in C having an integer as the condition is valid.
>>
>>55108204
So it's C with training wheels.

That's actually pretty neat.
>>
>>55108078
>In other languages, the compiler would throw a fit over the omission of == true.

Not unless there's an implicit comparison of some type with booleans, but no implicit cast. No idea why that would ever be a thing.
>>
>>55105007

why does github classify my python project as shell
>>
>>55108267
Why did you label your project as shell?
>>
>>55108267
https://github.com/github/linguist#overrides
>>
File: 142076302352.jpg (83 KB, 540x960) Image search: [Google]
142076302352.jpg
83 KB, 540x960
How did you become interested in programming?

When minecraft was still a thing I found a modpack named Tekkit. It had a mod called ComputerCraft and this basically added programmable computers to the game and you could do various other thing thing with the world objects and so on. You had to learn a minimal Lua for using it.

After a few years I become interested in Computer Science because one of my dad's college at his workplace was a sys admin and I saw him working and it was fascinating.
>>
>>55106196
The cpu does a check on every single memory access, and the cache works kinda like a hashtable where the address is used as a key, dividided into buckets of cache lines.
>>
>>55108336
Ragnarok Online bots
>>
Anons who have dabbled in machine learning/neural networks, what was your first project?


>>55108336
wannabe haxor
truth is I find netsec a bit dry now
>>
>>55108154
Well I just barely started it yesterday. Never used rust before either. The idea is that by the end of summer I'll have something like the commodore 64s basic interpreter.
>>
>>55108336
who are these demen
>>
File: agdq.jpg (77 KB, 933x700) Image search: [Google]
agdq.jpg
77 KB, 933x700
Is not using multiple return statements a good practice? Or is it one of those fanatical OOP "let's sacrifice efficiency and clarity to pretend to be more organized" rules.
>>
>>55108454
No it's not, it's evn required if the task is very procedural, either because the language or the algorithm is. With a lisp, or an expression-based algorithm tho, it makes less sense. Why would it not be? return statements are there for a reason, and early return isn't an antipattern, in case that's what you wanted to hear.
>>
>>55108454
I don't see why it wouldn't. If you got the result you need and don't need to continue with the rest of the function, it's the best way to break out of it.
>>
File: 1465435492402.png (226 KB, 468x345) Image search: [Google]
1465435492402.png
226 KB, 468x345
Learning Julia
Not really liking it as I thought I would.

I converted a little command-line program that gets a word from you, and spits out a randomized string of numbers to be your "password" that I wrote in C++ awhile ago, but although it looks cleaner, and is in less lines, the shit takes forever to start.

on = true


function passwordMaker()

println("password seed: ")
pass = readline()

if pass == "#end\r\n"
!on
quit()
else

for i = 1:length(pass)
print(rand(1:126))
end

println(" ")

end

end


while on

@time @fastmath passwordMaker()

end

Maybe i'm just not optimizing correctly.
>>
>>55108454
It's retarded. Consider:

if (muhPenis.isTheBiggest()) {
return muhPenis;
} else {
return worldsBiggestPenis;
}


Compared to:

Penis returnValue = null;
if (muhPenis.isTheBiggest()) {
returnValue = muhPenis;
} else {
returnValue = worldsBiggestPenis;
}
return returnValue;
>>
import Adafruit_BBIO.GPIO as GPIO
from time import sleep

tB = "P9_11"
bB = "P9_13"
GPIO.setup(tB, GPIO.IN)
GPIO.setup(bB, GPIO.IN)
while(1):
if GPIO.input(tB):
print "Top button has been pressed"
if GPIO.input(bB):
print "Bottom button has ben pressed"
sleep(0.2)
print "Exited the loop"
GPIO.cleanup()

trying to get my beaglebone black to read the values of two push button switches but it seem not even to be reading the push buttons and is always on.
>>
What do you functional guys think of this?
https://youtu.be/E8I19uA-wGY
As someone who didn't really have a good grasp on functional programming, this video really cleared up a whole lot for me.
>>
>>55108500
What about putting return statements in nested loops?
>>
>>55108493

Julia isn't generally designed for utilities like that. It's optimized for longer-running computations and modeling, where a slightly longer startup time is not such a big issue. IIRC the language's creators are aware of the issue and are working on it anyway.
>>
File: End it all.jpg (76 KB, 642x525) Image search: [Google]
End it all.jpg
76 KB, 642x525
>>55108160
>>55108212
>>55108263
>In other languages, the compiler would throw a fit over the omission of == true
>Untrue
>If it was an integer variable then maybe yes
Ah. That was probably what I read. Never mind. Sorry.

>same guy as
else continue;

I may be Captain Obvious but I'm not that guy.
I'm a beginner, read a For Dummies on Java and C++ and I wanted some advice on what books to buy for further reading.
For some reason, I prefer tangible things in my hands (and by my bedside for some midnight reading) rather than a pdf on my harddrive.
>>
>>55108418
If i tell you will I die?
>>
Is using break; and continue; outside of switches really as bad as I'm being told?
>>
>>55108608
no
>>
>>55108608
Why would you do that?
>>
>>55108576
>I may be Captain Obvious but I'm not that guy.
Nevermind. It's still interesting to explore the implications of truism tho.
x == true
rings differently in a dynamically typed language than it does in a static one.
>>
>>55108517
Do you have pulldowns on the input pins?
This is difficult to troubleshoot without seeing your setup.
>>
How to make unit tests less boring to write?
>>
>>55108608
Who told you that? No you're not wrong baby. Here, here, I'll hug you till you don't cry
>>
>>55108608
it is if you don't know the alternative (it's simple yes but you should know it and you'll need to do it anyway when you want to break out of nested loops)
>>
>>55108640
-Automate the boring stuff
Templates, yasnippet shit; a good framework that abstracts away repetitive crap, etc.
-Write more synthetic tests
>>
>>55105007
I'm at work and literally nothing is happening.
I'm just monitoring and reading various shit
>>
>>55108749
Congratulations, faggot.

Welcome to most tech jobs.
>>
>>55108749
That's my dream. Do you at least have to pretend to work?
>>
http://pastebin.com/zJ4upD2i

So I'm trying to create a simple way of mapping a key to a value in C using a linked list, and I've ran into the weirdest issue I've ever seen.

My problem is that when I try to print the value of "BAR" it doesn't work, I just get 0. This is obviously a problem with add_value, right? Maybe. It seems that the 'else' part of the function gets run but somehow doesn't work. So I tried just "recreating" the function underneath the first add_value call and it worked, but somehow it doesn't work if you use the function.

I know I'm not explaining it very well, but if you run the program and read the code I'm sure you'll understand.

I also know I may not get much help with this, but this seems like a very weird issue.

Also, please try to ignore my shitty comments, they were just me writing so that I force myself to understand it better
>>
>>55108749
Same here, friend, though fortunately I'm telecommuting. I'm currently waiting for our database to process a batch of about a million inbound records.
>>
>>55108749
Create a bug
Then fix it

Repeat until eyestrain happens.
>>
>>55108524
It's fine. That doesn't mean a few zealots won't complain about it, but it's fine.

The real issue is long methods. If your methods are short, an early return isn't so easily missed.
>>
Let's say I have a vector with n instaces of a class, or simply any object that can't be represented with a number. How would I generate combinations of K elements of that vector? So far I've generated combinations of indexes and then simply extracted thise elements out if the vector.

I'm working in c++.
>>
>>55108758
I'd assume so
I'm hoping someone gets a virus so that I can download it and analyze it. That's always fun.
>>55108773
Not really. I'm with two other guys from my team and they didn't give a fuck if I slack off as long as there's actually no work to do.
>>
>>55108831
https://en.wikipedia.org/wiki/Heap%27s_algorithm
>>
https://github.com/deeepaaa/hachidori
>>
>>55108817
This is why my returns are highlighted in hot pink so there is no confusion.
>>
File: ANSI_logo.jpg (9 KB, 360x213) Image search: [Google]
ANSI_logo.jpg
9 KB, 360x213
Friendly reminder that you should only use ANSI standard languages.
>>
>>55108893
>not ISO
>>
>>55108875
How are you supposed to tell at-a-glance what datatype a javascript function returns?
>>
So I finally decided to write a game.
All I know is that it will be some sort of a 2d platformer.
I'm using java, lwjgl, box2d and twl.
My experimental branch is 33 commits ahead of master and looks like it will take even more to get rid of all the spaghetti code before pulling.
>inb4 inane comments.
>>
>>55108790
Go do something else and you'll find the answer.
>>
>>55108944
What are you trying to say with your post?
>>
Fuck unit tests desu
>>
>>55108943
See if you can guess by looking at the return value or hope the author left a comment
Javascript's dynamic typing makes deobfuscating that shit a bitch
>>
>>55105007
where do you think that guy is now?
>>
>>55108987
God damn.
>>
Hey guys, I'm trying to make an app for Android TV that's really image heavy, but when I load large images, they don't load on the app or I get a OOM error on the emulator.
All the advice for online Android is "scale your images to fit the screen " but my screen is a TV, they should be HD sized, right?
What do?
>>
What is an application or program that people need? I want to make something but I don't want it to be, well, pointless.
>>
>>55109034
>that people need
What do you need? Odds are you aren't alone.
>>
File: 1392431883713.jpg (18 KB, 180x195) Image search: [Google]
1392431883713.jpg
18 KB, 180x195
>>55108944
SDL, SFML, GameMaker.
I don't know. The furthest I ever got with anything was a shitty ASCII thing that moves around the console at 1fps.
>>
>>55109034
Your life is already pointless you won't even succeed writing a useable program you ignorant fuck.

What's with all these stupid questions?
>>
>>55109034
I'd tell you but I'm working on one such program right now and want to use it as a portfolio :^)
>>
>>55109063
>>55108944
Samefag
>>
>>55109034
HA like I'm gonna give some NERD my EPIC business idea

Idiot.
>>
>>55109034
Can you write me a frame work for a porn game?
>>
>>55108336
Always been around computers and thought telling them what to do was cool. Learning C through K&R but it is rough because I am not a student of it rn and also don't understand many exercises *sigh*
>>
Is anyone good enough in problem solving?
I am right now trying to decode a message and have fed it into my character counter.
So far I have 1409 letters in the message and the count of letters in the alphabet is 26.
This is what I have so far:
I 110 7.806
L 100 7.097
E 97 6.884
V 96 6.813
R 87 6.175
Y 71 5.039
S 67 4.755
H 64
W 61
O 59
X 56
M 54
T 52
K 51
Z 50
C 45
U 37
J 35
P 34
N 34
B 31
D 30
G 29
A 28
Q 22
F 9

Unfortunately, I am not so sure about calculating the frequency of these letters.
I know that it is a simple percentage calculation, but I am not so sure if I divide the amount of letters by 26(Alphabet), or the length of the letter without the spaces (1409).

The decoded message should be in old german, so most decrypting sites I am won't help me.
And I actually want to solve it on my own.... But I am a bit dumbfounded.
>>
>>55109079
i usually go to other's people portfolio and copy their ideas to mine.

pray i don't see yours.
>>
>>55109114
divide by 1409

t. anon
>>
>>55108636
yeah got em. reason I think it's the code is because I straight up pulled the leads out to the breadboard and it acted the same. kept giving 1 to GPIO.input(tB) and GPIO.input(bB).
>>
>>55109114
What >>55109150 said.
If you want a shortcut in deciding what to divide it by, remember that percentages are between 0 and 1 so all your answers should be between 0 and 1.
Dividing by 26, you're going to get numbers bigger than 1.
>>
C source code on github I'm reading right now has this:

void init(int _argc, char** _argv) BX_OVERRIDE
{
// ...
}


What is that BX_OVERRIDE?

I've never seen something like this in C/C++.

https://github.com/bkaradzic/bgfx/blob/master/examples/01-cubes/cubes.cpp
>>
>>55108874
That's neat, I think I remember that from algorithm courses. but that one permutes a given set of elements. I was talking about combinations, all possible combinations of 3 out of 10 elements and so on.
>>
>>55109123
I'm pretty sure my project is out of your scope so it's okay.
>>
>>55109182
I'm guessing it's a macro for the override C++ keyword that's been introduced in C++11, this way they can make it compatible with both C++03 and C++11 by either defining or leaving the macro empty.
>>
>>55108790
Your GetLinkedListLength() is wrong, if you only have a root node, it will return 0 (true length is 1). If you have a root node and one node linked to that ("FOO" and "BAR"), it's going to return 1 (true length is 2). Then in get_value the for loop will look like
for (int i = 0; i < 1; ++i)

which will only run one iteration, only reaching "FOO" node and returning 0.
>>
>>55109278
Fuck, it's always the retarded little mistakes that confuse me the most.

I actually used this linked list in another program and I fixed that mistake, but I must have forgot to fix it in this project.

Thanks for spotting it Anon.
>>
>>55108790
Is this a homework? why are you commenting even most trivial things?
>>
def kek(iteration=0,base="[]",space="  "):
vert = lambda a,b: "".join(l1+l2+chr(10) for l1, l2 in zip(a.splitlines(),b.splitlines()))
while iteration:
base = "".join([reduce(vert,[base]*3),reduce(vert,[base,(space*len(base.splitlines())+chr(10))*(len(base)/2),base]),reduce(vert,[base]*3)])
iteration -= 1
print base


kek(4)
>>
>>55109321
You might consider simply walking the list while comparing the key values instead of calculating the length and getting the value at each index; it adds needless complexity for you and the computer, and indexes with linked lists don't make sense in my opinion as they're not contiguous anyway. Also, off-by-one errors are a bitch.
>>
>>55109360
>why are you commenting even most trivial things?

Is it normal to not be able to read code that is like this? The
>comment
code;
>comment
code;
rattles my brain. It gives me dyslexia.
code; >comment
code; >comment
is much better.
>>
>>55107289
>>python
Idk but python is one of the best language out there its up next to c, lisp, haskell and languages like that go back to your stupid ass java code nerd
>>
>>55109409
that results in really long lines tho
>>
>>55108963
>>>55108944 (You)
>What are you trying to say with your post?
Well.. did I misread the "what are you working on" question in the OP?
Looks like level of autism is insufficient to understand the true meaning of the sentence.
>>
I'm starting to learn how to program, is learning Python a bad idea?
>>
>>55109438
yes
>>
>>55109437
But who asked? You ask the wrong question!!
>>
>>55109438
not if you want to do cool things very soon
>>
>>55109438
no not at all
python3 is amazing
else try looking at c
>>
>>55109195
oh rite, sorry, my bad. I look at some good old programs I did on this subject... If it's a combination, 1 4 7 and 7 1 4 out of 1 2 3 4 5 6 7 8 9 10 are the same, right? order doesn't matter, so sort your results. Then IMHO, the recursive approach is goat. Maybe you can adapt this old algorithm I did for some semi-school shit in math? I generate combinations with repetitions tho, yours are without. Tell me what you think.
# combination of n distinct elements out of p.
def C(n, p):
return factorial(p)//factorial(p-n)//factorial(n)

# generator function for possible sets of n dice values sorted in increasing order, accompanied with their number of permutations.
def rolls(n):
roll = [1] * n

# We start by setting the first dice to 1, then recurse to generate all the sequences that start with 1, and then on.
# Since our set is in increasing order, that means the next dice has to be either (1) equal to or (2) greater than the first one.
# When we land on the second case, we have just set all the occurences of the current value, allowing us to count them,
# then compute the number of ways in which we could insert them in between the remaining values of the sequence.
# Since these values themselves have different possible orders, we multiply our result with the result downstream.
# i is the current index in roll, p is the current number of combinations in regard to the preceding elements,
# v1 is the value of the preceding element and current starting value, nv1 is the number of v1 we've set sof far.
def rec(i, p, v1, nv1):
if i == n:
yield roll.copy(), p
return

roll[i] = v1
nv1 += 1
yield from rec(i+1, p, v1, nv1)
p *= C(nv1, n - i + nv1)
for v in range(v1+1, 7):
roll[i] = v
yield from rec(i+1, p, v, 0)

for v in range(1,7):
roll[0] = v
yield from rec(1, 1, v, 0)

(I can into C++ btw, it's just that it was easier)
>>
>>55109438
naw python is dope for all kind of stuff
>>
>>55109438
IMO it is better to learn a language where you have to do most things yourself. Python hides everything from the user, C lets you learn exactly what is happening.
>>
>>55109445
>>55109452
What would be better?
Is it difficult to learn other languages after learning Python?
>>
>>55109492
btw maybe scrap the number of permutation computing bits. Also here's tests that assert it kind of looks correct:
# generator function for all the possible dice rolls of length n.
# Order matters: we have 6**n equally probable elements.
def oldrolls(n):
roll = [1] * n

def rec(i):
if i == n:
yield roll.copy()
return

for j in range(1, 7):
roll[i] = j
yield from rec(i + 1)

yield from rec(0)

if __name__ == '__main__':
for i in range(1,10):
rs = list(oldrolls(i))
for r in rs:
r.sort()
for r, n in rolls(i):
assert rs.count(r) == n
>>
>>55109495
I dont think you are right at all.
while python hides it learns the basics and a bit how you should think. if you enjoy doing thing with python you can learn c and use python as scripting language after.

>>55109500
not from my experience
>>
>>55109500
>Is it difficult to learn other languages after learning Python?
yes, it pretty much makes you braindead after you are subjected to python for long periods of time.
>>
>>55109534
I dont think you have tried it yourself. or you are just dumb
>>
>>55109500
not really, you can jump from learning any language to learning any other language, the point is to learn to program and to develop skills, not to learn a specific language, some start with low level and transit to high level, some do the other way around, personally I started with Lua, then transitioned to C++, then back to Python, and nowadays I'm doing reverse engineering and asm mostly and had no problems with each transition despite starting with a high level lang
>>
>>55109500
If you learn python then try to learn c you are basically starting from scratch and you need to relearn everything.

If you learn c then try to learn python you are just discovering all the shortcuts the language has built in and you understand how it all works.
>>
>>55109513
Not 100% sure it progresses compared to what you were doing tho... Maybe "move element 1 into temp vector, recurse, put it back in main vector, loop for elements 2+", or maybe I'm just too tired to know what's going on. Sorry for wasting your time, I'm off now
>>
>>55109652
>>55109513
>>55109492

>Sorry for wasting your time, I'm off now

No problem at all, I'll try and analyze your code later on.
>>
File: 61131.png (62 KB, 750x477) Image search: [Google]
61131.png
62 KB, 750x477
>>55108893
>not ISO/IEC

IEC 61131 ftw
>>
>Have non programming experience
>Understand how computers work fairly well
>Am pretty good at Maths
>Have a pretty awful memory
>Would like to automate tasks on my computer and write some simple apps

Can anyone please recommend a programming language for me to learn?
>>
File: ss+(2016-06-16+at+08.05.16).png (3 KB, 262x157) Image search: [Google]
ss+(2016-06-16+at+08.05.16).png
3 KB, 262x157
I just compiled my Java project into a JAR but when I try to open I get this dialogue. Any idea to what it could relate? My code runs perfectly in the IDE
>>
>>55110013
Python. Cross-platform, beginner friendly, versatile.

also fyi shitposts inbound
>>
>>55110038
Are you trying to run Java GUI application with java.exe or Java console application with javaw.exe?
>>
>>55110082
Nah, its a console app and I try to run it via java.exe
>>
>>55110110
Then I don't know, log the exception I guess? Start it with command line or something.
>>
>>55110123
Ah yeah, forgot that theres a command line. Well it says its a NoClassDefFoundError in the gson library. meh
>>
>>55110048

Some people have been recommending I learn C. What's the advantages of Python over that?
>>
>>55105142
Fedora aswell
>>
>>55110013
C#, hands down. Pretty much any basic automation or task is super easy to do.

Python is also fantastic for this.

Both are cross-platform and open-source, so take your pick.
>>
>>55110174

The syntax of C# looks quite hard to learn. Is this true?
>>
web shitter coming through, try not to get my filth on you as i ask my pleblord question:

node.js question

I'm wondering if I can call a function within the callback associated with a mongodb connection, and successfully have that function interact with the database connection.

E.g.
mongoClient.connect(mongoURL, function(err, db) {
// err handling
var myCollection = db.collection('myCollection');
nestedFunction();

// nestedFunction is declared within the scope of the .connect callback
function nestedFunction() {
// code
// then, a database query
myCollection.find();
}

}


I think it should be alright, provided nestedFunction is declared within the callback scope, right? I've only just moved nestedFunction into the callback, so I'm not entirely sure. I think it solves the issue I expect might happen.
>>
>>55110185
It's easy and beautiful.
>>
>>55110168
>Some people have been recommending I learn C.
Those people are only recommending C first because they were forced to learn C first.

No one learns a comfy high level language and then goes to C and thinks, "Man, I'm so glad I get to worry about managing all this memory!"

>>55110185
No, not at all. If you'd like, you could give me an example of something you'd want to do, and I'll show you what it looks like.

Python's syntax is super easy, too.
>>
>>55110185
C# sucks dick for beginners. It is only faster to code if you've already memorized hundreds of pre-built functions. You are going to be spending most of your time googling shit. It is better to just learn to code it yourself, at least you will learn something.
>>
>>55110206
>It is only faster to code if you've already memorized hundreds of pre-built functions.
That's why it's so much faster.

>How do I get the files in this directory?
>Oh look, a one-line method that I just pass a filepath to, and it gives me everything I need.
>>
>>55110206
A beginner is going to be googling functions for any programming language.

Though C# has the advantage of a fantastic IDE to aid with this.
Thread replies: 255
Thread images: 25

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

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.