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

/dpt/ - Daily Programming Thread

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

Thread replies: 340
Thread images: 32

File: 1452461991933.png (69KB, 1024x1191px) Image search: [Google]
1452461991933.png
69KB, 1024x1191px
What are you working on, /g/?

Old: >>52398999
>>
first for anime
>>
I'm working on anime mostly
>>
>>52403869
ThirD
>>
real thread here

>>52403910
>>52403910
>>
>programming in java
Urge to use cpp for macros intensifies.
>>
>>52403972
Loving
Every
Laugh
>>
>>52403984
get scala
>>
>>52403972
Rekt.

No, I won't gloat, I'm sorry, anon. You can make the next thread if you like.
>>
Is it wasteful to put function pointers to member functions in C structs?
I know C++ abstracts this away with vtables instead of actual pointers to functions, but I was wondering if I could do the same in C?
Should i put a vtable instead?
>>
Use the old one you monkeys >>52400261

If you spent less time trying to beat each other to see who posts the underage anime girl first you'd make /dpt/ better for everyone
>>
>>52404021
A vtable is just a struct of function pointers that gets shared between all instances of the class.
>>
>>52404030
kill yourself
that thread was created as continuation to an older thread and is now deprecated
>>
>>52403869
Why can't the OP in this general post good anime pictures instead of cuteposting throughout the entire thread?
>>
>>52404041
no it was posted hours after >>52398999
>>
ayy lmao
>>
>>52404036
Do I declare that globally or something?
>>
>>52404030
Nah, he posted that when the old thread was like on 100 replies.

It should have been deleted.
>>
>>52404080
but it didn't get deleted, so it's legit according to newfag logic
>>
File: 1452446300011.png (229KB, 628x708px) Image search: [Google]
1452446300011.png
229KB, 628x708px
So, what are you working on, /g/?
>>
>>52404076
I'd have the struct itself declared in the header for the "class" and the actual vtable a static variable in the corresponding implementation file. The "constructor" would set the "object"'s vtable pointer to that one.
>>
>>52404118
xD
>>
Is gitgud.io any gud? I mean, what about the uptime?
>>
File: 1452447821535.png (287KB, 900x1140px) Image search: [Google]
1452447821535.png
287KB, 900x1140px
>>52404149

HxD?
>>
>>52404195
back to >>>/a/ faggot
>>
Hop to it, /dpt/.

http://better-dpt-roll.github.io/
>>
>>52404216
This is an anime site, so technically anime is always on topic although if you are going to post anime please post something that objectively good instead of the crap in this thread.
It's an insult to Japanese animation and those of us with actual anime taste.
>>
File: 1452448978219.png (188KB, 575x372px) Image search: [Google]
1452448978219.png
188KB, 575x372px
>>52404216
My home board is /pol/, anon.
>>
Hi guys, please tell me what language should I learn to prog little 2d vidyas ?
I'm already pretty good I think at C, should I stick to it or learn a new language ?
>>
>>52404121
so the vtable would declared like
/* thing.h */

struct _vtable {
(*func1) (struct thing);
(*func2) (struct thing);
};

struct _thing {
unsigned *data;
struct _vtable *vt;
}

struct _vtable _global_thing_vtable {
&nameoffunc1,
&nameoffunc2
};


and then for the constructor, I just have it assign a function pointer to this global scope _vtable struct?
>>
>>52404281
C is deprecated. Learn C++
>>
Is having a text column as primary key bad practice in sql?
>>
>>52404296
Not a function pointer to that. Just a pointer.

Though this is all pretty meaningless without subtyping polymorphism.
>>
File: 1452530965310.png (193KB, 397x547px) Image search: [Google]
1452530965310.png
193KB, 397x547px
>>52404281
JavaScript.

You can easily share your games online and it's perfect for 2D games.
>>
>>52404281
C++ and opengl

read the opengl superbible
>>
>>52404356
>opengl superbible
but that horrible custom framework they use in that book is so off-putting
>>
>>52404281
I don't see any reason to use C. Use a programming language that makes life easier for you, like Lua.
>>
>>52404356
Is opengl a language ?
>>
>>52404388
i've barely even read a single page tbqh but the setup thing for multiple shaders looked fine and would have saved me like a day of trawling the internet for tidbits of information
>>
>>52404437
The issue I have with it, is that they teach you how to use opengl with their framework, instead of doing a general opengl book that would work with everything as long as you can get a glcontext running.
>>
>>52404424
opengl itself is an API implemented by a set of C functions for interfacing with graphics hardware. GLSL which shaders use is its own language but it's very simple and similar to C.
>>
>>52404424
It's an API for programming your GPU. I guess it could be called a DSL in some sense, since it's quite abstracted away from the details and is more declarative than imperative at heart.
>>
>>52404437
where did you learn then?
>>
>>52404306
Yes.

Whatcha trying to do?
>>
>>52404493
Not him, but I learned through an amalgamation of pretty much everything I could find, and of course a lot of practice.
>>
CHIP-8 opcodes left to implement
>0x00E0 - CLS - clear screen
>0xCxnn - RND - sets register x to nn&(random number)
>0xDxyN - DRW - draws sprite at I at position x,y with N lines drawn
>0xEx9E - SKP - skip next instruction if key at register x is pressed
>0xExA1 - SKNP - skip next instruction if key at register x is not pressed
>0xFx0A - LD - execution stops until key is pressed, then it's stored in register x
>0xFx29 - LD - sets I to the location of the sprite in register x

So pretty much just stuff I need external libraries for (display, random numbers, key presses)

We're all gonna make it lads
>>
File: 1439624602379.png (31KB, 400x400px) Image search: [Google]
1439624602379.png
31KB, 400x400px
Everyone recommends me something different =/
What should I base myself upon to pick a language in particular and not another?
>>
>>52404493
i've learned over time, in the beginning it was from dissecting how libgdx does its rendering and so i had to look up how to use VBOs and such. i don't recommend libgdx though, i would have much preferred to have learned opengl from scratch. you could copy some setup code to get started (glCreateProgram and such) and then fiddle with one thing at a time such as shaders and VBOs with different vertex components.

this thing is useful for fiddling with shaders or at least checking if they compile:
http://shdr.bkcore.com/
>>
>>52404306
create a id field for your primary key
+----+----------+
| id | username |
+----+----------+
| 1 | john |
| 2 | ted |
| 3 | bob |
+----+----------+
>>
>>52404496
Well I've got stuck thinking out my YouTube scraper, so I want to start my anime manager. Currently thinking out the database.
I got the following:
SERIE
id INTEGER PRIMARY KEY AUTO INCREMENT name TEXT UNIQUE

SEASON
id PRIMARY KEY AUTO INCREMENT name TEXT serie INTEGER FOREIGN KEY

I don't see any reason to have the id column in the serie table, because name is already unique.
>>
>>52404551
Honestly, JavaScript is the way to go for what you want to do.

People can play your 2D games in the comfort of their own browser.
>>
>>52404551
Figure out what you want to do and what best suits your aims. Faggot.
>>
>>52404616
not everyone wants shitty flappy bird clones that run in their browser
>>
>>52404590
What if you change the series name? What if 2 series are called the same? That would fuck up all your records that point to it. Use a primary key integer.
>>
>>52403126
Meh, I kind of gave up halfway.

import qualified Data.Map.Strict as M

type Pos = Height
type Height = Int
type Skyline = [(Pos, Height, Pos)]
type Heightmap = M.Map Pos Height

skyline :: Skyline
skyline = [(1,3,3),(3,2,5),(5,4,7)]

fromSkyline :: Skyline -> (Height, Heightmap)
fromSkyline = foldr add (0, M.empty)
where add (left, height, right) (maxHeight, m) = (max height maxHeight, foldr f m [left..right])
where f x = M.insertWith max x height

printHeightmap :: Height -> Heightmap -> String
printHeightmap maxHeight heightmap =
unlines $ helper (M.elems heightmap) (replicate maxHeight "")
where
keys = [maxHeight,maxHeight-1..]

helper (x:y:xs) = helper (y:xs) . zipWith (\h l -> l ++ [f h]) keys
where f h
| h >= min x y && h <= max x y = '*'
| otherwise = ' '
helper _ = id

main = putStr (uncurry printHeightmap $ fromSkyline skyline)


>>52403908
>him
>>
File: mons.webm (3MB, 900x506px) Image search: [Google]
mons.webm
3MB, 900x506px
>>52404551
just pick one of the following.

:: Structure and Interpretation of Computer Programs
http://sarabander.github.io/sicp/
http://paste.lisp.org/display/151208/raw

:: How to Design Programs
http://htdp.org/
https://www.edx.org/xseries/systematic-program-design-0

:: Concepts, Techniques, and Models of Computer Programming
not free

:: Composing Programs
http://composingprograms.com/

:: CS for All
http://www.cs.hmc.edu/csforall/
https://www.edx.org/course/cs-all-introduction-computer-science-harveymuddx-cs005x

:: Program Arcade Games With Python And Pygame
http://programarcadegames.com/
>>
>change the series name
Good point.
>2 series called the same
If I remove the UNIQUE constraint, I'm in big trouble. Let's say you have the following commands:
season add <serie name> <season name> ...
season remove <serie name> <season name> ...

Now I'm unable to look up the serie id for the serie name.
>>
I want to write a .png loader from scratch in Python. Is there an easy way to individually access bytes of memory with Python 3? I need to parse the header file.
>>
>>52404757
Do you get off on wasting your time?
>>
>>52404792
Maybe I mis-spoke. I don't "want to" but it sounded like the easiest project my professor suggested.
>>
>>52404753
You do a query and see if there's 1 or more series with the same name, if there's several, decide to which one you add.
>>
>>52404757
import PIL
>>
>>52404757
http://stackoverflow.com/questions/1035340/reading-binary-file-in-python-and-looping-over-each-byte
>>
>>52404838
Thanks, looks pretty annoying though. Oh well.
>>
>>52404809
It's possible from a technical perspective, but the user won't know which is the right serie.
The name is serie A is weeaboo. It has 2 seasons called 1 and 2.
The name of serie B is weeaboo. It has 2 seasons called 1 and 2.
How would the user know which serie to append to?
>>
the vertex shader takes vertex data and transforms it in a programmable manner. it could take for example xy coordinates and color data.

the fragment shader outputs to individual pixels.

in opengl you have a clip space of -1 to 1 in the x and y directions, and 0 (near) to 1 (far) in the z direction.

for example if you're rendering to a 16:9 surface and you have the game coordinate space at (-8 to +8, -4.5 to 4.5) then in the vertex shader you would divide by 8 in the x axis and by 4.5 in the y axis to make things fit within the clip space.

to rotate you can multiply the coordinated by a rotation matrix. to zoom you can multiply the values (for example multiply by 2 to look at (-4 to +4, -2.25 to 2.25). to move the "camera" you can add numbers to the x and y values to translate the "world" in the x and y directions.
>>
key as name + description
if there is ambiguity then describe each one to the user
>>
>>52404910
OK, but how do I combine transformations? Like what if I want to rotate a triangle around 0,0 and then move it to the center of the screen?
>>
File: Spengbab.png (72KB, 323x345px) Image search: [Google]
Spengbab.png
72KB, 323x345px
Could someone please explain to me how to compress a text file with zlib in C++? I've been Googling for the last half hour but nothing works.
>>
>>52404989
import zlib
zlib.compress(myfile)
>>
>>52404989
load text into buffer
usz zlib.h to compress said buffer

WOW SO HARD
>>
>>52404937
https://www.youtube.com/watch?v=IrggOvOSZr4

to rotate a triangle you multiply by a rotation matrix. you can have a 2x2 mat2 uniform variable in the shader, calculate { cos(angle), -sin(angle), sin(angle), cos(angle) } on the CPU side, then upload to the GPU with glUniform. then in the vertex shader you would set the position like
gl_Position(u_rotation_matrix * a_coord.xy, 0.0, 1.0);


this would already be centered since the clip space is -1 to 1 in both the x and y axis but to move the triangle you could have a uniform 2d vector like

gl_Position(u_rotation_matrix * a_coord.xy + translation_vector.xy, 0.0, 1.0);
>>
>>52404757
>Is there an easy way to individually access bytes of memory with
Erlang? yes :3

<<137,80,78,71,13,10,26,10,Rest/binary>> = Data.
>>
File: 1451779320598.png (20KB, 418x359px) Image search: [Google]
1451779320598.png
20KB, 418x359px
>mfw making a virtual machine capable of running a 4chan image downloader that prints Fizz every 3 images, Buzz every 5 images and FizzBuzz every 15 images in a tornado-like fashion
>>
>>52405010
>>52405027
That doesn't fucking work, assholes. The compress() function takes four arguments, but I can't find any documentation so I don't even know what the fuck they are.
>>
>>52405124
Kill yourself, frogposter.
>>
File: 1451754656606.png (17KB, 418x359px) Image search: [Google]
1451754656606.png
17KB, 418x359px
>>52405158
>>
>>52405129
GO READ ZLIB.h you nigger.
ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
const Bytef *source, uLong sourceLen));

It's human readable
>>
>>52405129
>I can't find any documentation
It literally says in the header.
ZEXTERN int ZEXPORT compress OF((Bytef *dest,   uLongf *destLen,
const Bytef *source, uLong sourceLen));
/*
Compresses the source buffer into the destination buffer. sourceLen is
the byte length of the source buffer. Upon entry, destLen is the total size
of the destination buffer, which must be at least the value returned by
compressBound(sourceLen). Upon exit, destLen is the actual size of the
compressed buffer.

compress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer.
*/

or one of the functions that works with files.
>>
how come no one uses libgdx
>>
File: you did it pupper.webm (3MB, 720x405px) Image search: [Google]
you did it pupper.webm
3MB, 720x405px
Am I doing this vtables thing correctly?
https://paste.installgentoo.com/view/raw/5ada1743

$ ./vtables
object_t placed on stack
func 1 accessed!
func 2 accessed!
func 3 accessed!
object_t placed on heap
func 1 accessed!
func 2 accessed!
func 3 accessed!
>>
>>52405232
it's not very good imo it doesn't bring you much of an advantage besides making it very easy to develop for multiple platforms
>>
>>52405269
what's so good about unity
>>
File: 1450844080429.gif (696KB, 242x191px) Image search: [Google]
1450844080429.gif
696KB, 242x191px
>>52405192
>>52405177
Okay, but how do I convert a string of text into those formats it needs?
>>
>>52405232
It's shit, especially the rooms
>>
>>52405318
i don't think unity is very good either but unity is more of a full-fledged engine that enables you to make 3d (and 2d) games with ease using a drag and drop editor and pre-made plugins and assets.
>>
>>52404911
The description will certainly help. Thanks senpai.
>>
>>52405333
>C++ fags everyone
>don't even understand what strings are
>>
what do after LYAH?
>>
>>52405431
commit sudoku
>>
Ignore the trips, the code is at: >>52393000

>spend time setting up a dynamic array lua entity system in C
>seems to work pretty good
>add SDL to engine
>only notice one entity on screen
>moves extremely fast (as many times as that entity should be on the level, say, 5)
>console still tells me there are 5

I don't seem to be having any memory issues at the time being, but for all the entities to converge is weird.

I think I may have found the issue though, the tables inside the entity table. For some reason those values are the same across all entities while variables just in the entity table itself aren't. Is this something easily fixable?
>>
>>52405441
any non-meme responses?
>>
>>52405466
>unironically using LUA
commit sudoku
>>
>>52405478
rewrite the windows kernel in haskell
>>
Hi /g/uys.
What language would you recommend to create automatons ?
I will need to get input from screen display and memory of a process, and generate keystrokes and mouse move/clicks as output.
Is c++ ok ?
>>
>>52405318
it supports C#
>>
Hey guys, I have a question. Modern, idiomatic C++11/14 seems pretty neat, but all the platform APIs I've seen are still C-style, so unless you write custom wrappers around every API call, you're still dealing with C-strings and naked pointers and so on.

Is it really better to have half your code in un-idiomatic C++ and then half of it in "proper" C++11/14? Wouldn't one consistent style be easier to maintain and read?
>>
>>52405478
If you don't want memes, why are you learning Haskell?
>>
>>52403908
Done!

http://lpaste.net/1074610940697116672

                  +--+       
| |
| |
| |
| |
+-----+ | |+-----+
| | | || |
+-+ | | || |
| | | || |
| | | || |
| | | || |
| | +---+ | || |
| | | | | || |
| | | | | || |
| | | | | || |
| | | +--+ ++ |
| | | |
| | | |
+ +--+ +
>>
>>52405620
i like it, I want more, pls, just help me
how do I become this guy
http://ezyang.com/
>>
>>52405693
>http://lpaste.net/1074610940697116672
./hahaskell c/lel
::::::|::[]->[]::[]::[]->[]->[][][][][]->[]->::|<:|:::[]->[]::[]->[][][][][]::|
:|::::->[]->[][][]:|:|->->::->::[]->[]::[]->|<$-|$----|--<>--::->::->::[[][]][[
][]]::[|<-]::
Meme: 171
Total: 3561
Total meme percent: 98.4162%
>>
>>52405235
help
>>
>>52405716
Read lots blog posts (monitor /r/haskell, including comments) and write programs
>>
>>52405495
what would you use then?
>>
>>52405333
You know about the c_str() method of std::string? You can cast a char* to Bytef*.

(Now if you'd been complaining about the core compression stream handling code, I could understand it. That's *not* easy to use. But you're struggling with the noddy interface for babbies. Stop embarrassing us and learn how to code for real.)
>>
>>52405693
>>52405735
hey haskell guy, how did you get good?
for example, I want to write ncurses stuff, but I've no way to learn ncurses because no documentation for haskell (only for c and perl) and I dont know those langs
what im trying to ask is, how do learn libraries that are too large?
>>
>>52404864
You obviously expose enough information for the user to make that decision, like a description, airing date or something.
>>
>>52405805
C. If you're already writing your game in C, why bother implementing a whole other language and trying to make it play nice?
>>
>>52405890
>no documentation
https://john-millikin.com/software/haskell-ncurses/reference/haskell-ncurses/latest/UI.NCurses/

10 seconds on DDG. You use it the same way you would use the C version.
>>
>>52404687

Not who you're replying to, but it should be easy to set up cascading of updates for a name change, and if 2 anime series actually have the same name, he probably wants to assign different names in the DB (differentiated by year, version, etc.) so that they can be told apart.

He's basically thinking of using a natural key over a surrogate key, which is not an inherently bad idea.

A possible disadvantage in this case is increased data storage since he'd have to have the name stored everywhere instead of an int, but that's a minor issue at best.
>>
>>52405890
Honestly I've never done interactive stuff in Haskell (neither TUI nor GUI). For what I can see, out of the few ncurses bindings available, what >>52405938 linked seems to be the nicest ones.

However, this seems a bit hard of a "first" library to learn. I'd try to write some other sofware before like good old command line tools. If you want to move on and have some background in webdev, there are some pretty good frameworks for it (yesod, snap, scotty, servant...).

If you insist in using this ncurses library, look at the example in the documentation: https://john-millikin.com/software/haskell-ncurses/reference/haskell-ncurses/latest/
This sounds like it's close to a raw binding from the C library, so I'd recommend learning the C version first.
>>
>>52405431

Try Real World Haskell or actually building something.
>>
>>52404546
doing this right now with SFML lmao
>>
>>52406071
I was thinking the same lmao, but not sure if I want to do it with SDL since I heard SFML was OO and I'm using C (for learning purposes)
>>
>>52406022
thanks!
also, have you done any AI stuff, is haskell a good language for that?
does category theory help at all?
>>
>>52405916
scripting
>>
I compiled C Hello World using gcc -static.
The elf file is huge, because it links the entire libc in it. How do I link only printf and functions used by printf?
>>
>>52405599
m8 there's like a billion excellent wrapper libraries already written for the native platform APIs

just pick and get cracking
>>
>>52406049
Some notes on good practices (it's hard to find this kind of list IMO):
- Try to never use Data.ByteString.Char8: it truncates unicode text to ascii
- Consider Data.ByteString to be an array of bytes, not text
- Prefer Data.Text when manipulating text (avoid String)
- Use Either/ExceptT error handling in simple cases
- Use Control.Monad.Catch for exceptions in IO-heavy code or bigger codebases
- Take advantage of MTL-style composable effects (MonadReader, MonadState, etc). Newtype small components using ReaderT/StateT in newtypes and abstract them in a MonadWhatever-style typeclass.
- Learn a streaming library (i.e. pipes and conduit)

>>52406101
I haven't done any AI with it either. It doesn't seem like a bad idea though, especially considering how much Lisps were used.
Category is just a tool for abstraction in some kinds of libraries. It's like a common language that everybody somewhat understands and can be used to reason more abstractly about your code. It's like a factory of design patterns (done right, without leaky abstractions).
>>
>>52406197
>considering how much Lisps were used
Lisp was used for AI based on an outdated concept of symbol manipulation. They believed the AI would generate code and run it with eval.
>>
>>52406233
Oh, I didn't know. Well, Haskell is pretty good at that too (in fact, it's a great language for writing compilers for many reasons). List/vector/tree manipulation and traversal are some things where it really shines (lenses are pretty handy for this if you like them)
>>
File: 4L_KacBygr5.gif (2MB, 480x480px) Image search: [Google]
4L_KacBygr5.gif
2MB, 480x480px
>>52403869

After seeing how the cracking process went with Just Cause 3 i got interested in reverse engineering software, i barely know IDA & Olly but youtube video's are speeding up my learning process. With this as a beginning i'd like to shift into the more advanced functions in software. Is it unrealistic?
>>
#include <iostream>
#define System S s;s
#define public
#define static
#define void int
#define main(x) main()
struct F {
void println(const char* s) {
std::cout << s << std::endl;
}
};
struct S {
F out;
};

public static void main(String[] args) {
System.out.println("Hello World");
}


>>
>>52406312
Why?
>>
>>52406312
wat is this
>>
>>52406312
absolute madman
>>
>>52406300
Depends on exactly what you plan to do and how much time you're willing to invest in. You won't be able crack Just Cause 3 if that's what you're wondering.
>>
>stoked to finally take a programming class over Jterm
>I'm fucking sucking at it, can't even get tictactoe to work
Welp, time to switch majors/kill myself.
>>
I finished a project and I can't think of another project to do. Literally every project idea has been done before. I was going to make a MOD player in javascript but some fucker already made one.
>>
>>52406312
>#define System S s;s
You could have just done
struct S {
F out;
} System;
>>
>>52406300
Do you have a link to that article/video?
>>
best scheme compiler to run asynchronously under Emacs?
>>
>>52406663
because it's not a loop (or it might be, I don't use javascript)

Implement a for loop. It's the best for looping through an array.
>>
>>52406663
Ignore this, I just fixed my scrub problem like a turbo-scrub
>>
What's the best IDE and why is it Visual Studio?
>>
>>52406704
It's a library method which acts like a loop. I wonder how much slower this method is than writing the real thing in vanilla js.

If you know, holla atcha boy.
>>
>>52406644
>Emacs
top pleb
go with mit-gnu or whatever that shit is called, it'll be just like your sicp wants it to be lmao
>>
>>52406714
>inb9 IDE pleb nigger

I'm actually enjoying Xcode more than VS because of it's debug tools. The syntax complete is on the same level as VS if not better.
>>
>>52406714
Thanks Pajeet.
₹2 has been deposited to your Microsoft® account.
>>
File: despoiled flower.png (653KB, 611x642px) Image search: [Google]
despoiled flower.png
653KB, 611x642px
>>52403869
In a high performance database with limited storage capacity, what should be the datatype of a Gender column.
>>
>>52406644
guile and racket work with geiser mode.
Chicken scheme might work with it too.
>>
File: 1447048507967.jpg (191KB, 640x800px) Image search: [Google]
1447048507967.jpg
191KB, 640x800px
How does this make you feel, /g/?

unsigned i;
for (i = 0; obj[i]; i++)
{
validated[i] = obj[i]->vt->validate(obj[i], obj->vt->getN(obj[i]));
}
>>
>>52406760
int64 where every value represent one gender.
>>
File: 1442350096723.png (103KB, 500x500px) Image search: [Google]
1442350096723.png
103KB, 500x500px
Desperately need help dynamically naming arrays.

I'm creating a tab app in Ruby that keeps track of a customer's tab so they can pay it at the end of the month.

I need to know how to do two things:

1. dynamically create an array. Essentially, have a new user register himself or herself into the app. I.e. if I pass a txt file through my code and it sees the Register command, like this:

Register Pepe

Then I want to be able to create an array named after the string "Pepe".

Second, I want to be able to store purchases (and, I guess, returns) by pushing dollar amounts through into the array so that I may make a total from it. I.e. if I instead get a Purchase command from that txt file:

Purchase Pepe 5 32 4 16

Then I want to be able to add 5, 32, 4 and 16 into Pepe = []

I scoured Stack Exchange with no luck. Please help a sad amateur who fell for the Ruby meme, /dpt/
>>
>>52406760
AbstractGenderFactoryTreeBeanObserver
>>
>>52406801
>unsigned i;
>for (i = 0
Irritated.
>>
>>52406801
looks like horribly designed software. you should aim at having clearer hierarchies.
>>
>>52406815
the array should just have a name like customerPurchase or whatever
>>
>>52406804
more realistically

vector<char> *gender;
while(1){
gender.push_back(randomshit);
}
>>
>>52406845
It would look fine if they didn't do stupid shit like using vtables and have get "methods".
>>
>>52406760
You really only need three.
Male/Female/Other
>>
>>52406886
fug its should be

gender->push_back(randomshit);
>>
>>52404546
can you show me source of that

i wanna tackle that project since im interested in emulation and low level related things
>>
>>52406917
*Male/Other

>>52406845
>>52406893
How about this?
for (i = 0; *(obj+i); i++)
{
*(validated+i) = (*(**(obj+i)).vt).validate(*(obj+i), (*(**(obj+i)).vt).getN(*(obj+i)));
}
>>
>>52406917
get with the times, it's LGBTQQIP2SAA and expanding
>>
>>52406935
the fuck are you doing nigger
vector<char> gender;
while (1) {
gender.push_back(randomshit);
}
>>
>>52406947
for (i = 0; obj[i]; i++)
{
validated[i] = (*(**(obj+i)).vt).validate(*(obj+i),(*(**(obj+i)).vt).getN(*(obj+i)));
}
>>
>>52406760
0 for female
1 for male
>>
>>52406950
I could care less
>>
>>52406939
I won't show you my source, since it's better if you learn yourself, but here are some helpful links
http://devernay.free.fr/hacks/chip8/C8TECH10.HTM
https://en.wikipedia.org/wiki/CHIP-8
http://www.multigesture.net/articles/how-to-write-an-emulator-chip-8-interpreter/
>>
File: 15465-1-1100.jpg (131KB, 1100x619px) Image search: [Google]
15465-1-1100.jpg
131KB, 1100x619px
>>52406877
well Pepe isnt going to be the only customer at this store.

I was also tasked with specifically making sure than some sort of Registration command will register a new shopper.
>>
>>52406986
use OOP

think of it like algebra

x + 2 = 4

it doesn't matter what the name of x is, it could be

t + 2 = 4

the variable name should describe what kind of data it represents. the Pepe name should just be in a separate string with a name like customerName or something
>>
>>52406917
>Other
Don't encourage their shit. Make it 'Unspecified'.
>>
>>52406481

I'd like to start with old/small program's and work my way up, i mainly want to understand how dll's/exe's work in their installed folder with its resources. Time isn't a problem, i have time and lasting motivation i hope.

I dont understand why it isnt possible to cut the portion out of a exe or multiple files where the security resides and fill in some code to keep the code running what prevents this? Too hard?


>>52406640
I started with this video, not done watching it
http://youtu.be/DEDYk8zN53A
>>
I want to make an Android app. What should I make?
>>
>>52407069
Fart app.
You'll make millions.
>>
>>52407021
what do you mean use OOP?

and if i dont know what an array is called how do i access it again?
>>
>>52407048
You can't just open up an exe file in a text editor. You need the source code if you want to take out the portion where the security resides.
>>
File: 1436580208695.jpg (59KB, 500x375px) Image search: [Google]
1436580208695.jpg
59KB, 500x375px
>team of 4
>two senior guys that know everything leave today
>manager comes to me and other junior guy
>"We'll be counting on you two"
>mfw we just inherited 8 half-done projects
>>
import Data.Maybe

data Cell = X | O | Blank deriving Eq
type Board = [Cell]

check [X, X, X] = X
check [O, O, O] = O
check _ = Blank

winner [ tl, t, tr
, l, m, r
, bl, b, br ] = listToMaybe $ filter (/=Blank) matches
where
matches =
-- horizontal
[ check [tl, t, tr]
, check [ l, m, r]
, check [bl, b, br]
-- vertical
, check [tl, l, bl]
, check [t , m, b ]
, check [tr, r, br]
-- diagonal
, check [tl, m, br]
, check [bl, m, tr] ]


rate my Haskell pls
>>
>>52407184
Quit
>>
>>52407184
ask for a pay rise
>>
>>52405693
looks nice !
i dont know if it applies to your solution but the heightChange occurs at pos 1, so the left most part should be either a whitespace or '-' in your case, indicating there is nothing visible
>>
>>52407257
What's that
>>
File: code.png (7KB, 1562x85px) Image search: [Google]
code.png
7KB, 1562x85px
>>52405832
Thanks, I think I've almost got this working. compress() returns 0, which means success, but I can't do anything with the output buffer. I tried to cout it but it always crashes. How do I convert it to text and save it?
p-pls no more bully
>>
>>52406969
i wasn't talking about notation. at first glance it looks like it could be designed more elegantly and cleaner.

why is it needed that you put a pointer of obj into the validator vt's method if vt is already known in obj? that's not a clear hierarchy. if you can, create a clear hierarchy. maybe obj doesn't need to know its validator?

also, it seems unnecessary that the validate method needs the second parameter. getN is part of the validtor.

maybe you're aiming for flexibility, but often clearness and simplicity is key, especially in large projects.

I'd argue that something like the following should be possible. Maybe too overengineered for your taste, I don't know. However it would have a clearer relationship and hierarchy. namely Validator -> SpecificValidator and Validator -> Obj. Obj wouldn't need to know anything about validation.

for ...
{
validated[i] = validator->validate(obj[i]);
}

bool Validator::validate(obj* o)
{
SpecificValidator * v = getSpecificValidator(o);
return v->validate(o);
}


bool SpecificValidatorA::validate(obj* o)
{
int n = getN(o);
//...
return result;
}
>>
>>52407222
check should be
Cell -> Cell -> Cell -> Cell


Pattern-matching on a list like that tends to be code smell

>>52407258
The wall begins on the last tile of the previous roof. The alternative is to have it begin in the beginning of the next one if you prefer
>>
>>52407291
>::
>C++
It seems more likely that the original code snippet was C.
>>
>>52407184
If I were you, I'd team up with the other guy and demand that your manager double your current pay or else you're gone.
>>
>>52407091

With a long enough search you could find something/change with a disassembler like
IDA Pro and debuggers like Ollydbg with it you could modify files to its core
>>
>>52407306
omg you're right... idk why I even used a list >_>
>>
File: 1448962169257.jpg (500KB, 1168x1280px) Image search: [Google]
1448962169257.jpg
500KB, 1168x1280px
>>52406815
Does anyone else know how to help me with this?

Would it be better to use hashes or even arrays or hashes within classes? Just to keep everything unique?

Halp?
>>
File: assembly.jpg (122KB, 671x635px) Image search: [Google]
assembly.jpg
122KB, 671x635px
Since I'm almost finished with the CHIP-8 interpreter, I decided to collate the opcodes as assembly instructions for reference, so I can quickly create binaries that work with the interpreter. Then I'll create a compiled language on top of it so I can develop games quicker. This is fun as fuck tbf. Yes I'm aware of the original machine's limited memory. With so few opcodes, I'll only be making simple things like sokoban
>>
I FUCKING HATE YOU ANIME FAGGOTS
DAILY PROGRAMMING THREAD IS FOR PROGRAMS
NOT FOR WEAK SHIT LIMP WRISTED ANIME GIRLS PUBLISHED BY LONELY FAILED MANSTATES FROM ACROSS THE PACIFIC
>>
File: anime pic.jpg (71KB, 400x465px) Image search: [Google]
anime pic.jpg
71KB, 400x465px
>>52407376
I think you should go back to reddit.
>>
File: 9a1hQfU.jpg (63KB, 1280x720px) Image search: [Google]
9a1hQfU.jpg
63KB, 1280x720px
>>52407376
How do you feel about weak shit limp wristed anime boys that dress like girls?

Also post code or shut up.
>>
>>52407089
OOP = object-oriented programming

you access it again by what you wrote its name as in the source code
>>
>>52407407
#include <gays.h>
#include <japanese_war_crimes/anime.h>

int main(void) {
gay_person **gays;
size_t num_gays = enumerate_gays(gays);

for (size_t i = 0; i < num_gays; i++) {
if (likes_anime(gays[i])) {
liquidate(gays[i]);
gays[i] = NULL;
}
}

free(gays)
return 0;
}
>>
>>52407479
That reminds me, I should start a /d/ game
>>
>>52407479
>liquidate(gays[i]);
>gays[i] = NULL;

I sure hope liquidate calls free on gays[i]
>>
>>52405158
>>52405165
Every time this happens I laugh

That fucking face, man

>>52407266
If 0 is Z_OK, that should be fine, meaning your destination buffer has the compressed data in it. But you really should be allocating using compressBound(test.size()), not test.size() directly. And why are you allocating an array of pointers to const chars? You should be allocating using Bytef. And why are you allocating it on the stack anyway? What exactly is the crash you're seeing?
>>
Okay DPT, explain this to me...

I have rustc installed at $HOME/opt/bin, with its respective libraries installed to $HOME/opt/lib (this is on a lab computer at my university, so I cannot install such files globally).

In order to link rustc against its own libraries, I had to add $HOME/opt/lib to my $LD_LIBRARY_PATH in my .bash_profile. Since the value was previously empty (apparently it is never set on Ubuntu), I set it like this:

export LD_LIBRARY_PATH=/usr/local/lib:$HOME/opt/lib


After a logout and re-login, the .bash_profile does not export this value, but it does export the $PATH variable that I had set previously. Starting a new instance of bash does not set this variable within that instance of Bash. If I ssh into localhost, however, the export succeeds within the context of that ssh.

So how is it that the PATH export in my .bash_profile is read every time I start a new instance of Bash, but not the LD_LIBRARY_PATH export?
>>
I feel like I'm getting burnt out on software. All of this programming just seems so pointless and none of it really matters. I've spent years hobbying away on various projects and I haven't gotten anywhere as a result. What should I do /dpt/?
>>
File: assembly categories.jpg (94KB, 687x657px) Image search: [Google]
assembly categories.jpg
94KB, 687x657px
>>52407369
and starting to categorize the 35 opcodes. It's so short I may as well just program in this
>>
>>52403869
Any anons in the Philly area looking for an apartment next year? I need a roommate, can't afford a studio ='(
>>
>>52407573
~/.bash_profile is only sourced by bash when started in interactive login mode. That is typically only when you login at the console or connecting via ssh.

When you log in graphically, ~/.profile will be specifically sourced by the script that launches gnome-session (or whichever desktop environment you're using). So ~/.bash_profile is not sourced at all when you log in graphically.

When you open a terminal, the terminal starts bash in (non-login) interactive mode, which means it will source ~/.bashrc.

The right place for you to put these environment variables is in ~/.profile, and the effect should be apparent next time you log in.

Sourcing ~/.bash_profile from ~/.bashrc is the wrong solution. It's supposed to be the other way around; ~/.bash_profile should source ~/.bashrc.
>>
>>52407582
Kill yourself. It's really the only exit.
>>
I'm working on a project in java. Does anyone know how to limit the number of characters per line that are printed as output to a text file. I have everything figured out but how to limit the number of characters per line to 320. Once that limit is reached, the string needs to end, and pickup where it left off on a new line. Below is a link that takes you directly to three txt files (they are safe I swear). One is an example input file, one is a file with the correctly formatted output, and the other is what my output currently looks like.

public class Processor {

private int length;
private int length1;
private int lineLength;
private HashMap<Integer, LinkedList<String>> map = new HashMap<Integer, LinkedList<String>>();
private String[] columns;

public Processor() {
finalArray = new String[0];
}

public String generateReport() {

String output = "";
String line1 = "";
String output1 = "";

for (int c = 0; c < 15000; c++) {
if (map.get(c) == null) {
System.out.print("");
}
else {
for (int z = 0; z < 1; z++) {
output1 += "If ";
output1 += "IsCPT" + "(\""
+ map.get(c).toString().replace(" ", "") + "\"" + ")";
output1 += " Then\n If Quantity > " + c + " AND Allowance >"
+ " 0.0 Then \n HoldBill(\"MUE Edits\")"
+ "\n End If\n";
if (c >= 1) {
output1 += "Else";
}
if (output1.contains("[")) {
output1 = output1.replace("[", "");
}
if (output1.contains("]")) {
output1 = output1.replace("]", "");
}
length = output1.length() + 1;
output = output1;
}
}
}
return output;
}
}
>>
>>52407652
already did. i'm posting as a zombie
>>
>>52407582
do something new and creative. learn opengl and make a cool game
>>
>>52407582
I've been programming for a while, and every so often, I would get in a sort of rut where everything I wrote felt boring and useless. I always would come out of it though, sooner or later. I think personally, hobbies shouldn't get you anywhere as a requirement. It just so happens that this one gives you big career opportunities as a developer.

>>52407652
Have you ever considered the impact your words have on real people?
>>
>>52407675
This is my biggest fear, if I make the decision to to kill myself I sure hope there is nothing else.
>>
>>52407665
>for (int z = 0; z < 1; z++)

You know that's only going to run once right? You can remove it.

Also use modulo in this case.

if (c % 320 == 0)
System.out.println();
>>
>>52407665
here
public class FuckThisShit {

public static String lineSeparator =
System.getProperty("line.separator");
public static int LIMIT = 20;

public static void main(String[] args) {
String read = "your fucking text here";
String[] wordArray = read.trim().split(" ");
printBySize(LIMIT, wordArray);

}

private static void printBySize(int size, String[] wordArray)
{
StringBuilder bld = new StringBuilder(size);
for (int i = 0; i < wordArray.length; i++) {

String word = wordArray[i];

if ((bld.length() + word.length()) >= size) {
bld.append(lineSeparator);
System.out.print(bld.toString());
bld = new StringBuilder(word);
}
else
bld.append((bld.length() == 0 ? "" : " ") + word);

}
System.out.println(bld.toString());
}
}
>>
>>52407665
if string.length > 320 {
print(string.substring(0, 320))
print(string.substring(320, string.length))
}

or however it is in java.
>>
showBoard board = unlines [row tl t tr, "-+-+-", row l m r, "-+-+-", row bl b br]
where
[tl, t, tr, l, m, r, bl, b, br] =
zipWith (\i c -> if c == Blank then show i else show c) [1..] board

row x y z = x ++ "|" ++ y ++ "|" ++ z

main = putStr $ showBoard [X, O, X, X, Blank, Blank, Blank, O, O]


X|O|X
-+-+-
X|5|6
-+-+-
7|O|O


my showBoard function seems like a hack ;_; pls help
>>
>>52407729
>Have you ever considered the impact your words have on real people?
What a strange thing to say on 4chan.
>>
>>52407801
What about
type Row = (Cell, Cell, Cell)
type Board = (Row, Row, Row)
>>
File: geeky girl feminism.jpg (360KB, 500x2094px) Image search: [Google]
geeky girl feminism.jpg
360KB, 500x2094px
>>52407729
>Have you ever considered the impact your words have on real people?
>>
>>52407750
thanks for the tip on the for loop. not sure what i was thinking. Sorry for the further ignorance, but where would I place the if statement you listed.. c is just referring to hash map key. for instance, map.get(c) (where c equals 1) would print all the values that are tied to key 1... or am i thinking of this wrong?
>>
>>52407837
ooooh I like that
>>
>>52407872
Don't copy that verbatim, it's just to get your mind thinking. You have to track how many characters you're going to use, including whatever comes out of the hashmap and the string literals you have there.
>>
File: bawwwww.jpg (36KB, 264x373px) Image search: [Google]
bawwwww.jpg
36KB, 264x373px
>>52407849
>that comic
so what if i don't look like superman just deal w/ it or put some work in to get your body into shape
>>
>>52407820
This is /g/, not /b/. Nobody comes here looking for a hugbox, but couldn't you come into /dpt/ with some basic human decency?
>>
>>52407927
kill you'reself
>>
>>52407611

So, .bash_profile gets called whenever I ssh, and .bashrc gets called whenever I open the terminal normally, and .profile gets called when I log into KDE...

Since .bashrc does not exist (yet), and I want to duplicate the functionality in my existing .bash_profile, would it make sense to simply just do:
cp .bash_profile .bashrc
>>
>>52403869
Op redpill me on that boy.
>>
>>52407886
In fact, you can even get GHC to write a lot of boilerplate for you

{-# LANGUAGE DeriveFunctor, DeriveFoldable, DeriveTraversable #-}

type Row a = (a, a, a)

newtype Board a = Board (Row a, Row a, Row a)
deriving (Eq, Show, Functor, Foldable, Traversable)
>>
>>52406167
I don't want to use some retard's awful wrapper library. I don't use libraries in my code -- they break too often.
>>
>https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-user/Unix-Installation.html
Move into the new directory:
cd mit-scheme-VERSION/src

Configure the software:
./configure

Build the software:
make compile-microcode

Install the software:
make install

>goes to the effort of explaining which directory to go to to run the configure command
>doesn't do the same for the compile-microcode or the make install command
>Version/src doesn't work
>REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
>>
>>52406644
MIT/GNU Scheme and xscheme. Runs like a dream.
>>
>>52404296
>>52404021
Why would anyone want to literally implement C With Classes?
>>
>>52407551
Nigga, I ain't got clue 1 what I'm doing. I'm just trying to compress a string and save it, so I can uncompress it later.
In that code, the error is happening when I try to cout any index of c.
>>
>>52407948
just put all the exports in .bashrc or in .profile
my .profile looks like this
....
export JAVA_HOME=/opt/jdk1.8.0_25
export PATH=$PATH:$JAVA_HOME/bin

#set calendar to start on mondays
export LC_TIME="en_GB.UTF-8"
>>
>>52407969
i agree that libraries and especially trivial wrapper libraries should be avoided. as for the platform APIs it's up to you but i think it would be fine to have modern C++ mixed in with old-style C stuff specifically for the APIs.
>>
>>52407965
what does all that do?

I rewrote mine to look like this
data Cell  = X | O | Empty Int deriving Eq
data Row = Row Cell Cell Cell
data Board = Board Row Row Row

instance Show Cell where
show X = "X"
show O = "O"
show (Empty i) = show i

instance Show Row where
show (Row a b c) = show a ++ "|" ++ show b ++ "|" ++ show c

instance Show Board where
show (Board a b c) = unlines [show a, line, show b, line, show c]
where line = "-+-+-"

main = print $ Board (Row (Empty 1) (Empty 2) (Empty 3)) (Row (Empty 4) (Empty 5) (Empty 6)) (Row X X O)
>>
>>52407947
I guess not.

>>52407997
That's because c isn't a pointer to a bunch of characters. It's an array of pointers to characters - in other words, it's an array of memory addresses, not text.

Are you trying to cout it inside the function c is declared?

>>52408041
I'm interested to learn as well
>>
>>52407987
I was kinda wondering the same thing.
There's no "self" in C, so you have to pretend using function pointers and feeding the member function with it's own pointer.
As I understand it, C++ does this too, but it abstracts it away from the user during compilation.
>>
>>52405575
Vb. Net
>>
>>52408051
Yeah, I wrote cout << c[0] << endl; immediately after the compress() line.
>>
Why
>>
>>52408041
>>52408051
You get all of these for free for your fixed 9-element "list":
fmap
everything in Data.Foldable
everything in Data.Traversable

So, for example, you can turn Board into a list if you really want to. You can also fmap over it, fold[lr], etc

This relies on GHC's ability to derive Functor, Foldable and Traversable automatically for the Board type.
>>
>>52408041
Looks good. Now it's a bit more verbose, but you will probably agree that it's quite safer.
>>
>>52408004

If I put all of my exports in .profile, then LD_LIBRARY_PATH will not be exported. If I put them all in .bashrc, then I can use LD_LIBRARY_PATH from the lab machine, but not when I am ssh'd into it. If I put exports in both .bashrc and .bash_profile, my $PATH exports will be added twice.
>>
>>52407519
I need to find a way to simultaneously become a competent artist as well as a decent programmer so I can reach this goal too.

Writing stories or text adventures is fine and all, but making a full blown thing with art would be way more fun I think.
>>
Are desktop applications dede
Do people only care about web apps and mobile apps
>>
Holy fuck why is getting Emacs semantic to parse windows.h such a nightmare. It just ignores all of these preprocessor defines and doesn't actually include anything important, like winuser or wingdi...
>>
>>52407519
That's my next goal after I finish this project... heh...

>>52408282
For me, text is all I want and need
>>
Need to learn some nonbasic SQL in like 2 days. How do I go about this?
>>
>>52408371
How did it become 2 days, anon?
>>
>>52408389
I did the initial phone interview 2 days ago and got confirmation on the in person interview yesterday. I have a storied history of procrastinating, but this time not really.... pls help
>>
What are some examples of excellently written C libraries? I don't think I've encountered a single sane, reasonable library that's actually worth using.
>>
>>52408288

That depends, which "people" are you talking about? Obviously performance intensive applications belong on the desktop. For anything else, it depends upon which market one is trying to target, and for many cases, it may be wise to make both a desktop and a mobile application.
>>
>>52408423
http://www.w3schools.com/sql/

http://sql.learncodethehardway.org/book/

http://www.sqlcourse.com/

https://www.codecademy.com/en/learn/learn-sql
>>
>>52408454
SDL
>>
>>52408454
pick one
https://notabug.org/koz.ross/awesome-c
>>
>>52408474
Does SDL support custom memory allocation? It looks neat but I don't want a library mallocing and freeing a thousand times a second.
>>
>>52408527
http://www.libsdl.org/tmp/SDL/src/stdlib/SDL_malloc.c

You can modify this however you like.
>>
>stack installing specific ghc version fails
>and I need it for yesod
>ncurses haskell binding reports "all builds failed as of 2015"
>and also failed for me
i really wanted to /haskell/, but welp
>>
>>52408527
No.
>>
>>52408580
--skip-ghc-check


Also, post results
>>
>>52408423
If you understand joins (and their performance repercussions) you are a fucking genius compared to most entry level retards. If you don't already know joins you might be fucked.
>>
>>52408527
Kek. Why does it matter if a library mallocs for you? Don't be such an autist.
>>
Any good C libraries for random generation, preferably with SSE paths?
>>
>>52408454
Lua as a C library. Allows from using Lua as a controller language, immutable string objects and methods to operator on them, tables (hash map and dynamic array) and methods to operator on them, closures, gc, and
>>52408527
custom allocation.

The API is pretty sane, the code itself is very short (only 20,000 lines), compiles anywhere because it's ANSI C, performance is okay, but the code is a bit of a quagmire (abuse of the preprocessor and typedef for unnecessary code "abstraction").
>>
Why do programmers from different backgrounds with different expertise and specializations have completely different jargon, conventions, and idioms that they expect everyone else to immediately understand or else assume that that person clearly doesn't know what they are doing and deserves to be treated like an infant?

Why is there this prevalent opinion being espoused lately that it's OK for open source software to suck because the developers are doing it for free and you should be grateful or do it yourself? Methinks this has actually been a long-held belief in the more incompetent, mainstream, normalfag OSS communities and speaks to their collective insecurity towards their own mediocrity and inability.

Also who is this Maki bitch and why is she being posted everywhere
>>
>>52408604
at least its compiling now (and using all my mem)
>>
is there some kinda a chart that says "how long" different basic c++ operations take?
>>
>>52408770
>Anything with std::string
Forever.
>Anything with too many angle brackets
Forever.
>Really anything that's not from the cstdlib
Forever.
>>
>>52403869
/sci/ here.

I'm trying to compare the efficiency one of my algorithms. Unfortunately the paper I'm using only quoted how long their runs took instead function evaluations (seriously, why?).

My question is how "good" is a "64 bit Xeon 3.2GHz processor"?

I'm using an "Intel Core i30 530 2.93 GHz". Is that worse or better?

Mine has 4 cores, but the interpreter only uses one. Obviously the clock speed is slower, but I'm guessing there's more to it than clock speed?


I hope my question isn't too off topic. I don't really know where else to ask, /g/ in general seems more about consumer product brand names than the minutiae of hardware.
>>
>>52408785
>forever
>actually 0.01 seconds

wewlad
>>
>>52408787
Xeons are typically high-end server processors. i3s are curry-nigger tier.
>>
>>52408787
an i3 is significantly less powerful than a Xeon in almost every case including this one
>>
>>52408785

>>Anything with std::string
>Forever.
If you reserve memory ahead of time, it's fairly fast. Same with vectors.

>>Anything with too many angle brackets
>Forever.
Templates are zero cost in terms of generated assembly. They can take forever to compile, however.

>>Really anything that's not from the cstdlib
>Forever.
std::sort beats out C's qsort. Software written in C++ can be faster.
>>
>>52408806
in computer terms 0.01 is forever, typically we work in microseconds (0.000001)
>>
>>52408808
That is very good news for me thank you.

I've never been so happy to have my hardware insulted.

>>52408828
Thanks anons.
>>
>>52408850
>std::sort beats out C's qsort. Software written in C++ can be faster.

This is true, but I don't know anyone who actually uses C's qsort. Most C programmers are used to rolling their own algorithms specific to their use case, which will almost certainly outperform the C++ implementations.

It is relatively harder to "abuse" C. It is very, very easy to abuse C++ features and balloon your execution times to absurd amounts.

>>>Anything with std::string
>>Forever.
>If you reserve memory ahead of time, it's fairly fast. Same with vectors.
I literally "ported" a genetic algorithm implementation to C and replaced his use of std:string with char arrays and modified them directly instead of using C++'s retarded functions. My implementation ran 25x faster.
>>
>>52408906
why did it use strings anyway
>>
File: 0001.png (82KB, 1761x1010px) Image search: [Google]
0001.png
82KB, 1761x1010px
Where did my sidebar with my project's tree go /g/uys T-T ?
>>
>>52408951
Storing the chromosomes as a series of characters. I assume he drank too much of the C++ kool-aid.
>>
>>52408787
Clock speed is nowhere close to the whole picture. Modern CPUs get faster by performing not more clock cycles, but more operations per clock cycle. That's what they use all the extra space on silicon for when they shrink down the transistor size.

Take a look at these two processors.

https://www.cpubenchmark.net/cpu.php?cpu=Intel+Pentium+E5800+%40+3.20GHz&id=1102

https://www.cpubenchmark.net/cpu.php?cpu=Intel+Xeon+E5-2695+v3+%40+2.30GHz&id=2371

Both top out at around 3.25 GHz, but one is an order of magnitude faster.
>>
>>52408051
>>52408113
>>52407551

Alright so I've got it 99% working now, except I've got it working with char arrays instead of a text file, which is what I really need to compress. Instead of compressing a text file directly, would it be easier to create a MASSIVE string with all the text that I need, compress the string, and then save that to the text file, or is there a better way?
>>
>>52409054
How big are we talking with this text file?
>>
File: 1lJ7wQU.png (9KB, 234x294px) Image search: [Google]
1lJ7wQU.png
9KB, 234x294px
>>52408963
nvm, im a fucking retard
>>
>>52408787
what year is the paper from? the xeon is probably faster than or as fast as your i3 since it's only a first-generation i-series processor. but your i3 could be faster if it's an old xeon and if the software is only running on one thread
>>
>>52409101
34 lines, about 2 kilobytes.
>>
>>52409130
>>52409101

I should have said, that's just as it is now, but later it will probably get much bigger, possibly over 100 lines.
>>
Has anyone used/tried Elm? Thoughts? Should I switch from React?
>>
>>52409130
>>52409143
That's still tiny as far as computers are concerned. You could easily do this in memory yourself and then just save it.

But if you were planning on going to and from a file this whole time, you really could have just done
execl("/usr/bin/gzip", "gzip", "-k", "mytext.txt");

this whole time. If your text file was hundreds of megabytes to gigabytes, I would recommend doing this exclusively. But for small files, execl can sometimes be an inconvenience or, for many small files, a source of poor performance.
>>
>>52409211
I have to do it in my C++ program. It's a save file for a game, and I'm not compressing it to save space, I'm compressing it because I don't want the player to mess with it.
>>
>>52409237
Ahh, I see - clever. You're a sneaky one. I wonder if that's what the garbled formats of some /d/ esque games that I've played used.

Yeah, your best bet is to just compress the whole thing at once in memory and then save it.
>>
>>52409282
>Ahh, I see - clever. You're a sneaky one.
Isn't that how all games do it? Open up a save file from any game in Notepad, it's all just a bunch of garbage.

>Yeah, your best bet is to just compress the whole thing at once in memory and then save it.
So I gotta make that huge-ass string. Oh boy, this is gonna be fun.
>>
>>52409346
Sometimes, other times games will just directly serialize the classes that make up their game state in binary.

Not to get you too far off track, but you might be interested in https://developers.google.com/protocol-buffers/?hl=en , as well as other libraries like it. It does this sort of binary serialization I just described.
>>
>>52409237
I look forward to breaking whatever crypto you use to cheat in whatever game you're making.
>>
>>52409346
>>52409384
(by the way, if you do use binary serialization, you can still apply compression with zlib for further obfuscation)
>>
>>52409403
I would like to see you break herocore.sav

https://tcrf.net/Hero_Core
>>
>>52409384
>>52409499
>>52409403
And what about things like art, music, ect? How do I keep players from messing with those? Obviously I can't use code.
>>
why am I afraid to program /dpt/?
am I afraid to fail? disappoint myself?
am I losing my passion? help me /g/.
>>
>>52409553
Nice.

But forbidden cheating is stupid.
>>
>>52409653
I agree.
>>
File: Remember-the-quitters.jpg (197KB, 576x576px) Image search: [Google]
Remember-the-quitters.jpg
197KB, 576x576px
>>52409645
You can do it anon!
>>
>>52409642
You're getting into DRM territory here. I strongly dislike DRM, but since you're writing a game I'm willing to help you. Feels unnecessary to me, but as cheap validation you can hash all the game assets, and if the hash doesn't match the one provided in your program, quit. Make sure you don't use any libraries that are GPL3.

>>52409653
I agree as well. At the least, you could keep the obfuscated format and make a save editor that enables a "CHEATER" flag whenever it saves.
>>
>>52409645
Treat programming like a sex game. Edge yourself until you reach a certain milestone in your problem. Afterwards you can treat yourself to a big release! Keeps things fresh and yourself programming for a reward now.
>>
>>52409642
You can't.
>>
So I don't really understand nonlocal in Python. Is it that if a name isn't found in the local scope it checks the global scope next, which is usually the module, instead of checking enclosing functions first?
>>
>>52409729
>enclosing functions
enclosing functions or calling functions?
>>
>>52409676
>>52409715
ok :')
>>
>>52409715
Oh shit man, I do that sometimes

It's actually made me really productive when I've done it.
>>
>>52409698
I hate DRM too. Would you really consider that DRM? I've never seen any game with all the assets available for anyone to edit. The closest I've seen would probably be Papers, Please. All the sound effects were in an /audio folder, but the art, dialogue, ect. weren't easy to get to. I guess it would make modding extremely easy, but my game isn't really mod-potential.
>>
I'm creating a small bash script to move a bunch of video files into directories based on their title.
I want to have a text file that contains a bunch of aliases between series titles and what I actually want to save them as.

For example, I have a file "[Commie] Ace of the Diamond ~Second Season~ - 40 [31261AE1].mkv".
Using sed, I get the title down to "Ace of the Diamond Second Season". What I actually want to save it into is "Ace of Diamond S2".
I want to have a text file which is contains a bunch of entries like "Ace of Diamond Second Season=Ace of Diamond S2" or whatever.

What would the easiest way to do this using bash?
>>
>>52409743
That's the thing. I'm not certain what it's supposed to do. I was talking about definition, like
def factory(n):
def addn(x):
return x + n
>>
>>52409761
Except not the edging, I just wait till I finished the goal to "collect" the reward. :^)

>>52409762
By the laymen's definition it isn't. I don't really have any idolization for the FSF, and honestly, as long as you don't implement "real" DRM by consumer standards I have no real aversion to what you're doing.

But the point about GPL3 still stands - the GNU project for example would consider this to be DRM and they actually have a clause in the GPL3 explicitly forbidding this use case (because in GPL2 someone used it as a loophole and there was nothing the FSF could do about it). So don't use any GPL3 licensed libraries, otherwise you might have a problem.
>>
best c programming book?
>>
>>52409796
So it's enclosing functions.
>>
>>52409838
K&R, of course.
>>
>>52409777
Easiest way is to not use bash. If you know another language use that instead. There really is no need to learn bash (the language that is) in 2016.
>>
>>52409117
2007. I think I bought my i3 in 2010 and it was old even back then.
>>
>>52409839
I know, but that doesn't answer my question. Luckily this helped. https://stackoverflow.com/questions/1261875/python-nonlocal-statement#1261961
It's essentially just making variables be captured by reference instead by value. So what are the use cases? All I can think of is using closures to implement private data in functions.
>>
>>52408999
Thanks for the info.

I think I found out why they don't have NFEs, the Jews who distribute the commercial optimisation software they were running does not give number of func evals for the free version.

>>52409117
Do you happen to know if commercial "block box" software like GAMS use multiple or single thread processing?
>>
>>52408787
Benchmark both on the same hardware. That's the only way to get a clean comparison. Eliminate as many confounding variables as possible.
>>
File: 1407381052923.jpg (32KB, 256x286px) Image search: [Google]
1407381052923.jpg
32KB, 256x286px
Does anyone here have any experience with Spring + Thymeleaf intergration?
If so, how can you call a null function using thymeleaf? as far as I can tell, the only thing you can do is call getters and setters for variables and there has to be a better way to deal with it other than being hacky as fuck.
>>
>>52409862
Dumb python memer.

Anyway, I figured out how to do it:
tmp=$(fgrep -m 1 "$title" ~/series_aliases)
if [[ $? -eq 0 ]]
then
title=${tmp##*=}
fi
>>
Do people unironically use arrays to implement linked lists?
>>
new thread when
>>
>>52410054
I really can't understand why people think bash isn't a complete joke these days. Most systems come with objectively better languages for shell scripting (perl or tcl) or general purpose scripting languages pre-installed. Bash is untyped, relies upon outside programs for ANY functionality, and is slow as misery.

The only reason people used previously was because it was a system standard and small. Lua is smaller and consumes less resources at idle if you care that much. And being a standard isn't even a valid strength in today's age; we have the internet for package distribution.

>>52410091
Yes. It's really the only way you should implement lists in a professional piece of software. Linked lists become horribly inefficient as they grow because a lack of data locality.
>>
>>52409751
well I've reached a milestone. thanks.
for ( ;  c <= 127; c++)
printf("%c\n", c);

this produces an infinite loop whereas every number less doesn't.
127 is DEL's ASCII code. Does anyone know what is being deleted here?
Every ASCII character gets printed during the infinite loop.
DEL prints out as some strange left square bracket.
>>
>>52410236
You are overflowing your char. Good god.
>>
>>52410262
my assignment is to find the limit of every C variable type without hard coding any information.
do you have any tips?
>>
>>52410291
You're not supposed to do that. You're supposed to watch for overflows.
>>
>>52410291

#include <limits.h>


Required to be provided in all standard C environments, even when producing a standalone application.
>>
>>52410291
Fill number of each type with CHAR_BIT*sizeof(var) number of 1s and print. For signed values do CHAR_BIT*sizeof(var)-1 1s.
>>
>>52410291
loool
>>
>>52410226
I'm writing a shitty 40 line script which moves files around.
I think bash is completely appropriate here.
>>
>>52410349
Any language you know with a good number of built-in string manipulation routines is as good, in fact better, than bash.
>>
>>52410226
bash is a DSL and a huge standard around the world for shell scripting and writing programs. As long as you're not trying to use it for general purpose programming, you'll often have an easier time with bash than some scripting language like Lua that isn't designed for shell scripting.
>>
>>52410384
Here is my entire, completed script:
#!/bin/bash

pushd ~/Videos > /dev/null

for file in *
do
if [[ -d $file ]]
then
continue
fi

title=$(sed -e "s/_/ /g" \
-e "s/^\[[^]]*\] //" \
-e "s/ - [0-9]\{1,2\} .*$//" <<< "$file")

tmp=$(fgrep -m 1 "$title" ~/series_aliases)
if [ $? -eq 0 ]
then
title=${tmp##*=}
fi

dest="Anime/[Airing] $title/"
if [[ ! -d $dest ]]
then
echo "Making directory \"$dest\""
mkdir "$dest"
fi

mv "$file" "$dest"
done

popd > /dev/null


I have VERY powerful string manipulation available to me with sed, and with grep, I was able to parse a file in only a few lines.
How would using another language make that any easier?
>>
>>52410406
>you'll often have an easier time with bash than some scripting language
No... If you want to do something that tools like cut, sed, grep, bc, etc. can't handle you have to write in another language. Lua is specifically meant for shell scripting, but Perl is superior in every way and every Unix-like I've ever heard of has perl available to it. Why do you think most system utilities in most Linux distributions are written in perl or python and not bash? Bash sucks, bash is outdated. I don't care if you learned it long ago and are accustomed to it, but there is no reason to learn it new.
>>
>>52410484
>Lua is specifically meant for shell scripting
What? No it's not. It's designed to be easily embedded into other languages.
>Why do you think most system utilities in most Linux distributions are written in perl or python and not bash?
Nobody is saying that people do or should write shit like that in Bash. Bash is for glueing other shit together.
>>
>>52410470
>How would using another language make that any easier?
Because you can, in addition to writing your shitty little script, write more complicated programs in another language. Why know bash and something else, when you could just know something else? Just for performance reasons no one would ever write a program in bash, not to mention what a nightmare developing it would be.

>>52410518
Sorry, I have a habit of leaving on contractions.
isn't*
>>
>>52410543
>leaving on contractions.
HOLY FUCK.
off*
>>
>>52410543
>Why know bash and something else, when you could just know something else?
Nobody is trying to write complicated programs with bash, you idiot. Why have more complexity than you actually need? Why not just write it in ENTERPRISE Java?
>Just for performance reasons no one would ever write a program in bash, not to mention what a nightmare developing it would be.
You clearly don't understand the point of bash. As I said before:
BASH IS FOR GLUEING OTHER SHIT TOGETHER
>>
>>52410608
>BASH IS FOR GLUEING OTHER SHIT TOGETHER
And you can do that in other shell scripting languages just, or nearly, as easily; bash isn't the only one. So what's bash use? If someone came to me and asked me if they should learn bash, I'd say no. I'm not trying to convince you to unlearn or replace it, just not to hold it up as if it's still got special advantages.

In other words bash is DEPRECATED. To be kept for compatibility in Unix. Maybe one day C will be tugged out from under Unix as well, but I doubt that day will be soon.
>>
>>52410679
>Maybe one day C will be tugged out from under Unix as well, but I doubt that day will be soon.
Just out of curiosity, which language do you think will do that?
>>
>>52410718
Not him, but one that does not currently exist.
>>
File: holyshit.jpg (5KB, 201x249px)
holyshit.jpg
5KB, 201x249px
>>52410679
>In other words bash is DEPRECATED.
>>
>>52410718
Him, does not exist yet. C++ is too un-Unix (muh OOP). Rust tries to be too high-level and will always be slower. D likewise. All other languages are just out of the question.

>>52410730
Not the shell, well maybe... zsh is too good.
>>
>>52410869
>C++ is too un-Unix (muh OOP)
That's not the only reason that C++ is nowhere near being a viable replacement for C.
>>
I have a rails question

I'm trying to model a database for my website and I'm trying to conceptualize how one would go about structuring a table that has a ManyToMany relationship with itself. I'm very new to programming and web development so explaining it in in laymen terms as best as possible is preferred. No need for specific code, just theory behind how one would structure such a database. Here's an example of what I'm trying to do and the best way I can explain it... using cats!

Let's say I have a table that lists cats and the relationship between itself is a representation of their mating pattern. Cats will mate with many other cats so each cat is a OneToMany relationship with a bunch of other cats. The initial thought would be to separate the cats into two tables of Male and Female and solve this issue classically with an intermediate table holding keys, however, this doesn't allow data for homosexual cats or bisexual cats. So how does one represent the mating details of these cats structurally in a database?
>>
>>52400261
>>52400261
>>52400261
>>52400261
>>52400261

NEW THREAD
>>
Any suggestions for which C++ book I should read? Currently thinking of reading C++ for everyone 2nd edition.
Thread posts: 340
Thread images: 32


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

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


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