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

/dpt/ - Daily Programming Thread

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

Thread replies: 319
Thread images: 34

File: tumtay.jpg (507KB, 742x967px) Image search: [Google]
tumtay.jpg
507KB, 742x967px
>What are you working on, /g/?
>Previous thread >>56228877
>>
File: cs_major_codemonkey.png (125KB, 813x600px) Image search: [Google]
cs_major_codemonkey.png
125KB, 813x600px
>>
What's the best way to make a twitch bot that goes to other channels and comments? I want to avoid using selenium because I don't want them to know its a bot. All of the tutorials I find are how to make a bot for your own channel.
>>
>>56233219
.jar
>>
>>56233219
We're not gonna tell you how to to create a spam bot, pajeet.
>>
tfw just posted my question in ded thread. I hope no one minds a quick reposting.

Whats a good set of tools(meaning languages and actual tools as well) that could be used for making a text based game that can be played from a web browser?

I've never done web-dev, and as far as I know you generally have web based front end and some sort of back end that does stuff. I'm not entirely sure what front end and back end mean.

I'm not making an mmo. Having a web based game just seems more convenient for getting people to try it and for handling text output than dealing with various multiplatform console windows/commands.
>>
>>56233236
Don't want to spam, I just wanted to do it for learning purposes. I am going to make it so anytime someone types !aaron, it says "That's me" thats it.
>>
>>56233242
php, js, html(5), ruby, etc
>>
>You will never construct a computer virus for an alien architecture to tear down their shields for a couple of minutes while your buddies down on Earth blow their space craft into smithereens
>>
>>56233333
obey the quints!
>>
>>56233126
Holy shit, I'd plug my Ethernet cable into my Networking professor's port if you catch my drift
>>
>>56233268
You mean plugging the male part into the female part?
>>
>>56233242

Basically the entire fucking thing should be in JavaScript.
>>
>>56233276
Yes
>>
rolling for quints

obey my order: make app that calls the user's mom at 3 am and plays a sound file saying help me, im lost
>>
>>56233242
You could do it ALL in CGI. This means you can do it in nearly any language. But, after every choice the user makes, they'd be seeing a new webpage, rather than the current webpage updating.
>>
>>56233292
too soon, loser
>>
Quints for D
>>
>>56233268

My old networking professor:
https://cse.wwu.edu/computer-science/meehan

(Picture is slightly old. He has a bit of a beard now).
>>
i wanna sex you up
>>
>>56233249
>>56233219
Forgot to mention, I am doing this in python
>>
>>56233333
let's go baby!
>>
>>56233333
Let's do it, I'd load my program into your memory
>>
>>56233333
what a faggoty ass quint
>>
>>56233350
ok, it'll be tight though
hope your hard drive can handle my software
>>
>>56233278
Alright, I guess I'll learn Javascript then. I've never actually made a website before so this might be fun.

>>56233301
I'm thinking far more actual RPG than visual novel or text adventure.
>>
>>56233369
Like a rogue-like?
>>
>>56233370
nah, if what you mean is a ascii-grid style movement anyways.

I'm more thinking like an index of menus, one might be objects in the room with each object having a index tag so you can type the index tag to bring up the menu for that object that would list the basic info, and then have its own command sections that would be available to every object such as search, pick up, push, pull etc.

I'm not a fan of text games where you enter "pick up paperclip" I'd rather have everything be seperated into "a" -> "4" -> "1" for the example of navigating 3 menus.

The combat would be JRPG style in regards to the display/input.
>>
Can someone help me understand the list slicing going on here?

def rotate(arr, n):
n = n % len(arr)
return arr[-n:] + arr[:-n]


It takes a list [1,2,3,4,5] and rotates it n times. [5,1,2,3,4] for +1, [2,3,4,5,1] for -1. I understand n = n % len(arr) is there for when n exceeds the length.

I achieved the same thing but it was using for loops and if/else. Much slower.
>>
failing at the proper terms to search google
but what i'm looking for a list of IDEs/ scripting programs which use a dark background (eye issues) and which languages they are used for
>>
>>56233153

I don't hate these kind of people. I just feel bad for them.
>>
>>56233510
Any reasonable terminal emulator can change colors.
>>
>>56233484
nvm, I realize its the last index to the end, so just the last index/indices, and then the beginning up to the last index/indices
>>
>>56233510

Most IDEs and Text Editors have a choice of color schemes.
>>
>>56233551
Yeah, negative indexes in python are counted from the end of the list starting at -1 like [-n,...,-3,-2,-1]
>>
>tfw working on a project with a 2 hour build time
suffering
>>
>>56233609
what are you working on?
>>
>>56233617
Enterprise shit
>>
>>56233609
If it's C++ your company might consider modulating the project into dynamic libraries, so instead of having everything in a single project you'd have separate modules for audio, physics, networking etc, then the engine would load what it needs, this way you only need to rebuild one module at a time.
>>
>>56233776
or even just write a decent makefile
>>
def dogman(arf):
for i in arf:
print(i.doggerino)
>>
https://codeshare.io/Y6UKd

is this thread different?
>>
>>56233609
>having a 1 million lines code in one file
>>
>>56233983
Lucky you~
I've been contracted to work on a C++ codebase with about 100 smaller ~1k line files and two ~200k line files where almost all the real code is. Why "only" 200k? Because the proprietary compiler shits itself when even one more line is added, AND they don't appear to think it's serious enough to do the smart thing in refactoring it into properly composed smaller files.
>>
>>56234067
>refactoring a 200k line file
I wouldn't do that under gunpoint.
>>
>>56233126
Writing a metadata scraper for FLIF files in Racket. Of course, it's largely theoretical since the metadata scheme isn't locked in yet and nothing actually writes metadata to FLIF files...
>>
>>56234225
most ides will automatically extract a function or class to a new file
>>
Anyone using Open Frameworks?
>>
>>56234424
Oh yeah, I also use Free Components and Public Domain Elements.
>>
How do I make learning programming more fun, /g/?
>>
>>56234511
make things that are fun to make
>>
>>56234523
But games are too advanced for me (for now).
>>
>>56234438
>Free Components

What kind of stuff are you using it for? I have a small project in mind, and am thinking of using it over Unity. Recommended?
>>
So apparently ElementTree in Python chokes on such line:
<something attr="<blah>"/>


I think it tries to parse the <blah> string as another tag.
>>
She looks like she would be really easy to creep out like i think just walking uo to her and sniffing the small of her back would get her all agitated
>>
>>56234511
learn the basics of a language(hopefully C) and then transition quickly to visual things like windows. I found it to be a lot more fun once I could see my work being displayed outside of the terminal. that's just me though.
>>
>>56234533
No they aren't
>>
>>56234533
tic tac toe is too advanced?
>>
>>56233510
Vim + solararized plugin... have fun! :)
>>
>>56234511
do it with friends
>>
A simple math tutor program

#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;

int main()
{
int rand1, rand2, total, answer, seed;
seed = time(0);
srand(seed);

rand1 = 1 + rand() % 1000;
rand2 = 1 + rand() % 1000;

total = rand1 + rand2;

cout << rand1 << endl << rand2 << endl << "+\n"
<< "____";
cout << "\nWhat is the answer?\n";
cin >> answer;

if (answer == total)
cout << "That is correct!";
else
cout << "Try again.";

return 0;
}
>>
>>56234593
Cute!
>>
File: 1428677825239.jpg (101KB, 426x640px) Image search: [Google]
1428677825239.jpg
101KB, 426x640px
>>56233126
Tay Tay uses Macs you autist.
>>
I posted this function a few days ago.

//Assumes ASCII and C-style string
char* get_extension(char* &str, int &len_ret) {
char* ext_pos = nullptr;
int length = strlen(str);
auto read_pos = length;
while (read_pos > 0) {
--read_pos;
if (str[read_pos] == '.') {
++read_pos;
len_ret = length - read_pos;
ext_pos = &str[read_pos];
break;
}
if (str[read_pos] == '\\' || str[read_pos] == '/')
break;
}
return ext_pos;
}


>&len_ret
What do you tend to do when a function ideally returns multiple things? std::pair is ugly and I'm not sure about the comparative speed of a struct, even for only two elements.
>>
>>56234566
>plugin
>for font colors
>>
>>56234554
>(hopefully C)
Why so? I'm learning Java cause it seems like the easy language

>>56234564
Well I guess I could do those simple games as a start.

>>56234585
My friends are not that interested in programming at all.
>>
>>56234630
Well, structs & pairs are your only choice here, really, you can make it slightly cleaner by doing this:

typedef std::pair<char *, int> ExtRet;

//Assumes ASCII and C-style string
ExtRet get_extension(char* &str) {
char* ext_pos = nullptr;
int length = strlen(str);
int len_ret = 0;
auto read_pos = length;
while (read_pos > 0) {
--read_pos;
if (str[read_pos] == '.') {
++read_pos;
len_ret = length - read_pos;
ext_pos = &str[read_pos];
break;
}
if (str[read_pos] == '\\' || str[read_pos] == '/')
break;
}
return {ext_pos, len_ret};
}
>>
I want to get good at C++. Any resources or projects/exercises that are good for this? Thanks.
>>
>>56234641
>Why so? I'm learning Java cause it seems like the easy language
Java doesn't push you, nor easily afford the means, to understand how the machine actually tends to work.

It also allocates variables on the heap, which is horrible for locality and tends to ensure consistent cache misses. Use interpreted languages for what they're actually good for, don't fall into a mode where you're trying to use them for everything (or think you should).

Really should start with C. And also read:
https://people.freebsd.org/~lstewart/articles/cpumemory.pdf
>>
>>56234628
but she codes in Java, so deploys on everything
>>
>>56234630
std::tuple and std::tie make it look alright.
>>
>>56234628
>Tay Tay
she has no such thing
>>
I'm doing babbys first hardware.

So I'm trying to control the speed of a motor by writing a number to a file/register/something. Via the command line, its done like this.

 
~/../..# echo [a number] > [the file]
~/../..# echo [another number] > [the file]
~/../..# echo [some other number] > [the file]


I want to write a program in C that will open this file, write a number to it (based on some sort of generating function or maybe user input), and close the file. I have basic implementation of this in pic related, but I don't know if this is the "proper" way to go about it. Any suggestions?
>>
>>56234696
It's a really good paper. I wonder how out of date some of the benchmarks are. Especially, with the advent of avx, and I'm sure prefetching is more aggressive because of it.
>>
File: Screenshot (1).png (21KB, 798x248px) Image search: [Google]
Screenshot (1).png
21KB, 798x248px
setting up a CHEAP laptop for my nephew to use to learn/practice coding.

starting with scratch, app-inventor2, java
anything else i should pre-install for him?
IDE(s), practice programs, bookmarks to resources, documentation, videos

(uninstalling all games to keep him focused)

>inb4 gentoo
>>
>>56234511
You have fun with what you learn.
If you just read a chapter on something, make a small project where you use that.
Like if you just learned about linked lists.
Then you could make a game that is a visual representation of a linked list (snake).
You can do that with almost anything although some subjects take more time to implement.
This is when you use libraries.
>>
>>56234889
you do realize you're buying him a porn machine right
>>
>>56234665
>>56234743
Hm. I guess I'll probably have to do something like this.

Are there any functional differences between the struct and pair approach?
>>
>>56234909
his parents have some christian porn site blocker router
>>
>>56234919
One is anonymous. Runtime representation will be identical.
>>
>>56234889
arch with vim and linaro armv8 assembler and qemu emulator
that's all he needs
>>
>>56234951
i'm not gonna force him to learn loonix before getting an idea of how to prgram
>>
File: oh noes.jpg (99KB, 784x810px) Image search: [Google]
oh noes.jpg
99KB, 784x810px
I spent 3 hours trying to track down a bug and the solution didn't hit me until i tried to work out the faulty code on paper

i was using memmove using strlen as the n bytes and trashing allocated memory
>>
OK is there a way around this issue?
I don't really understand why it is throwing an error

variable=2
def func():
print(variable)#<--does not cause an error, as variable is already declared outside the function
if variable==2:
variable=1
print(variable)
variable=3#<--causes an error three lines above for referencing variable before declaration
func()
>>
>>56234972
Should've bought him an arduino kit.

Kids love the physical shit, programming takes motivation and real knowledge to persevere with because it's all abstract, having some physical stuff to go along with it would make it far more likely he'll stick with it.

Depends on how old he is though, when you're a little older you can understand and appreciate the whole thing as opposed to just the end product.
>>
>>56233333
You'll have to now with numbers like that!
>>
>>56235075
Nice blog, where can I subscribe?
>>
Working on my pajeet game on ARM64 assembly
Adding a level where he fights evil westerns trying to force him to sit in loo
>>
>>56235119
>/dpt/
>What are you working on, /g/?

Could you please fuck off and find some other place to shitpost?
>>
>>56235105
age 15, into vidya, marvel/dc
wants to make some games
>>
>>56235132

Care to share your source?
>>
>>56235144
Games is hard, Unity is probably the best option for a complete beginner but even that requires a decent amount of motivation to push through because of the vast workload involved.

If he's mature enough that he can accept it'll take a long while to be competent and even longer to produce anything then he should be aight. But vidya dev is a real serious pain in the ass, especially solo.
>>
>>56235119
boy you probably were the kid sticking pins in sockets in primary
>>
>>56235168
must kindly provide 30% upfront
will do great work Sir...
but seriously, gonna post github when finished
>>
>>56234930
If he's destined to be a coder, he'll get around a silly site blocker.
>>
>>56235170
told him to start simple
like pong or something
one video series shows how to make Breakout game, i think he'll dig that as a beginner project.
>>
Hey guys python fag here. You guys keep shitting on python so I want to learn a better language. Do you guys have a language that you recommend
>>
>>56235200
The second you hit that first "oh shit what if I did this" moment you're away.

I imagine most every programmer had that when first learning, no matter the language or the project.
>>
>>56235196
eventually, yeah. but he's quite sheltered right now. very obedient. wants to do the right thing. literal boy scout.
>>
>>56235196
Routers have default passwords. Don't deprive the kid. God knows they'll never let him get near a real girl.
>>
>>56235229
they trying to set him up with some cute church chick
>>
>>56233219
If you're not wanting to use a browser to interact with Twitch, chat is accessible via IRC.
>>
>>56235096
As I recall, in Python if you wish to read the value of a global variable, you can just use the variables name ("variable", in your case)
However if you wish to update its value, you'll need to declare the use of that global variable beforehand
variable=2

def just_reading_a_global():
print(variable)

def updating_a_global():
global variable
print(variable)
if variable==2:
variable = 1
print(variable)
variable = 3

just_reading_a_global()
updating_a_global()
just_reading_a_global()


I'm not sure if there are any further in depth nuances to this
>>
How do I prevent HTML injection in my cgi scripts?
>>
>>56235276
Why are you doing cgi?
>>
>>56235203
no
my lang > ur lang
>>
>>56235301
What
>>
>>56235293
why not?
>>
add : (x : Nat) -> (y : Nat) -> {auto smaller : LT x y} -> Nat
add x y = x + y

cool
>>
>>56235323
What's the point of forcing x<y?
>>
>>56235315
people telling you "x is bad" are just sitting here shitposting
don't listen to autists on an anime imageboard, fuck off and focus on learning something
>>
>>56233219
chat is basically irc
>>
>>56235244
Well fuck. I wish my parents gave a shit about my love life.
>>
>>56235334
just an example of what is available for compile time
>>
>>56235356
What language? The auto in the implicit argument is new to me.
>>
>>56235336
Uh alright although I do agree with the limitations of python as a scripting language
>>
>>56233219
make your own framework
>>
>>56235275
thank you, that was helpful

so basically every time you update a variable inside a function that you would like to use in another function you should declare it global before updating or referencing it

Then you are free to declare it wherever and it should persist
>>
>>56233337
I know how to do this, but I'm not going to tell you how to do it because you're just trying to spam

In fact I could make it run when you aren't even online at all
>>
>>56234889
>Windows 10 with 2GB of RA
WHAT HAVE YOU DONE?

>IDES
Dicks out for Visual Studio

But seriously, two giggidy bytes is way too little for Windows 10 to run decently
>>
>>56235276
I would disallow symbols like < and >

Or simply check to see if any strings contain any html tags
>>
>>56235441
i did say cheap didn't i?
bought it for $25 from facebook local
it had win7 on it, took advantage of free upgrade window.
IF he puts the loaner to good use, i may buy and install more RAM
but it's an early gen atom machine
>>
>>56235480
I think windows 7 (or even xp) will run better on a shittop than windows 10

also so you are aware there is really no way to completely block porn, even if the kid is like 13. At that age I certainly had the time and energy to find holes in the parental blocks on computers, even if it meant reformatting the entire system. And of course it's not even a really good thing to block porn for teens, literally no downsides to it
>>
>>56235360
idris
>>
Anyone else feel like they get overwhelmed and fucked in the head when they think about whether to make things types or variables? I know I do.
In one project, I had a type called CharacterType, and it held all instances of a type of character, and anything static to that type, i.e. the characteristics of characters of that type. But, I would create a variable, i.e. HumanType, that is of type CharacterType.

It's not that I'm confused as to what is going on, but to if this is the best way to do things, the implicatoins of a variable being a type, etc.

This is a year-old project, so I'm not looking for refactoring advice or anything like that.

It's just an uncomfortable thing to think about I guess.
>>
what are your favorite programming-related videos, /dpt/

i need something to watch since im really bored right now and i need inspiration, i already watched some of the MIT computer science course ones
>>
File: susan.jpg (85KB, 460x581px) Image search: [Google]
susan.jpg
85KB, 460x581px
how hard would it be to implement this idea?:
buy used server with 4x xeons and 64 GB RAM
have shittops like:
>>56234889
to remote into the server hardware, so that the server does all the heavy shit like compiling, testing, running Android Studio (extremely bulky and resource hog), etc
>>
>>56235649
The issue is that things like classes are often far more than just types.
>>
File: 1412888920685.png (719KB, 850x1000px) Image search: [Google]
1412888920685.png
719KB, 850x1000px
I want to learn something more scientific. Something advanced. Can anyone give me any ideas about some cool areas to study (machine learning, data science, etc.)?
>>
>>56235708
NLP is cool
>>
>>56235708
wear girl clothes and suck cock
>>
>>56235649
No idea what you mean, please post code.
>>
>>56235697
why?
>>
>>56235522
>literally no downsides to it

Except for the rapid decedent into more and more extreme and taboo shit just to get off and guys having erection difficulties now in their 20s.
I think the most important thing though is the kid having a good relationship with at least one of the parents where they can hear the realities of sex even if it's awkward for them so they at least have something to balance out the artificial and dysfunctional black hole of porn and everything else the media industry spends billion of dollars pushing on them.
>>
>>56235734
cuz reasons, of course
>>
File: 5cd.jpg (25KB, 400x462px) Image search: [Google]
5cd.jpg
25KB, 400x462px
threadly reminder that lisp > haskell
>>
>>56235773
incorrect
>>
>>56235748
^this^
look what /b/ has degraded to, so bad that mlp got its own board. now with traps and boipussie
>>
>>56235773
lisp is stuck on the 70s
>>
>>56235748
hey man maybe you can have your descent into depravity, I leveled off at incest and bestiality

>>56235765
servers are supposed to help you manage data on the run or free you from using just one machine, there's not much benefiet from sshing or remoting another computer running something resource-intensive

Although if your mind is set on this get a computer, disable sleeping, and install teamviewer. It's free forever and requires only windows. I don't recommend it though because it's delayed by at least 100 ms and will feel shitty
you're much better off going around with the laptop than getting another one and then remoting into the first
>>
File: 1417567490721.png (360KB, 538x477px) Image search: [Google]
1417567490721.png
360KB, 538x477px
>>56235789
>type declarations
>>
>>56235838
are optional
>>
File: rekt.gif (406KB, 300x231px) Image search: [Google]
rekt.gif
406KB, 300x231px
>>56235869
>optional, noun: something that is required 90% of the time in order for the code to compile
>>
>>56235916
fib :: (Ord a, Num a, Num t) => a -> t
fib n = if n <= 2 then 1 else fib (n-1) + fib (n-2)

fib n = if n <= 2 then 1 else fib (n-1) + fib (n-2)


both compile fine since type declarations are optional and mainly for reading code at a glance AND documentation
>>
File: 1416086957412.png (259KB, 603x356px) Image search: [Google]
1416086957412.png
259KB, 603x356px
>>56235949
So what happens when you write a whole project instead of some contrived example without any type declarations?
>>
>>56235989
it compiles
>>
>>56235989
you don't understand type inference do you
>>
>>56235789
Racket is nice, though.
>>
File: 1416098027729.jpg (380KB, 1438x1080px) Image search: [Google]
1416098027729.jpg
380KB, 1438x1080px
>>56236002
>>56236009
Lel, the wiki even has a whole page documenting the issue

https://wiki.haskell.org/Monomorphism_restriction

Haskellfags on suicide watch
>>
>Eliminate a bunch of superfluous vectors
>Accomplish task far more efficiently
>Binary size goes from 35.5kb to 22.5
Feels pretty okay.
>>
File: 1471826753443.jpg (215KB, 692x554px) Image search: [Google]
1471826753443.jpg
215KB, 692x554px
>>56233242

You're going to be using Javascript and dynamic loading via AJAX for most of that shit. All your info would probably do best in a json file. Backend stuff is for cookies and whatnot so that's generally not as important, since your game would work best as a single page app. Then there's also the issue of working with the HTML5 canvas, since even in a JRPG, unless it's completely text-based like Candy Box, you're going to have to render those elements on the page and doing it all through the DOM is going to kill performance.

Frontend is like what the user can see and manipulate, so the board your posting on right now, how it's styled with CSS, ordered by HTML/Templating, able to do nice things like backlinking via Javascript. Backend is all server side, such as placing images/posts into a database, pagination via queries to said database, and storing/issuing relevant data which is important to the user which (hopefully) the user can't interact with it directly except through the Frontend.

Also, there's always a thread up for webdev, have fun:
>>>/g/wdg
>>
File: OUfPxLJ.gif (4MB, 433x184px) Image search: [Google]
OUfPxLJ.gif
4MB, 433x184px
>>56236178
>superfluous

would you tell us why or how they were redundant?
either way, here's a virtual pat on your back.
>>
In python, I want to make sure the user insert a number (float) and that the program doesn't crash if he inserts something else. Is this the best way to do it?
while True:
try:
H = float(input("Input H: "))
except ValueError:
print("Insert a valid number.")
continue
else:
break
>>
Working on a very basic random sentence generator (Using chains of words) and am having a bit of an issue:

I'm placing all of the words in a map with keys of Queues
Map<Queue<std::string>, Queue<std::string> >


How would I access a particular value of Queues? (Basically, I don't know how to get the key values of the Queues in the map)
>>
>>56235686

Anything from Bisqwit
>>
>>56236291
Exceptions are for CHUMPS!
>>
>>56236321
This isn't very helpful, what do you suggest instead?
>>
(

(type Nat (< Z (S Nat)))

(val + (-> Nat Nat))
(let +
(fn (x) (fn (y)
(match (, x y)
((, n Z) n)
((, n (S m)) (S (+ n m)))))))

)

r8 syntax
>>
>>56236314
yeah, that guy's cool too
>>
>>56236355

Truly awful.
>>
>>56236355
Never, ever, EVER use one letter variables/ function names.

"use-descriptive-names" that explain what everything does. The extra time required to type out your code is negligible compared the massive amount of time you'll save by being able to easily reason about wtf you're programming.
>>
>>56236381
the other syntax mode (which im still making the parser for) is a bit nicer
type Nat = [< Z | S Nat]

val (+) : Nat -> Nat
let (+) x y =
match x, y with
| (n, Z) -> n
| (n, S m) -> S (n + m)
end
>>
>>56236350
Actually looking at it again, I guess it's alright
>>
>>56236494
(

(type Nat (< Zero (Succ Nat)))

(val + (-> Nat Nat))
(let +
(fn (num1) (fn (num2)
(match (, num1 num2)
((, num1 Zero) num1)
((, num1 (Succ num2)) (Succ (+ num1 num2)))))))

)

i should add a limit for identifiers to be a single char just for you
>>
>>56236494
I don't know if you're only talking about lisp or whatever, but one letter variable names are perfectly fine if used correctly.
It's all about context and how much information you can encode into your variable names.
For example, if a function primarily deals with a single type,
void my_function(struct thing *t);

is perfectly acceptable.
>>
>>56236533
when she give you succ
>>
>>56236503

That is much better.
>>
File: 2016-08-23 20-39-06.webm (2MB, 1364x768px) Image search: [Google]
2016-08-23 20-39-06.webm
2MB, 1364x768px
I did it!

http://pastebin.com/JzQHdWpd

You'll need this as august.txt too if you'd like to run it
http://pastebin.com/uSTmcWjS. I could auto-generate it fairly easily but eh
>>
>>56236533
You're only shooting yourself in the foot, man. I've noticed that this is the one thing that I do differently than most other programmers that gives me so much more productivity.

>>56236554
Except, no, that's never acceptable. You will
A.) lose track of what all the symbols mean while programming and introduce bugs
B.) come back to make changes to your code and have no idea what the fuck is going on
C.) have to waste a ton of time writing documentation since you chose to use hieroglyphics instead of descriptions
>>
>>56233126
i got a %20, baby and i'll write your stringName
>>
>>56236603
naming those variables doesn't really make any sense within that context cause they all are just generic numbers. the name of a function is much more important than the name of a variable
>>56236586
yep, i just havent gotten around to finishing that lexer/parser yet so im just working with the s-expression version for now while i test other parts of the compiler
>>
How do I learn how to make Android apps in 6 hours?

This is important.
>>
>>56236658
mit app inventor 2
youtube videos
gumption
>>
>>56236635
Surely those numbers represent something, though, don't they? Name them after what they represent.
>>
File: akari eats chippus2.jpg (215KB, 1000x1000px) Image search: [Google]
akari eats chippus2.jpg
215KB, 1000x1000px
Rate my XSS santizer!
char *xss_sanitize(char *str)
{
unsigned i, j;
for (i = 0; str[i]; i++)
{
if (str[i] == '<')
{
for (j = i; str[j]; j++)
{
if (str[j] == '>')
{
memmove(&str[i], &str[j+1], strlen(&str[j+1])+1);
i--; /* go back one */
break;
}
}
}
}
}
>>
>>56236694
yeah, the number on the left of the + sign and the number on the right side of it
>>
>>56236713
lol was this the program you spent 3 hours on?
>>
>>56236713
I hope you're not going to rely on this/ 10
>>
>>56233239
>for my class
famiglia, sizeof is a C function carried over to C++
You can't "overload" a function that doesn't belong to a class.

And to be more pedantic, sizeof is not a function. It's practically a fuckin' preprocessor directive. Which is why it's impossible to overwrite it.
>>
>>56236603
>Except, no, that's never acceptable.
Again, it's about context.
In the context of that function, t refers to the "thing" which is being worked on.
If something has a large scope, or if the context isn't clear, you'll obviously use a more descriptive name.
It's the exact same reason that using "i" in a for loop is acceptable. In the context of that loop, it's an index/incrementor.
>>
>>56236777
no that was something else
this one took 3 minutes
>>
File: 1470804356900.jpg (256KB, 1280x960px) Image search: [Google]
1470804356900.jpg
256KB, 1280x960px
>>56236713
void xss_sanitize(char* str) {
while(*str != '\0') {
if(*str == '<') {
*str = ' ';
}
str++;
}
}
>>
>>56236823
This doesn't remove the tags tho.
>>
>>56236823
i'd wife her
>>
>>56236832
>her
>>
>>56236832
doesn't really look like wife material imo
then again I'm not in the wife market
>>
>>56236831
Is the function called remove_sgml or xss_sanitize? You fucking donkey.
>>
>>56236832
>wife
>>
>>56236832
>I'd
>>
>>56236823
>while(
>if(
Is this a meme now? Why am I seeing this so much on dpt lately?
>>
>>56236832
>I'd wife
>>
does anyone know how to compile for mip32r2 from ubuntu 16.04 x64? or if it's there a mips32r2 distro out there?
>>
>>56236713
shouldn't this be using switch-case
>>
>>56236978
how
>>
>>56236291
Doesn't this just make the input into a float? What would happen if the user inserts a Long number?
>>
>>56237007
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.maxsize
2147483647
>>> sys.maxsize * 5555
11929271659085L
>>> type(sys.maxsize * 5555)
<type 'long'>
>>> float(sys.maxsize * 5555)
11929271659085.0
>>> type(float(sys.maxsize * 5555))
<type 'float'>
>>>
>>
>>56236713
>>56236823
void sanitize(const char *in, char *out, size_t out_max)
{
const char *escape[UCHAR_MAX] = {
['"'] = "&quot;",
['\''] = "&apos;",
['<'] = "&lt;",
['>'] = "&gt;",
['&'] = "&amp;",
};

size_t i;

for (i = 0; i < out_max - 1 && *in; ++in) {
unsigned char c = *in;

if (escape[c]) {
if (strlen(escape[c]) > out_max - i) {
break;
} else {
strcpy(out + i, escape[c]);
i += strlen(escape[c]);
}
} else {
out[i++] = c;
}
}

out[i] = '\0';
}
>>
File: 81Gepr-sTpL._SL1500_.jpg (145KB, 1500x1169px) Image search: [Google]
81Gepr-sTpL._SL1500_.jpg
145KB, 1500x1169px
How do I become a professional Pajiit?

What common codemonkey shit should I bind to my g600 so I can write copypasta code even faster?
>>
>>56237147
pajeet is just a meme
>>
>>56236931
It's called programming, son. You might have heard of it.
>>
>>56237166
What should I do to get good at writing code? Like if I don't give a shit about computer science or program structure, but I want to get good at simply writing code and programming? What types of things do people look for when hiring those types of people because I imagine a cs degree grad is over qualified for that type of work.

My friend has said they have certifications you can get from microsoft.
>>
How do I get passed behavioral questions
>>
>>56237287
You ask someone to pass them to you.
>>
File: 1471621021696.jpg (30KB, 480x490px) Image search: [Google]
1471621021696.jpg
30KB, 480x490px
Tomorrow I start my job helping underclassmen figure out why their Hello World program won't run
>>
File: 101291.gif (370KB, 490x750px) Image search: [Google]
101291.gif
370KB, 490x750px
>>56237333
Excited?
>>
>>56237333
I hope you're getting paid above minimum wage.
>>
>>56237183
Not without a space goes after those keywords, faggot.
>>
>>56237221
by practicing, retard
>>
File: 1469744549665.gif (2MB, 600x333px) Image search: [Google]
1469744549665.gif
2MB, 600x333px
>>56237366
Kinda, I'm helping with an IT lab where students are given a lab assignment (in Java) to complete, and I'll be there to help the Grad student who is in charge of the lab. Should be fun as long as people are asking questions.
>>56237371
lol, if only. This is more for padding my bank account than anything, since I just invested a lot of money.
>>
>>56237418
what uni is it?
>>
>>56237432
Illinois State, for IT 168
>>
>>56235200

Try getting him "land of lisp". Configure clisp with a nice easy editor like atom.

It's a great book teaches the fundamentals through the construction of increasingly complicated games.
>>
>>56237287
the psych stuff? google it. seriously, there are lots of guides
>>
made my first genetic meme

you input a date (MMDDYYYY), and it generates a population of X organisms with random dates, then it breeds the top two of every five to create five children to replace those five, then shuffles

its pretty cool I guess, especially seeing how mutation rate, population size, and generation count changes things
>>
>>56237695
>MMDDYYYY
Literally the most pleb-tier of date formatting.
>>
>>56237752
the program literally doesn't care about the format, it's just a string of 8 numbers
>>
>>56237451
(sixth (multiple-value-list (decode-universal-time (get-universal-time))))

>clisp

Use SBCL, you heretic.
And I'm a Vim+slimv user, I know first-hand how to spot a heretic.
>>
>>56237830
>decode-universal-time (get-universal-time)
Why?
>>
Can I get a (You)? Just need to test something
>>
>>56237923
no
>>
>>56237931
You gave >>56237923 a (You) by posting that, idiot.
>>
>>56237945
that's the joke you fucking retard
>>
>>56235697
Did this but with only 2x xeons and 48gb ram. Works perfectly and i can do some really resource hungry shit anywhere i go
>>
>>56237889
Because it's late and I am pampering fucking apt on the side and I forgot about
get-decoded-time
>>
>>56237975
how hard is it to set up (windows)?
>>
File: 1468274225076.png (150KB, 1024x713px) Image search: [Google]
1468274225076.png
150KB, 1024x713px
>>56238048
it's very easy to set up windows 10 on your computer
>>
I'm currently learning C and i'm wondering if you can do something like that

void foo(x, y=1)
{
//function
}

?
>>
>>56238048
Install your favourite hypervisor and setup some VMs. Might take some time to learn how to do it but totally worth it
>>
>>56238077
In C++ you can
>>
>>56233153
Whats wrong with this??
>>
File: FtsU79oVvsg.jpg (40KB, 686x1024px) Image search: [Google]
FtsU79oVvsg.jpg
40KB, 686x1024px
>>56236853
Your heuristics dun goofed.
>>
>>56238234
it's okay anon, we can't all be swapping experts
>>
Hullo dpt

I'm trying to remove watermarks from a PDF I have

Notepad++ doesn't seem to want to interpret my regexes correctly.
Simply put, I want to search for the string
/G6 gs
1 0 0 1 71.2913 98.9291 cm
0 Tc
q
1 0 0 1 7.6 121.935 cm
/Fm7 Do
1 0 0 1 71.2913 98.9291 cm
Q
endstream


where the number /G6 and /FM7 have a tendency to change (to for example, /G10 and /G11 or G123890 and G123891)

So the regex I came up with is
(/G .* endstream)

For some reason, Notepad++ is always finding the very first instance of /G and the very last instance of endstream.
Works perfectly on regexr though.
What the fuck is going on?
>>
>>56238320
*to for example /G10 and /FM11 or /G123890 and /FM123891
>>
>>56238291
I know I'm not trolling just a programming noob reading through these threads
>>
>>56238077
>C
With some macro fuckery and _Generic, you can. It's quite a convoluted solution however.
#include <stdio.h>
#include <stdbool.h>

struct _def;
#define DEF (struct _def *)NULL
#define IS_DEF(val) _Generic(val, struct _def *: true, default: false)
#define GET_DEF(val, def) _Generic(val, struct _def *: def, default: val)

int foo(int x, int y)
{
printf("x: %d, y: %d\n", x, y);

return x + y;
}

#define _foo(x, y, end, ...) \
(foo)((x), GET_DEF(y, 0)); \
_Static_assert(IS_DEF(end), "Too many arguments to foo()");
#define foo(...) _foo(__VA_ARGS__, DEF, DEF, )

int main()
{
foo(1);
foo(1, 2);

int a = foo(2);
printf("%d\n", a);

// Fails to compile:
// foo();
// foo(1, 2, 3);
// printf("%d\n", foo(1));
}

Unfortunately you can't use a macro like this for an expression, only a basic assignment statement.
You can by removing the _Static_assert, but then you won't be able to detect if too many arguments are passed to the function.

>>56238104
Why did you even bring that up?
C++ is a completely different language.
>>
>>56238394
>Why did you even bring that up?
>C++ is a completely different language.
There's no need to be so mad. If he wants C + default parameters, he can switch to C++.
>>
>>56238394
A slight mistake, there shouldn't be a semi-colon after _Static_assert.

>>56238398
>Implying that C++ is a superset of C
>>
>>56238405
>>Implying that C++ is a superset of C
The only thing I can think of that's common C but not in C++ is VLAs
>>
>>56238394
What a horrendously ugly way to achieve something that should be simple.
>>
>>56238320
>>56238330
Nevermind.

I found the original XObject that was being referenced 900 times somewhere in page 2 and deleted all of the xobjects that looked related to it.
Meaning, anything labeled PDFTron and anything near to it.

Do you guys think this is enough to be safe?
>>
>>56238424
Designated initialisers are another huge one, as well as the lack of superfluous bullshit (This is actually a feature in systems programming) and having a stable ABI.
There are also shitloads of small semantic differences between the languages.

>>56238432
>horrendously ugly way
I agree. I was just demonstrating that it can be done.
I don't find default arguments to be particularly useful, so it isn't something I would do myself.
>>
>>56238463
Just don't use the superfluous bullshit
>>
>>56238463
>I don't find default arguments to be particularly useful
They are in some cases, but they also tend to disappear over time.
>>
>>56238481
And that's why there are a million subsets that people collectively call "C++".
>>
>>56238496
... and?
>>
>>56238512
>Read someone else's "C++"
>It's completely different to what you would have written
>>
>>56238525
... and?
>>
>>56238535
You're an idiot.
>>
>>56238438
crossposting from >>56238536
Any PDF gurus in here?
>>
>>56234834
fprintf
>>
>>56238569
Literally what is wrong with >>56238525
>>
What could I write to make use of my VPS? Right now it sits there at 0.1% load serving a website.
>>
>>56238599
>VPS
>only serving a website
What a waste of money.

Toss your VPS and get a subscription to Amazon AWS. Run your website from Amazon S3 and Lambda.
>>
>>56237085
hey thanks for teaching me about that neat hashtable trick

i rewrote your function so it sanitizes the string in place
char *xss_sanitize(char *str)
{
/* escapes malicious syntax */
/* figure out some way to make this overwrite in place */
const char *escape[UCHAR_MAX] = {
['\"'] = "&quot;",
['\''] = "&apos;",
['<'] = "&lt;",
['>'] = "&gt;",
['&'] = "&amp;"
};
unsigned i;
for (i = 0; str[i]; i++)
{
unsigned char c = str[i];
if (escape[c])
{
unsigned offset = strlen(escape[c]);
str = (char *) realloc(str, strlen(str) + offset + 1);
memmove(&str[i + offset], &str[i + 1], strlen(&str[i + 1]) + 1);
memcpy(&str[i], escape[c], offset);
i += offset;
}
}
return str;
}
>>
how the fuck do i find the position of a number in the fobinicci series lol
>>
Anyone good in HTTP/Python here? I want to try make a post on 4chan using Python. I just have no idea what to look for in the urllib.request/Requests module docs. Only been messing with the read-only json 4chan API before.
>>
>>56238651
http://www.maths.surrey.ac.uk/hosted-sites/R.Knott/Fibonacci/fibFormula.html
Do this in reverse.
Learn to use google, fucking newfag.
>>
>>56238656
just compose a POST request
>>
File: dt160131.jpg (177KB, 900x439px) Image search: [Google]
dt160131.jpg
177KB, 900x439px
>>
>>56238688
wait when did dilbert's company become a startup?
>>
>>56238707
I'm pretty sure he was always a software developer
>>
>>56238646
Actually, just a small fix that I forgot to put in my original:
const char *escape[UCHAR_MAX]

should be
static const char *escape[UCHAR_MAX]

just so you don't needlessly allocate that array on the stack.
>>
>>56238646
/!\ BUFFER OVERFLOW /!\
>>
>>56238728
yeah but it was always a at stuffy enterprise-y place

also dilbert is an engineer
>>
>>56238728
dilbert has always been an engineer (generically)
so software engineering isn't a stretch
>>
>>56238751
whatever that means.
>>
>>56238749
Wait no is fine.
>>
>>56233890
it was my first language
>>
>>56238791
It's a good first language, ignore the people knocking it
>>
>>56235697
If you even ask this question why are you on this board? Setting up hyperv is basically just clicking it, go go go. There are thousands of tutorials for people that are even too dull for that.
>>
>>56238832
Its great first language, keeps retards out.
>>
File: turbo_pascal.png (78KB, 640x454px) Image search: [Google]
turbo_pascal.png
78KB, 640x454px
>>56238832
>>56238953
what about pascal?
>>
>>56238999
basically dead
>>
you know that language you always talk shit about?
yeah, that one!
reply to this post with:
>1 language
>2 biggest gripe about it
>3 one thing you have to admit is good about it ("nothing" is not an option)
>>
>>56239047
Java.
It's object oriented.
It's not quite as shit as C++.
>>
>>56239047
Java
syntax, verbose, oop
robust and ubiquitous
>>
>>56239047
haskell
it's useless
it's not lisp
>>
>>56238748

You're making me realise how rarely I recognise const's and actually use them.
>>
>>56239047
Python
import solution
import solution
>>
File: idtech.png (8KB, 622x266px) Image search: [Google]
idtech.png
8KB, 622x266px
>>56239076
>>56238748
why don't people use T const * instead of const T *?
>>
File: terrain gen.png (497KB, 1920x1080px) Image search: [Google]
terrain gen.png
497KB, 1920x1080px
anybody ever use roblox studio for anything other than piecing together a free model "game" when they were 8?
>>
>>56233263
what does this even me
>>
>>56239089
This is why I try to make everything I do with just the standard library, no 3rd party modules

But it's still kinda like that anyway
>>
>>56239149
I used it exclusively for script building and programming you moron
>free model
You're cancer on a cancer site
>>
File: IndependenceDay.png (2MB, 1130x1600px) Image search: [Google]
IndependenceDay.png
2MB, 1130x1600px
>>56239152
>>
>>56239172
i made the terrain generator you see in the picture
i literally use it for the same thing as you
even when i used it as a little kid i didn't like using free models, i agree, they're cancer
>>
File: wew lad.png (152KB, 1232x256px) Image search: [Google]
wew lad.png
152KB, 1232x256px
>>
>>56239159
that's impossible though, how can you do anything useful without beautiful soup?

>>56239047
java
syntax is way to strict for me, and every program is like 3x as long as most any other language
it's very nice needing only eclipse to run it, no messing around with hotkeys and batch scripts
also I like how much easier it is to work with large files in java
>>
>>56239210
well he's half right at least
>>
>>56239241
which half?
>>
>>56239233
>that's impossible though, how can you do anything useful without beautiful soup?
html.parser, it's not as clean nor convenient. Something you can do in one line in bs4 requires a class with several functions in html.parser etc.
>>
>>56236314
Hi, Ruby!
>>
>>56239090
C allows the type and specifiers to be in any order, but <storage> <modifier> <type> seems the most consistent and logical to me.
Otherwise you permit stupid shit like
int typedef const myint;
>>
>>56239389
New
>>
>>56239400
Fucking idiot.
That is way too soon.
>>
>>56238751
He is an EE, works at an engineering firm and Scott Adams keeps the style contemporary so people can relate to it (think about who his audience is).
>>
>>56239089
> making shit faster and easier
> a gripe
>>
>>56233263
Just park behind a planet with rings!
>>
>>56239973
>making
importing*
>>
>>56233609
Stop using boost.
>>
>>56234067
God, I feel so sorry for you.
I hope I never have to work on anything like that.
>>
>>56233333
>>56235111

Well hello internet, and thank you for the wonderful numbers. It was just what I needed right now.
>>
>>56238394
thanks for the answer. I don't quite understand everything in that code but i'm definitely saving it for later.
I'm probably not going to use default arguments ever but i saw it used in a c++ tutorial i'm following (and doing in c), so i was curious if it could be done.
>>
>>56237007
I'm using Python 3.5 and it works just fine
>>
>>56240474
>>56240474
>I don't quite understand everything in that code
Right. It's stupidly macro heavy isn't obvious at all.

I'll try to give an explanation:
_Generic is a language construct added in C11 which will pick some replacement based on the type of the argument.
The first argument ('val') is the expression, and the rest of the arguments are a list of types and their substitutions.
e.g.
#define foo(v) _Generic((v), int: "integer", double: "floating point")

printf("%s\n", foo(0)); // "integer"
printf("%s\n", foo(1.0); // "floating point"


For the purposes of this, I created an incomplete type (struct _def) and used a pointer to it for the _Generic selection.
The user isn't supposed to worry about this type.
DEF is a convenience macro that is a pointer to this new type.

I then have two macros which use _Generic.
IS_DEF will be true if the argument is a DEF, otherwise false.
GET_DEF will return the 'def' value if 'val' is a DEF, or return the value as-is otherwise.

#define foo(...) _foo(__VA_ARGS__, DEF, DEF, )

This macro adds some DEF values to the end of the provided arguments. If the user provides fewer than 2 arguments, the DEF values will become 'x' and 'y' in the next bit.
We also need an extra DEF, just to act as the end marker.
Ignore the trailing comma. That was just to shut up some pedantic compiler warnings.

#define _foo(x, y, end, ...) \
(foo)((x), GET_DEF(y, 0)); \
_Static_assert(IS_DEF(end), "Too many arguments to foo()");

This is the macro that actually does the work.
The round brackets around foo makes sure we actually call the function instead of the macro.
We use the GET_DEF macro to do the replacement of 'y' if DEF was passed through from the previous macro.
The _Static_assert checks if the end argument isn't a user provided one, so that compilation will fail if the user passes too many arguments to the function.

It's fine if you don't understand. It's all pretty convoluted.
>>
>>56236823
even the cat isn't impressed
>>
So, in the untyped lambda calculus, where the only value is a function, what would be the value of a purely side-effecting function, e.g. print.
Does one have to introduce a unit value or are there ways around that? Continuations maybe?
>>
>>56241863
Side effects as free variables, e.g. literally "print 3"
>>
>>56233153
>>56238234
I think it's because it's an ArrayList, not a normal Java array, so you can't use a[i] to access an element, you have to use a.get(i)
>>
File: samus_absolutely_disgusting.gif (2MB, 357x238px) Image search: [Google]
samus_absolutely_disgusting.gif
2MB, 357x238px
>>56233902
>3 space indent
absolutely disgusting

Also, you should probably only be using 'i' as an index variable in a regular loop, and not as an object in a foreach type loop.
>>
>>56235203
Learn C, and then C++ to learn about pointers and other stuff which is common to many languages.

Learn Scheme or another Lisp to get good at recursion and data structures.

Read K&R C for learning C, and SICP for Scheme.
>>
File: dilbert_zeros.gif (66KB, 1200x368px) Image search: [Google]
dilbert_zeros.gif
66KB, 1200x368px
>>56238707
>>56238751
I think it started like a year or so ago, maybe a little more. Pretty sure it's still the same company, but the ID cards around their necks and polo shirts is a parody of more "hip" company cultures which are mostly seen at startups.
>>
>>56243408
>zeroes
>more than one
Lucky bastard
>>
>>56239047

>C++
>huge inconsistent clusterfuck
>one_ring_to_rule_them_all.cpp
>>
>>56239047
php
it's a clusterfuck of ideas
it has libraries for almost everything
>>
hey friends, I've been learning C# over the past week from this

https://mva.microsoft.com/en-US/training-courses/c-fundamentals-for-absolute-beginners-16169?l=chmm8TQIC_8106218949

I just finished part 9, but I can't really think of anything to apply this knowledge to

Is there some form of site/app/project that I can use my knowledge (the little I have) to make?

I know there is a subreddit about doing this kind of stuff but I want something else yknow?
>>
>>56244057
Maybe try some of the earlier problems on projecteuler.net
>>
>>56244091
yeah sure thing, thx
Thread posts: 319
Thread images: 34


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

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


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