BI-YEARLY PROGRAMMING THREAD

BI-YEARLY PROGRAMMING THREAD
Working on code? Post it here!
Not working on code? Open your sh-compatible shell and type `echo $(( ( RANDOM % 145 ) + 1 ))` to choose a challenge. If you have any more of these programming challenges images, please do share.

NO BLOAT
NO OBSFUCATION
NO GAY SHIT

Other urls found in this thread:

blogger.programmingwiththegreats.io/blog/posts/public/february/public/01/public/posts/blog/why you should love the0dev0random0/
oforth.com/
github.com/GNOME/gnome-software
github.com/mvo5/synaptic
github.com/mvo5/synaptic/search?utf8=✓&q=apt-pkg&type=
github.com/Debian/apt/tree/master/apt-pkg
oxwugzccvk3dk6tj.onion/faq.html#how-do-i-format-my-text
gitgud.io/zyrod/zyrod
twitter.com/AnonBabble

Holla Forums only cares about browsers

$RANDOM is not POSIX sh, it's a bash extension. Shit op, shit thread.

/thread

Thread Sabotaged.

Fucking fa/g/s

Well shit

:--------DDDDDDDDDDDDDD

Don't forget expensive hardware solutions designed for problems they don't have.

right

tr -cd 0-9

Not POSIX

What the fuck is POSIX even useful for if it doesn't have the most basic shit

Made a bash script that takes a list of handles, gets all of their tweets, sorts it by date, and converts it all to a neat XML that doesn't make newsbeuter shit its pants. Was pretty difficult debugging because I didn't know about "set -x" until I was already done (and that I've never used bash). Took me about three days of non-stop (NEET) programming (figuring out REGEX and the clusterfuck of sed/awk/grep/egrep/gawk/gsub) to finally get something I'm proud of. Got a spiffy mandoc and some options. About 350-400 lines if you remove the mandoc and newlines. Was a pretty good experience.

/blog

seed=$(date +%H%M%S)i=1modulus=$((2

Any accidental entropy-destroying flaws that cripple the random number generator and make it unsuitable for real world use were inserted in the spirit of unix by the way

Why use something so bloated? Try this one-liner that I discussed in my blog[0]:

head -10 /dev/urandom | cksum | cut -f1 -d " "

-----------------------------------------------------------------------------------------------------------
Serenity is happiness and my happiness is a bacon and egg sandwhich in the morning!
[0] blogger.programmingwiththegreats.io/blog/posts/public/february/public/01/public/posts/blog/why you should love the0dev0random0/

This answer answered my original question pretty well. BUT, command prompt tells me head or cksum or whatever cut is don't exist???

Why is this in the unix forum?

Install Gentoo.

@863836
Moved to pozzers.united.anonymous.stackexchange.com/peepee-hurt%21
Thank you and remember not to necro bump or make duplicates
______________
Lebronious the Master Programmer
For the new guys who know, sometimes you just need a hand.
Blog | Skype | Myspace | Discord | AOL
IF YOU CAN'T HANDLE THE HEAT, STAY OUT OF THE CODE SESSION!!!

:below_the_waist_ok_hand:


The game

Reply to this post or your mom gets dicked
Thread derailed

/dev/urandom is not POSIX. head -10 (as opposed to head -n 10) is not POSIX. cut -f1 (as opposed to cut -f 1) is not POSIX.
And you're taking the first ten lines of random noise, which means you wait until there've been ten newlines, which is arbitrary and pointless and hard to reason about.
Consider me triggered.

...

Am doing bullet hell engine (120) in sfml, will post code when finished

Interesting one. I have given it a bit of thought but I'm not motivated for any kind of game programming.
I have done the ones about music synthesis and MIDI, they are my cup of tea. Now I implement some audio effects out of the dafx book.

lmao. stop using trash. use fish. it is the best shell
btw, Holla Forums can't program. also all those challenges are shit

I'm making a web server to expand my language knowledge with shit that I don't use at work every day but I'm still fucking around with server tutorials in both Go and Python and haven't decided which one I should use for the full blown actual thing. They both have a lot of disgusting aspects, but Go has the slight edge for not being some retarded whitespace language. Python would be more professionally useful for me to know but it just feels so degenerate to not have brackets. Also the 2.7/3.3 split is a little asinine.

Python 2 is being phased out left and right, from Operating Systems to I forget.

Official End of Life of Python 2 is 2020.

Just start coding in Python, by which is now almost universally meant Python 3, and don't worry about the rest.

Forcing people to indent so that their code doesn't look like PHP coders' spaghetti is not retarded.

And yet 2.7 is still critical to just about every Linux distro out there.

Python 3.3 is grossly outdated. I don't think it's supported any more. The current release is 3.6.
Python 3 is a better language than Python 2 in a lot of ways, some of them backward incompatible. The split is asinine, but having to deal with Python 2's bad decisions even more so. Go has vague plans to do a similar incompatible new version at some point.
Brackets don't matter. I think whitespace is a bit better but it's one of the least important aspects of the language. The reason people argue about brackets is that you don't have to know anything about the language to do so. It's bikeshed bait.
Python is a bit more useful than Go in general. It's very versatile. Comparing them isn't very sensible, though, they occupy different niches.


If I uninstalled it right now it would only remove libraries and a few applications, no system parts. I'm running Debian.
It's still used because upgrading takes effort. It's a bad idea for nearly all new code.

I feel like the only people who actually believe this are the ones who use whitespace languages.

I write code in whitespace languages, bracket languages and ALGOL-style languages, among others, and I haven't found a reason to strongly care. All text editors I use are intelligent enough to make it nearly irrelevant.

...

POSIX is UNIX weenies with political power. They get to force their "standard" onto vendors and users.

Heard in a talk by a vendor at a conference I was atrecently... ``The unix market has generally been more forgiving on quality aspects.''Gee, I always thought of the distinctive Unix level ofquality as unambiguously negative. But seen from the otherside, it has its advantage. First beat your customers intoa daze where they don't know good from bad, then lean backand enjoy the cash flow from putting out products that meetestablished expectations... Why didn't I think of that?


it *was* nice of British Telecom to force Sun to rename their white pages service to be something other than "yp") ...A crying shame too. After all, even though Sun's "yellowpages" service was really a white pages (name lookup)service, they should have been able to use whateverdeceptive name they wanted. Renaming things for marketposition is really a modern (not just unix) tradition:Build a presentation manager: call it Presentation Manager...Build a personal computer: call it The ibm Personal Computer...Build a machine with an 8-bit byte: Define "byte" to be 8 bits...Build a IO subroutine package: call it DOS (an OS).But the unix weenies have refined it to a high art.Everything must be "open" and a "standard." Why, my companyalready supports at least a dozen "standards!"The latest Sun entry is their new "free" window system.Their salesman called me proudly: all you need to do is sendthem a thousand dollars a copy, plus pay a royalty onprograms which use it, and you can use their new free openstandard window system (called "open look" of course).Hm, maybe I can add cons to C and call the result Lisp...

All the cool kids use printf(1). The echo(1) specification is full of implementation-defined behavior.

I was writing a ZilogZ80 cpu emulator, need to get back to work on it though.

post it on /byte/ when you're done
I will populate the board with more posts later
>>>/byte/

It'll probably be shit because I've never wrote an emulator before, but sure I'll post it.

Not taking the piss, how is this different from prog?

Isn't /prog/ absolutely dead?

Not much different from your board, eh? It gets close to 20 posts monthly.

When I have time I plan to flood my board with a deluge of manufactured posts and perhaps a low-frequency bot

Aight, I'll lurk and contribute where I can.

Take some advice from this thread:
If you want to get people to use your board you're going to need to build and foster the community. That is, hold community events and do small things to encourage participation like a tan-design or banner submissions or something. You could also do something like Holla Forums does and sticky important threads for awhile to get participation on big issues and such. Also consider ID's to curb the lowest-tier shitposters. Good luck with the board user.

First semester of C++, my classes are pretty horrible and mostly consist of me working through sicp while listening to business majors talk about twitch and complain about how hard C++ is. I think I'm going to rewrite a podcatcher I wrote awhile back to handle youtube RSS feeds and use the curl library if I can figure it out. This is my first reasonable C++ program.

/* Adds a list of fractions and outputs the simplified fraction. */#include #include using namespace std;int main() {/* * Define variables for the number for the iterator, the input, the numerator, * the denominator, and the denominator and numerator from the last iteration. */ int i = 1; int input; double old_den = 1; double old_num; double numerator; double denominator = 1; cout

Not a one line comment, not a two line comment, not even a three line comment, but a FIVE LINE comment. On a scale of "uses orthogonal in casual conversation" to "requires all assignments be turned in, in manually optimized binaries," how pedantic is your professor?

The best thing to do with C++ is use C-style syntax and C libraries.

He's not bad tbh. I think it's mostly because it's the beginning of the course and he wants to make sure we understand what we're doing, although I'm not sure how we wouldn't considering he mostly just gives us a problem and tells us to figure it out.


My thoughts exactly, this really bugs my prof though :P
I need to switch to cstdio, or I guess stdio.h to complete it then it should run in a c compiler I think.

you're a fucking retard

C only handles full and floating point numbers fucking retard

The entire point of programming is to make computers do things they didn't do before. It's absolutely possible to handle fractions in C. And that program isn't even written in C.
Honestly, I'm not sure what you're trying to say.

This is nothing in the entire world to do with int or float. It has to do with your interface not being smart enough to accept a string "5/10" and parse out the 5 and the 10 instead of having the user type each one individually.

And then you have the user fucking type "done" to finish what the hell.

Aren't Game Boy emulators exactly that?

it adds fractions and simpilifies, I'd like to be able to enter fractions, but I don't know how to do that yet. read first semester c++

Pretty close. The Gameboy has a Z80/intel8080 hybrid sort of CPU.

After you add your fractions, you should use a normalization routine to put them in a canonical form. Hint: Use the GCD algorithm, both the recursive and imperative versions are dead simple to write, and it'll save you from that abomination at the bottom of your code.

I'm confused what you mean, isn't that what I did?

I wrote a hexdumper in Retro Forth, going to work it further later. I posted it at >>>/byte/8, you should check it out if you like concatenative languages, they're quite like functional languages but (I would reckon) more readable and more practical. look at Joy as an example.

result of guy spotting a horse in the distance and saying, huh, that's a good idea. Then that guy goes off, with no further experience or knowledge of horses than this one glimpse, to invent the Ride-able Gimp(TM)
if you want a somewhat practical Forth-like language, at least go with Oforth: oforth.com/
The real thing is also available, and not that bad. My interest only waned when I found ATS - comparatively terrifyingly complex, but complexity wasn't my concern. My concern was always that the shittiness that most programmers deal with is actually non-beneficial. Languages like Python or Java only even exist because programming hasn't developed as a discipline enough to have good tools. Even when someone develops a straight metal hand-axe there are these apes who are completely sure that their bunches of twigs remain competitive.
a language whose total worth is summarized as: "I got people to pretend that 'concatenative' is some kind of special, meaningful category of programming language."

Retro is quite cool, it has the colours of colorForth implemented as prefixes and even conditionals are postfix. All implemented on a tiny MISC vm. Look at the docs, it's great.

WHy would I use Oforth over regular Forth (gforth or pforth or SwiftForth)

Your post reeks of tryhard.

of course a real program would accept a single argument which is the URL of the JSON object that it should decode to get its input.

nah that stench is "pent up with incomplete rants". Really the short story is just that I really hate Haskell.


Oforth has literal arrays and hash tables, and it offers explicit parameter passing in a language that is still otherwise very Forth-like. The arrays and hash tables you could graft on to Forth proper, but the parameterization you realy need another language for. This sounds like a small thing but Forth code tends to look like A B C D E F G where some of those words consume inputs and some of them emit outputs and you have to sit and study the code to reconstruct simple data flow. It's not for nothing that any Forth programmer you talk to will agree that some other Forth programmer's code is shit: any style variance interferes with how Forth programmers learn to intuit their own data flow. There's a lot of cool things about Forth but this is simply a burden and with Oforth you can avoid it.

How is the American Thoracic Society compare to C?

All I want is a concurrent array-oriented meta semi-functional language with mutability, lazy evaluation, strong static flow sensitive type inference, and some sort of safe compile time memory management.

Why doesn't it exist.

Come up with all the reasons to use C.

got it.

What happened to the prog fags? Board is dead. Only chan I know of that has a somewhat active board is lain. Is that it?

sup guys. NOOB here, I need YOUR help.

I am not new to programming, I programmed back in high school with c# and made little programs. I stopped for 2 years and now I want to get back to it, so I can prepare myself to enter a computer science degree in university. (right now i'm doing biology, and no, I don't want to do bio informatics)

Where should I go to learn? SICP looks pretty fucking old and heavy to me, is it really the only way or is it only a neckbeard meme?

post on >>>/byte/ and bring the legend back to life.

If you already know some c# learn c#, simple as that.

Sicp is a amazing book, but it's only helpful in its ability to make you learn some language other than scheme better.

Also for future reference, don't derail a thread with hardware/software questions. put that shit here

bump

thats 20 threads in 2 hours, no new content added to a single one, can someone please ban this nigger?

If you're going to post in the programming thread please post your code.

behold: top kek
nobodys posting anything in this thread
they havnt been for over a week

That's not an excuse to streetshit here.

gonna guess that youre probably him because nobody can be that unironically stupid

Filtered.

what did Go mean by this?

...

Go is extremely bizarre. I'm really not sure if it's a troll. The error on unused import and variables followed by producing a giant binary has to be a joke. The constant forced error handling is clearly a joke about C programmers never checking return values.
Interfaces are some weird OOP jab. Like the difference is instead of doing foo(object, val) you do (object) foo(val). That's like a zero cost abstractions joke.

I think the reason it feels so bizarre is because we're not the kinds of people it was created for. It was created for the kind of mouthbreathers that don't actually read the directions or attempt to understand what they're writing and just start copypasting shit into their code from stackoverflow. What the hell is "fmt"? Who cares, it'll automatically get imported when I save the file anyways. Code is spaghetti trash with orphaned crap lying around everywhere? Don't worry, just save it and it'll all be cleaned up!

45 - RPN Calculator - Common Lisp

(defun rpn-calculator (list &optional operand-stack) (cond ((null list) (car operand-stack)) ((numberp (car list)) (rpn-calculator (cdr list) (cons (car list) operand-stack))) (T (rpn-calculator (cdr list) (cons (reduce (symbol-function (car list)) (reverse (list (pop operand-stack) (pop operand-stack)))) operand-stack)))))

ez

96 - Generate a complimentary color from any input color - Common Lisp

(defun main (color) "Give the complementary of a hex color following " (rgbtohex (rgbcomplementary (hextorgb color))))(defun hextorgb (hexcolor) "string in, int list out" (format t "~% hexcolor: ~S" hexcolor) (list (parse-integer (subseq hexcolor 1 3) :radix 16) (parse-integer (subseq hexcolor 3 5) :radix 16) (parse-integer (subseq hexcolor 5 7) :radix 16)))(defun rgbtohex (rgbcolor) "int list out, string in" (format t "~% rgbcolor: ~S" rgbcolor) (concatenate 'string "#" (format nil "~2,'0X" (nth 0 rgbcolor)) (format nil "~2,'0X" (nth 1 rgbcolor)) (format nil "~2,'0X" (nth 2 rgbcolor)))) (defun rgbcomplementary (rgbcolor) "int list in, int list out" (format t "~% before complementary: ~S" rgbcolor) (let ((res nil)) (dolist (el rgbcolor (nreverse res)) (push (- 255 el) res))));; second method (floor (sqrt (- (* 255 255) (* el el)))) res))))

Neither of those things happen, it's a programming language, not an editor

I have a weird question, lads. I am thinking of making a package manager frontend (like Synaptic or Gnome Software) as a personal coding project, but I can't find any documentation on how to actually interact with the package managers with another program. I'm searching in the source code to these programs and I can't find the part where they actually query the installed programs, repos, etc. Do they literally just run the commands and then parse the output, or is there some buried API they're using?

Can anyone help me and point out which file is doing the work? Either is fine...
github.com/GNOME/gnome-software
github.com/mvo5/synaptic

Yes. That is the Unix/Linux/Gahnoo/Loonix way.

libapt-pkg

oh nice, so this stuff?
github.com/mvo5/synaptic/search?utf8=✓&q=apt-pkg&type=
github.com/Debian/apt/tree/master/apt-pkg

That's good for apt, but I don't see an equivalent for DNF for instance. So do some package managers have a low-level API while others don't? For them is it still like this guy >>876411says?

Trying out ATS2 today. Gotta say I don't get it at all. Getting the compiler working took a while and there are very few examples but whatever. I managed to get as far as trying to apply a function over a list before I got confused by types.
The error messages are classic stuff though.
273(line=17, offs=10) -- 273(line=17, offs=10): error(3): unsolved constraint: C3NSTRprop(C3TKmain(); S2Eapp(S2Ecst(S2Eapp(S2Ecst(add_int_int); S2Evar(m(8767)), S2Eintinf(1))), S2EVar(5095->S2Evar(n(8768)))))typechecking has failed: there are some unsolved constraints: please inspect the above reported error message(s) for information.exit(ATS): uncaught exception: _2home_2hwxi_2Research_2ATS_2dPostiats_2src_2pats_error_2esats__FatalErrorExn(1025)
As you can see it has a nice autistic minimalism that makes you feel like a haaaacker. So I'll give it a few more days.

New guy here. How do I make a box around my code?

oxwugzccvk3dk6tj.onion/faq.html#how-do-i-format-my-text

My project isn't big enough to warrant its own thread, but I've been working on a BBS like software to be used over tor.
Right now it only really support a chatroom, but I have plans to add some other features like mail, and customized user pages.
The project is called Zyrod and it's licensed under the AGPLv3.
You can find the source at: gitgud.io/zyrod/zyrod
You can join my instance at: zyrod3akfrytejihgoofmarjhojorwxd6cvf55qyqr476e5msac7nhqd.onion:54706

Attached: 2018-03-18-001925_825x227_scrot.png (825x227, 20.32K)

Added new menus:
[L]icense: View the AGPLv3 License
[M]embers: View a list of registered members
[W]arranty: View the warranty.
I also set it up so that when I push my code to the remote repository the onion server automatically pulls the latest code down and restarts Zyrod.

...

Probably the last thing I'll add tonight to Zyrod.
Fortune.

Attached: 2018-03-18-202440_933x261_scrot.png (933x261, 15.63K)

I just tried the "print number in binary" with python.
def tobinary(n): binarystring = '' place = total = 1 while (n > total): # Get highest binary place possible for n place = highestplace): binarystring += '1' n -= highestplace else: binarystring += '0' highestplace >>= 1 return binarystringprint(tobinary(37))

Attached: easy short programming.png (870x1448, 50.16K)

Is K&R still relevant for learning C?

No. Btw rollin

It's the only C book worth reading

Both of these are wrong.

I made #26 instead: 



fn main() { // let mut args = std::env::args().skip(1); let args = vec!("masterpassword", "facebook.com", "Adolf Hitler"); let mut args = args.iter(); if args.len() < 2 { eprintln!("Usage: pass ..."); std::process::exit(1); } let hash = hash_impl(std::iter::once(password_hash(args.next().unwrap().as_bytes())) .chain(args.map(|s| hash(s.as_bytes())))); println!("{:x}{:x}", hash.0, hash.1);}macro_rules! round { ($x:expr, $y:expr, $k:expr) => { *$x = $x.rotate_right(8); *$x = $x.wrapping_add(*$y); *$x ^= $k; *$y = $y.rotate_left(3); *$y ^= *$x; }}fn key_schedule(ks: &mut [u64], (mut k2, mut k1): (u64, u64)) { for (i, k) in ks.iter_mut().enumerate() { *k = k2; round!(&mut k1, &mut k2, i as u64); }}fn encrypt(ks: &[u64], &mut (ref mut m2, ref mut m1): &mut (u64, u64)) { for &k in ks { round!(m1, m2, k); }}fn hash(data: &[u8]) -> (u64, u64) { fn read_u64(iter: &mut I) -> u64 { iter.take(8).fold(0, |acc, b| (acc (u64, u64) { let mut ks = [0; 32]; let mut state = (0x6A09E667F3BCC908, 0xBB67AE8584CAA73B); for k in iter { key_schedule(&mut ks, k); encrypt(&ks, &mut state); } key_schedule(&mut ks, (0, 0)); encrypt(&ks, &mut state); state}fn password_hash(data: &[u8]) -> (u64, u64) { let mut ks = [0; 32]; key_schedule(&mut ks, hash(data)); let mut state = [(0u64, 0u64); (4

Any recommendations on whether to use SDL2 or GLFW for a home-made game engine? I'm mostly worried about input lag.

Roll

rolling

Did #18
import os, sysfrom PIL import Imagedef imgtoascii(pathtoimg): charx = 2 chary = 5 rangepervalue = 3 asciiequivalent = ( "@", "#", "M", "B", "H", "E", "N", "R", "K", "W", "X", "D", "F", "P", "Q", "A", "S", "U", "Z", "b", "d", "e", "h", "x", "8", "&", "G", "*", "m", "O", "4", "a", "g", "n", "s", "6", "9", "o", "w", "z", "$", "C", "I", "u", "2", "3", "J", "c", "f", "r", "y", "%", "1", "v", "7", "l", "+", "i", "t", "[", "]", "{", "}", "?", "j", "|", "(", ")", "=", "~", "!", "-", "/", "", '"', "^", "_", "'", ";", ",", ":", "`", ".", " " ) # Check if pathtoimg is valid then convert to grayscale try: img = Image.open(pathtoimg).convert("LA") except IOError: print("Unable to open file") return False output = open(os.path.splitext(pathtoimg)[0]+".txt", "w") line = "" imgx, imgy = img.size # Loop through image and get each region to be converted to ASCII for y in range(0, imgy, chary): for x in range(0, imgx, charx): region = (x, y, x+charx, y+chary) grayscaleval = getgrayscalevalue(img.crop(region)) / rangepervalue grayscaleval = 0 if (grayscaleval == 0) else (grayscaleval - 1) line += asciiequivalent[grayscaleval] output.write(line + "\n") line = "" output.closedef getgrayscalevalue(region): total = 0 pixels = list(region.getdata()) for pixel in pixels: total += pixel[0] return(total/len(pixels))if __name__ == "__main__": for arg in sys.argv: imgtoascii(arg)

rollan XDD