Actual fucking programming edition.
What are you working on, Sup Forums?
Previous thread:
Actual fucking programming edition.
What are you working on, Sup Forums?
Previous thread:
Other urls found in this thread:
youtube.com
github.com
youtube.com
twitter.com
Xth for programming music:
Nice thread :)
I'm writing a bootloader for an NXP microcontroller
Writing a game in Purescript.
Unfortunately my codebase become big enough to make compilation slow, and my macbook air is slow enough to make the development painful.
What should I do? I can get an iMac to enjoy the power, but then I will not be able to code everywhere.
Alternatively, I can use a cloud server+rsync to enjoy the remote power. But I'm not sure how the lag will affect the process, and I don't know how much I will waste setting things up.
What shall I do?
What is the most performance-saving dummy generating method?
openssl rand 1024 -out dummy.tmp
Is what I use.
I finished new raycasting algorithms for my minecraft clone. So far it is more accurate, conciser, more generalized, way faster, and just generally better in every way.
I'm going to work on sprucing up the appearance of the water now.
Fix up your makefile so you recompile less when you make changes. Split your codebase into smaller chunks.
Maybe try programming in a real language where you don't have to recompile the entire project every build?
>Fix up your makefile so you recompile less when you make changes. Split your codebase into smaller chunks.
Will not help, webpack will be building a one huge bundle anyway. And splitting every component into its own bundle would make build config too complicated.
>Maybe try programming in a real language where you don't have to recompile the entire project every build?
Meh, the only real language that will provide a quick change-reload cycle without a different hardware is clojurescript(figwheel is awesome). But any typed flavour of JS, Elm and Purescript are limited by webpack, which is too slow for me.
Updated my torrent site crawler to search Nyaa.
I just pushed out an FAQ section for the app I work on to 2.2m users...
fucking kill me now.
github.com
Neat
Nicely done user!
who else /greenprogramming/ here?
im writing spatial analysis functions that will be used to find the best locations for electric car charging stations, taking into account parking capacity, local population, distance to grid, etc.
i sold my soul for 2 years to the fucking oil corps and it feels so good to be working on something i can actually be proud of
I'm making an app on where to find the most healthy tree to cut down, and also an app to find all the near extinct specie animal to better hunt them.
NO
Your pic is extremely offensive to me. Go fuck yourself.
...
Thanks for supporting American fracking user!
Down here in Texas, I'm really glad that you're switching to natural gas, I mean electric power to drive your cars.
I'd also like to thank you for your support of the lithium industries. I have family in China making bank, and all that electrowinning needed for those lithium batteries and aluminum parts is really good business for the power companies I sell all my fracked natural gas to.
Gentlemen, take a note: this is what JavaScript will do to you.
>What are you working on, Sup Forums?
Exploring the deepest, darkest corners of Racket.
Does anyone actually follow all PEP8 rules?
>E128 continuation line under-indented for visual indent
>E501 line too long (85 > 79 characters)
Why not /dev/urandom?
No line of code should be over 80 characters save for URLs in comments if necessary.
Not him, but /dev/urandom is slow
If your CPU supports AES-NI, this is blazing fast:
dd if=/dev/zero bs=1024 count=1048576 |openssl enc -aes-256-ctr -pass pass:"$(dd if=/dev/urandom bs=128 count=1 2>/dev/null | base64)" -nosalt
(removed redundant dd)
True, but he didn't say it needed to be fast, just not system intensive. You're right that it's probably implied that he's really just looking for a faster method though.
how often do employers actually go to your github? and by employers I mean the average run of the mill no name company that most developers end up working at?
I know Google probably scrutinizes every line of code.
how do i motivate myself to learn qt so i can make a crappy project to put on github
>bs=1024 count=1048576
bs=1K count=1M
Will intro to programming on top of tough teachers for calculus 1 and intro to chem with a 30 hr work week be a bad decision for learning programming ?
General Leo, the brave
Fighterballs edition.
Spent this weekend + today rewriting part of a frontend React application in OCaml via Bucklescript.
I love OCaml.
>>>/wdg/
Wrong thread
nice
Install an integrated terminal, faggot
I'm thinking about creating a protocol & framework for creating TCG games like MTG or Hearthstone. It will have a novel crypto-based backend that allows you to play against another player with a direct connection (no middleman server), yet all the randomization is secure and prevents cheating. You'll be able to load a lisp program containing the rules of the game, which is evaluated in sync by the clients of both players. The goal is to allow anyone to experiment with new ideas for mechanics and rules, design their own sets of cards, etc. It would be amazing if it could replace systems like cockatrice and MTGO, but I'd need help from people who can build nicer GUIs after I finish a proof-of-concept.
However I'm wondering how general such a framework should be. I could make it extremely general, allowing a broad scope of games to be implemented, such as battleships, poker games, maybe even slot machines and multiplayer minesweeper. OR I could design it with TCG games in mind, so that the protocol is simpler, and the UI is more friendly for these kinds of games, but is exclusive to those kinds.
Any opinions, Sup Forums?
How do I write cross-platform C?
Lots of #ifdef's
-Wall -Wextra -pedantic -std=c99 and MISRA C.
emacs, vim, or spacemacs?
Going through K&R
Is there any way I could improve this?
/* Exercise 3.2 - Write a function, esacpe(s, t), that converts
characters like newline and tab into a visible escape sequence
as it copies the string t to s.
Use a switch statement
*/
void escape_to_char(char s[], char t[])
{
int t_ind, s_ind, c;
t_ind = s_ind = 0;
while( (c = t[t_ind++]) != '\0') /*get character at current index */
{
switch(c)
{
/* place escape sequences, if there are any */
case '\n':
s[s_ind++] = '\\';
s[s_ind] = 'n'; break;
case '\t':
s[s_ind++] = '\\';
s[s_ind] = 't'; break;
/* place regular character */
default:
s[s_ind] = c;
}
s_ind++; /*move forward to place the next character */
}
}
vim is incredibly comfy
I'm using emacs with evil right now, it's comfy. It's hard to jump directly into spacemacs since it's basically emacs plus a fuck ton of plugins. I first switched from vim to emacs and decided to learn emacs from the ground up. But now I realize that vim has better shortcuts.
don't lie in your function signature
How am I lying? I'm copying t into s while making escape characters visible... Or am I just being a brainlet?
This might be a personal style choice, but I prefer passing pointers as arguments with the asterisk notation.
void escape_to_char(char *s, char *t)
Other than that, there's nothing off the top of my head to note, really.
what said
There's no such thing as an array argument
Alright cool I stick to misra anyway.
But what about the build system? How do people set up those programs where you go to a website and click "windows" or "linux" and out comes the appropriate build for your system?
Can travisCI do this?
Use cross-platform libraries and don't rely on undefined behavior.
Oh gotcha.
Thanks!
I would do
s[s_ind++] = '\\';
s[s_ind++] = 'n';
break;
Instead of deferring the statement s_ind++ at the end for no real reason.
It's idiomatic C to do this same thing by incrementing the pointer itself, instead of a index variable, e.g.
*s++ = '\\';
*s++ = 'n';
break;
I've seen this pattern in multiple C codebases.
I believe that the syntax is still correct, that's totally bikeshedding. K&R is an old book and does a few old C things that people don't do anymore.
If you're using Makefiles, create seperate rules for different platforms, and test them on the target platforms (you could automate this in travis) to make sure the binaries are built correctly. Automatic build systems like cmake have all sorts of options for making things cross platform.
Just did that as part of my internship
Learnt a lot
Good luck amigo
Like said, consider tracking the position in the string in the pointer itself using pointer arithmetic rather than using a seperate index variable.
Also you might want to indent inside your while loop but that's a style thing.
Did you purposefully forget to free(event)?
Also, why CSFML?
>Did you purposefully forget to free(event)?
there's more code after that (see the scroll bar)
What said.
Also, I just think sepples is ugly and convoluted.
>I just think sepplse is ugly and convoluted
Fair enough, but I guess I mean in comparison to using SDL or Allegro.
Ah, I getcha.
I guess I kinda wanted to expand my knowledge from the usual console output programs and SFML looked like a neat thing to pick up.
Does SDL and Allegro happen to be in native C?
You don't really need to free anything allocated in main, since the program terminates after main ends, and the OS cleans up everything after that.
I'm not too sure how I feel about the other anons suggesting using pointer arithmetic instead of array dereferencing. I always found array syntax to be cleaner to read than a clusterfuck of *'s everywhere. But it's really a nitpicky thing anyway.
"Array" arguments are lies, so I'd recommend calling them pointers.
But I will suggest this:
case '\n':
s[s_ind+1] = 'n';
case '\t':
s[s_ind+1] = 't';
s[s_ind++] = '\\';
break;
It's a bit less repetitious.
Hrm... I feel I should add something on to that last post. You definitely need to free everything in main if you are:
1. Recursively calling main for some reason.
2. Doing something dumb inside an atexit function that can take forever.
3. Using resources other than memory that may not be cleaned up immediately from the OS.
There is no harm in using free() inside main, but it is not typically required because execution does not typically continue after the main function. For all other functions, all resources should be freed. Using free() in main may help to develop a habit of freeing allocated resources regardless of necessity.
>does anyone [python]
Nobody that matters.
What you should have added is that if your main is calling malloc in a loop it should also free the memory it allocates.
Or you've allocated something so massive you'd page it out if you allocate more memory. That's another good reason to free.
How would you write a function that scans for floats fitting certain parameters? I don't know the alignment of them and I'm reading a binary file. All I have is a marker (ascii string) and I know I'll have zero or more floats in the block before the next ascii string.
I've already written a very ugly version but I'm not happy with it.
I feel like you should focus on card games, but not necessarily just MTG clones.
If you create generalized concepts like hands, decks, field slots, tokens, and cards in your rules, then you should be able to do everything from poker to MTG commander.
I'd resist the desire to make it so general you can program slot machines though. Focus on cards.
It sounds neat though. How would you handle RNG? Would it be through deterministic lockstep of inputs and coherency checks to make sure one player isn't cheating?
Sounds almost completely unnecessary.
Why would you choose to play with someone that's intending to cheat? The reason online games have these issues is because of the way people play games nowadays. What you're doing makes as much sense as anti-cheat for lan. But go ahead. I think it's a cool idea, even if it's not useful.
Post an example of what you're reading.
You say it's a binary file but you also say it has ascii strings?
If it's actually binary use hexdump to show us.
>if it's actually binary
It's binary. It just has some strings as markers. I've read the hex dump and interpreted some of it manually. It's just a lot to process.
I don't see why this would confuse you. Why would a binary file not contain string data? The reason I know I have floats stored is by inspection. There doesn't seem to be a nice system for offsetting off the strings. It must be defined in the binary that reads these.
>show us
Sorry. I can't.
The general question I'm asking doesn't need the file anyway.
Valid points as well.
I'm waiting to get done setting up new es clusters at work so I can pick up doing some tooling go.
I would like to put together a tool to do the majority of our maintenance, emergency and ordinary tasks with a convenient single thing. That way none of us need to write shit by hand and curl it up.
Normally I'd do it in python but distributing that can be a bit annoying.
There's so many variables user. Are the strings null terminated? Are the floats word aligned? What are the markers? What is the endianness of the binary file? What "certain parameters" are you looking for? Are the floats IEEE754? Are they some dark ages format from before 1980ish?
It's pretty easy to be confused when the person asking for help is working on some fucking SAP shit that he can't show you or can't talk about with any degree of concreteness. Ask the other spooks you work with.
SDL and Allegro are pure C libraries.
>this makes cpp fags happy
Pure C libraries are actually pretty great. It means that you don't have to make a C library wrapping around them to port them to other languages. And C++ never has problems using C libraries.
>null terminated
Technically at least. There's what seems mostly like zero padding but I do find that odd as:
>word aligned
No, the few examples I've done manually indicate no particular alignment. I've found 1, 2 and 4 byte aligned floats. At visual inspection at least. The other stuff is of course valid floats but usually you get stuff like #e-39. Seems unlikely.
>endianess
Big endian
>certain parameters
The routine I had in mind should take a function to evaluate the set of floats. I'm not sure what's relevant yet. Right now the floats I'm looking at look like human edited floats (nice round numbers like 0.1) but I'm sure most won't be.
>format
They're IEEE754.
>ask the other spooks
There are no other spooks.
Playing around in Julia, writing a very basic parser combinor library.
import Base.>>
abstract type ParseResult{T} end
struct Success{T} Success(foo(t)),x)
# foo :: (ParseResult{T})
function ifFail{T}(foo,res::Success{T})
res
end
function ifFail{T}(foo,res::Failure{T})
foo()
end
abstract type AbstractParser{T} end
struct Parser{T} >(p1::AbstractParser,p2::AbstractParser) = andThen(p1,p2)
function orElse{T,U}(parser1::AbstractParser{T},parser2::AbstractParser{U})
function innerFn(input)
result1 = runparser(parser1,input)
ifFail(result1) do
return runparser(parser2,input)
end
end
return Parser{Union{T,U}}(innerFn)
end
|(p1::AbstractParser,p2::AbstractParser) = orElse(p1,p2)
choice(listOfParsers) = reduce(orElse,listOfParsers)
Mostly fixed my parser up a bit so it produces a better parse tree (structurally, the "pretty-printing" still looks awful).
>There's what seems most likely zero padding.
They're probably not null terminated. The strings have a set size. Pretty common in old computers to have set string sizes in their files and pad out the remainder of the string with 0's.
I don't really have any ideas. Sounds like you're reverse engineering something. I'd just increment through the file one char at a time, reading a float at a time, see if I get a float that passes my standards, and if I do, record where in the file it is and increment the char pointer by 4 instead of 1.
Also worth marking where the padding is and how long it is.
In general I'd want to try to construct a file which contains format information for that file.
Doesn't Purescript support incremental compilation?
Actually interesting. I would suggest also allowing for supply piles to support deck-building games like the Dominion series.
You using flex and bison?
Also that's the edgiest hostname I ever seen in my entire life.
In a good way tho.
Like some good ol fashioned edgyness only warms my heart in an age dominated by pseuds and pinkpill anime nazis.
Are there any good yet language-agnostic solutions for generic cross-platform modular builds? Would Nix work?
Ragel and Bison, the glue language is D
>Also that's the edgiest hostname I ever seen in my entire life.
>In a good way tho.
>Like some good ol fashioned edgyness only warms my heart in an age dominated by pseuds and pinkpill anime nazis.
T-thanks
Why does Python exist? Why did it get more popular than, say, CL and Scheme?
Fast to get something going, straightforward, simple to use and understand largely, stdlib is pretty good, and lots of good libraries to use for pretty much anything you'd need.
At my work it's usually the first choice for anything operations, tooling or data based, besides Go for tooling/cli applications.
>straightforward, simple to use
I disagree. I think Scheme is straightforward, but not Python.
That's a you problem then, I can't help you with that.
how long would it take you to write a scheme program that does something useful like saving a webpage? not accusing, genuinely don't know. i think python's so popular because it has no real boilerplate
user pls
I can't bring myself to use Python or Go or JS
I don't blame you for JS, I don't like it too.
The others, not my problem, I have no issue with them.
Probably a couple of weeks, not long at all.
Couple of weeks is an awful lot longer than a couple minutes.
I stopped using Vim the day I saw that there were starving African kids on the Vim home page.
>Two (2) active /dpt/s
Starting master's program next month, gimme a good graduate level book for computer science
You have two sides to the invention of programming languages: the language design and the implementation (science, engineering).
In popular language design you have proclaimed "philosopher-kings", great engineers thinking they have the ability to invent good languages, but lack in the scientific ability.
It is true that Python is a piece of great engineering and generally a pleasure to use because it's pragmatic, has easy to understand tools, has nicely organized automatic documentation, etc. Language design is objectively inferior, Python can still not have an efficient compiler in the present day despite all attempts, while CL and Scheme have them since decades, and manage performance within 2x C, while Python is in 50-100x.
the other one is mostly shitposting
I want a generic way to search files in the file system in a VMDK (search via file name or file hash) I have searched quite a bit but have not found such a tool. Is this something I will have to create? If so would I need to mount each VMDK before searching the file system or is there be a non-mounting way to do it? Would there be a performance hit if I had to mount the VMDKs vs doing it in non-mounting way?
Which Nyaa?
Do you think he believes he's getting magically routed to a solar panel just because his car charger has the color green on it?
He knows where his electricity comes from. Even when it's not renewable renewable it's way more efficient getting your energy from a full size power plant than burning your fuel in the tiny engine of a car.
That's entirely Unity's fault, not JS's. They're not even using a standard JS engine, they're doing some weird shit where they build JS into DLLs.
In fact, apparently it's not even JS, it's some incompatible language with a different standard called UnityScript.
when it's not renewably sourced*
>Two (2)
I really don't understand this meme.