Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "random numbers"
Was letting my five year old cousin play on my laptop today. She was writing numbers in notepad, and after typing '123', she erased them because she wanted to start over from 0 instead.
Later she started typing 1 and 0 repeatedly in random sequence.
She may be a robot. Either way, I sense a bright future ahead for her.2
To become an engineer (CS/IT) in India, you have to study:
1. 3 papers in Physics (2 mechanics, 1 optics)
2. 1 paper in Chemistry
3. 2 papers in English (1 grammar, 1 professional communication). Sometimes 3 papers will be there.
4. 6 papers in Mathematics (sequences, series, linear algebra, complex numbers and related stuff, vectors and 3D geometry, differential calculus, integral calculus, maxima/minima, differential equations, descrete mathematics)
5. 1 paper in Economics
6. 1 paper in Business Management
7. 1 paper in Engineering Drawing (drawing random nuts and bolts, locus of point etc)
8. 1 paper in Electronics
9. 1 paper in Mechanical Workshop (sheet metal, wooden work, moulding, metal casting, fitting, lathe machine, milling machine, various drills)
And when you jump in real life scenario, you encounter source/revision/version control, profilers, build server, automated build toolchains, scripts, refactoring, debugging, optimizations etc. As a matter of fact none of these are touched in the course.
Sure, they teach you a large set of algorithms, but they don't tell you when to prefer insertion sort over quick sort, quick sort over merge sort etc. They teach you Las Vegas and Monte Carlo algorithms, but they don't tell you that the randomizer in question should pass Die Hard test (and then you wonder why algorithm is not working as expected). They teach compiler theory, but you cannot write a simple parser after passing the course. They taught you multicore architecture and multicore programming, but you don't know how to detect and fix a race condition. You passed entire engineering course with flying colors, and yet you don't know ABC of debugging (I wish you encounter some notorious heisenbug really soon). They taught 2-3 programming languages, and yet you cannot explain simple variable declaration.
And then, they say that you should have knowledge of multiple fields. Oh well! you don't have any damn idea about your major, and now you are talking about knowledge in multiple fields?
What is the point of such education?
PS: I am tired of interviewing shitty candidates with flying colours in their marksheets. Go kids, learn some real stuff first, and then talk some random bullshit.18
Welcome back to practiseSafeHex's new life as a manager.
Episode 2: Why automate when you can spend all day doing it by hand
This is a particularly special episode for me, as these problems are taking up so much of my time with non-sensical bullshit, that i'm delayed with everything else. Some badly require tooling or new products. Some are just unnecessary processes or annoyances that should not need to be handled by another human. So lets jump right in, in no particular order:
- Jira ... nuff said? not quite because somehow some blue moon, planets aligning, act of god style set of circumstances lined up to allow this team to somehow make Jira worse. On one hand we have a gigantic Jira project containing 7 separate sub teams, a million different labels / epics and 4.2 million possible assignees, all making sure the loading page takes as long as possible to open. But the new country we've added support for in the app gets a separate project. So we have product, backend, mobile, design, management etc on one, and mobile-country2 on another. This delightfully means a lot of duplication and copy pasting from one to the other, for literally no reason what so ever.
- Everything on Jira is found through a label. Every time something happens, a new one is created. So I need to check for "iOS", "Android", "iOS-country2", "Android-country2", "mobile-<feature>", "mobile-<feature>-issues", "mobile-<feature>-prod-issues", "mobile-<feature>-existing-issues" and "<project>-July31" ... why July31? Because some fucking moron decided to do a round of testing, and tag all the issues with the current date (despite the fact Jira does that anyway), which somehow still gets used from time to time because nobody pays attention to what they are doing. This means creating and modifying filters on a daily basis ... after spending time trying to figure out what its not in the first one.
- One of my favourite morning rituals I like to call "Jira dumpster diving". This involves me removing all the filters and reading all the tickets. Why would I do such a thing? oh remember the 9000 labels I mentioned earlier? right well its very likely that they actually won't use any of them ... or the wrong ones ... or assign to the wrong person, so I have to go find them and fix them. If I don't, i'll get yelled at, because clearly it's my fault.
- Moving on from Jira. As some of you might have seen in your companies, if you use things like TestFlight, HockeyApp, AppCenter, BuddyBuild etc. that when you release a new app version for testing, each version comes with an automated change-log, listing ticket numbers addressed ...... yeah we don't do that. No we use this shitty service, which is effectively an FTP server and a webpage, that only allows you to host the new versions. Sending out those emails is all manual ... distribution groups?? ... whats that?
- Moving back to Jira. Can't even automate the changelog with a script, because I can't even make sense of the tickets, in order to translate that to a script.
- Moving on from Jira. Me and one of the remote testers play this great game I like to call "tag team ticketing". It's so much fun. Right heres how to play, you'll need a QA and a PM.
*QA creates a ticket, and puts nothing of any use inside it, and assigns to the PM.
*PM fires it back asking for clarification.
*QA adds in what he feels is clarification (hes wrong) and assigns it back to the PM.
*PM sends detailed instructions, with examples as to what is needed and assigns it back.
*QA adds 1 of the 3 things required and assigns it back.
*PM assigns it back saying the one thing added is from the wrong day, and reminds him about the other 2 items.
*QA adds some random piece of unrelated info to the ticket instead, forgetting about the 3 things and assigns it back.
and you just continue doing this for the whole dev / release cycle hahaha. Oh you guys have no idea how much fun it is, seriously give it a go, you'll thank me later ... or kill yourselves, each to their own.
- Moving back to Jira. I decided to take an action of creating a new project for my team (the mobile team) and set it up the way we want and just ignore everything going on around us. Use proper automation, and a kanban board. Maybe only give product a slack bot interface that won't allow them to create a ticket without what we need etc. Spent 25 minutes looking for the "create new project" button before finding the link which says I need to open a ticket with support and wait ... 5 ... fucking ... long ... painful ... unnecessary ... business days.
... Heres hoping my head continues to not have a bullet hole in it by then.
Id love to talk more, but those filters ain't gonna fix themselves. So we'll have to leave it here for today. Tune in again for another episode soon.
And remember to always practiseSafeHex16
I laughed at how in the movies hacking is portrayed as some person clicking a lot buttons really quickly in a very flashy UI. There's a picture of America and sometimes there's a 3d model rotating for no good reason or a bunch of random numbers floating across the screen. They use random hacking related terms like: backdoor, DDoS...etc in their sentences.
At least they did their research...17
I JUST FINISHED MY FIRST NEURAL NETWORK!!!
But first of all, as I know you guys, it's spaghetti code and even I as a newb see places where I used too few-dimensional array or passed useless parameters or simply wrote too many redundant lines of code. I know it. I will make it MUCH better next time. Period.
But OMFG this made me scream from happiness today!! Just these few seemingly random numbers... I'm really done.. That's why I jumped into coding year or two ago..
And for some background, I didn't study any IT school, I'm just highschooler (general grammar school) who traded gaming for learning. Also my maths teacher teached NNs on university and is very keen to teach me, so that's that.
Now I wanna make the best out of it and I'm looking forward to write some well documented and flexible library, parallelized and everything (I'm gonna learn a lot in the process of doing this) better then FANN.
Maybe I'm gonna fail(99% probability but hey, I'm programmer beginner, I still think I can code everything I want). But if there is just one moment like when I saw this screen today, I'mma trade my life for it.
Sorry for taking your time guys, I was just genuinely stunned... A lot26
The last year my school installed MagicBoards (whiteboard with beamer that responses to touch) in every class room and called itself "ready for the future of media". What they also got is A FUCKING LOW SPEC SERVER RUNNING DEBIAN 6 W/O ANY UPDATES SINCE 2010 WHICH IS DYING CONSTANTLY.
As I'm a nice person I asked the 65 y/o technician (who is also my physics teacher) whether I could help updating this piece of shit.
Teacher: "Naahh, we don't have root access to the server and also we'll get a new company maintaining our servers in two years. And even if we would have the root access, we can't give that to a student."
My head: "Two. Years. TWO YEARS?! ARE YOU FUCKING KIDDING ME YOU RETARDED PIECE OF SHIT?! YOU'RE TELLING ME YOU DON'T HAVE TO INSTALL UPDATES EVEN THOUGH YOU CREATE AN SSH USER FOR EVERY FUCKING STUDENT SO THEY CAN LOGIN USING THEIR BIRTH DATE?! DID YOU EVER HEAR ABOUT SECURITY VULNERABILITIES IN YOUR LITTLE MISERABLE LIFE OR SOUNDS 'CVE-2016-5195' LIKE RANDOM LETTERS AND NUMBERS TO YOU?! BECAUSE - FUNFACT - THERE ARE TEN STUDENTS WHO ARE IN THE SUDO GROUP IF YOU EVEN KNOW WHAT THAT IS!"
Me (because I want to keep my good grades): "Yes, that sounds alright."13
It's kind of neat knowing people who are famous for things I don't care about, and having their numbers / talking semi-regularly. They're a special person to so many others, but to me they're just some random person that's mildly annoying.
Like API Guy.
Freaking API Guy.
He's a millionaire musician who's adored by literally millions of people, but none of them know he writes absolutely terrible APIs, zero tests, rushes to the shiniest new things, and happily agrees to everything (often without listening) only to deny it later. Absolutely infuriating.
Or knowing one of Netscape founders as that strange and really terrible trumpet player with the great tequila. He did give me his copy of The C Programming Language (the bible) though. He was cool. Super weird, but cool.
It's just a strange feeling. I don't care, and yet others inexplicably think I should. I don't understand it. They're just people? idk.23
When it comes to users, perception is everything.
The task: Choose x random contractor numbers for us to assign to y jobs.
Me: How many contractors are there?
Me: How many jobs need assignment?
Me: Does the program need to assign contractors to individual jobs?
Mgr: No, we just need the 25 contractor numbers
Me: Well in that case just use the list I gave you earlier.
Mgr: No, we can't do that. It won't be random
Fix? Return a list of 25 contractor numbers in a slightly different order than the one originally submitted (5 or 6 items moved around)
The manager was pleased.3
I got a friend who likes to travel randomly to random places.. he now found some dudes who share this hobby.
So now there is a thing running on my server ticking everyday, 10am, with a 1:150 probability to send a sms to 7 numbers (including me) which tells them to travel to budapest.
FYI: he and his friends study engineering, i study too. So 1:150 may sound pretty low at first but we don't have that much time over the year actually.:D
Russian Roulette Travelling is a thing now.😁13
Very long story ahead!
Yesterday in the evening a friend of mine (calling him F from now on) became the target of something new to me...
Apparently one can fake his phone number through some fishy ways and call people with that number. Someone (we think we might know who it was, the why is at the end) did this yesterday to F.
Here's the whole story:
We were just talking together on a TeamSpeak Server (a program to talk to others on the internet) when suddenly another friend said: "F, why did you just call me three times in a row?" That was the first thing that was a bit suspicious. After that, F got calls from random numbers (even Afghanistan, we are German), and they said something like "Have fun with the police coming to your house". Then there was silence. 10 minutes later his phone rang and there were a ton of pizza delivery services in his town that apparently got pizza orders from him. Then there was silence, again. Suddenly someone with a hidden number called him, a woman's voice said they were the police and if F doesn't stop calling the police there will be consequences. F then told her what was going on but I think she didn't really care. She then wanted to know where F lives, but I told him not to say that, because if it is the police they can find it out by themself and if it's not, they don't need to know that.
Now, a short break: There is some fake information going around about where F lives. I can't remember when we found out but the attacker thought he would actually live there. No idea what happened at that location...
Now back to the story:
Time went by, nothing really happened. Suddenly F shouted: "There are blue lights outside! The police is here!" He muted his microphone and (the following is what he told us what happened) went down to the door (remember, he is 16) and there were two police men. They were asking about why he called the police. F explained what we knew until then, about number spoofing and stuff... They sent a more technical person to him, he understood what F was trying to explain. The police men drove away and he came back to tell us what happened. (Now we get back to what I heared myself.) The mom came in, screamed something that I couldn't understand, and F went offline. We searched who the attacker could have been. And we are pretty sure we found him. That guy connected to our Minecraft server (that's where I know F from) with his real IP, and his main account, which made it easy to search. He also got a static IP which means it doesn't change. We also got some information that in the recent days this guy was talking about VoIP spoofing and such stuff. Another friend of mine, a bit older, found some proofs and I think he will go to the police.
That's it. Thanks for reading.8
Just heard at the coffee machine: "Well, does that mean I'm not allowed to use Trump's quotes to seed the random numbers generator?"1
There is a function for creating random numbers.
So with the same inputs , I must get the same output.
So it is somewhat predictable.
So it is not actually random!
Am I tight?33
This happened yesterday. It was a Friday and I didn't have much time to implement something that I was asked.
I was supposed to get the cpu temperature from a host device and send it to the server. Instead I just used random.randint(x,y) (python random function) with x,y linearly dependent on cpu utilisation (cpu utilisation is easy to get).
The ability to generate random numbers on fly has to be on of the coolest things that you can do. You can almost fake anything using them properly 😅8
Was just thinking of building a command line tool's to ease development of some of my games assets (Just packing them all together) and seeing as I want to use gamemaker studio 2 thought that my obsession with JSON would be perfect for use with it's ds_map functions so lets start understanding the backend of these functions to tie them with my CL tool...
Oh this might be helpful, easily save a data structure with decent encryption...
*Looks at saved output and starts noticing some patterns*
Hmm, this looks kinda familiar... Hmmm using UTF-8, always ends with =, seems to always have 8 random numbers at the start.. almost like padding... Wait... this is just base64!
Now yoyogames, I understand encryption can be hard but calling base64 'secure' is like me flopping my knob on the table and calling it a subtle flirt...6
I'm having a DAY.
it's like I'm trying to "2+2=4" and hitting "unknown operator =", figure that out, get "22" back, fix that, then math service is down, redeploy math service, wait 30 minutes, that's up, get "out of numbers" exception, turns out a dependency updated and now I have to register what "2" means, fix that, FINALLY get 2+2 to evaluate, I get 5. Figure that out, get 4! 4!!! FINALLY. Push it. Get 55 on the server. Gets 4 on my machine, getting some random 55 from the server.6
Today I had to write a unit test to test a method that internally used a random number generator...
My test was literally just assertNotNull...4
TL;DR - Girlfriend wanted to learn coding, I might have scared her off.
Today, my girlfriend said she wants to learn coding.
She: well, all these data science lectures are recommending Python and R.
Me: Ok. But, are you interested in coding?
She: No, but I think I have to learn.
Me: Hmm.. coding requires a clear thought process, and we should tell the computer exactly what needs to be done.
She: I think I can do that.
Me: Okay... then tell the computer to think and give a random number between 1 to 10.
She: I will use that randint function. (She has basic knowledge in C)
Me: Nope. You write your own logic to make the computer think.
She: What do you mean?
Me: If I were you... Since it is just a single digit number.. I would capture the current time and would send the last digit of milliseconds @current time.
She: Oh yeah, that's cool. Understood! I will try...
" " "
We both work in same office.. so, we meet up for lunch
" " "
I didn't ask about it, but she started,
She: Hmm, I thought about it, but I was not able to think of any solution. May be its not my cup of tea.
I felt bad for scaring her off... :(
Anyway, what are some other simple methods to generate random numbers like OTPs. I am interested in simple logics, which you have thought of..not the Genius algorithms we have in predefined libraries.25
I'll be honest, I've never understood why people say that numbers generated by a computer are pseudorandom and not random.
I know a lot of algorithms for number generation, and I implemented mine, based on time of invokation expressed in nanoseconds, taking digits, manipulating and transforming them. Then I analyzed the probability distribution and it's absolutely flat. So, if you know the Touring test, we can use a modified version of it. If I give you a sequence of random numbers generated by a computer and I give you a sequence of random numbers invented by a person, and you can't notice the difference, so the test is passed.
What's wrong on it?14
As an iPhone user, who generally appreciates an iPhone over google spyware, I have to say Live Photo’s are CANCER and are KILLING ME SLOWLY.
They take up a ton of space, are basically movies (wrong format for high quality images) when you text too many of them it creates them as an iCloud attachment (kill me) and sends the link to somebody, when you connect your phone to your computer the photos app for some certain Live Photo’s does one of the following 4. at random:
1. Fail to import the photo and give an error message
2. Import the photo but it shows up as a video in your library
3. Import the photo and it shows up as a Live Photo as it should
4. Import the photo and it does not show up at all in your library but no error
But regardless of which of these happens, the same photo will show up as a new photo to import the next time you connect your phone to the computer. So you end up with different numbers of different types of duplicates of only certain Live Photo’s on your phone, but not all of them!
These sorts of problems frustrate me because they are mundane and waste my time, when I could be focusing on other things like hacking on compilers or smt solvers, so I said “fuck it, I’m going to delete all the Live Photo’s from my phone.” It was only about 100, and of those 100 about 30 were persistently problematic.
Well, after I did that 18 of them kept showing up but as black squares in photos but weren’t on my phone! And of course it failed to import them because they were gone.
after rebooting my phone twice and waiting a day and rebooting it again this problem has gone away and i will never take or share a Live Photo again as long as I live. If you’re going to make something new, you have to remember to actually write software that works. Pls, kthx. Otherwise you will cause Frodo to work on things that are not smt solvers or compilers and this will make Frodo very no bueno.8
I remember the first time our class coded a simple program in C. The objective was to input two random numbers, check which one is larger, and output it on the screen.
After class, I asked one of my classmates if he finds the test easy. My classmate replied that it was so easy he got bored. Then when I asked him to show me his code, this was what I saw:
int a, b;
printf("Enter smaller number: ");
printf("Enter larger number: ");
printf("Larger number: %i\n", b);1
I wrote a little script that generates random numbers until it reaches 420, my luckiest go was 17. What was yours?
300 global variables.. THREE HUNDRED FUCKING GLOBAL VARIABLES?
Are you for real?
Now let me check the line numbers again..
hmm.. line 97 to .. yep line 410, just a few new lines to seperate some of them or.. group? Idk, I've given up on trying to understand those.
Now you may ask "But ThatPerlDeb, where did you see this and what was the intention?"
Low and behold, take a chair and I may explain this to you.
First of all: Fuck the dev that wrote this!
Second: Fuck all the devs that kept up with this practice or whatever you want to fucking call this!
Now, the application is our POS system that our customers can use for a monthly fee (That this piece of garbage even requires payment is disgusting) but anyway..
The global variables sometimes are declared for labels, sometimes for some frames, sometimes just for random values to be there.
We're using Perl for the POS system and Perl ain't the best at OOP, so in the dev's defense I can understand why you'd use a few global variables, but not fucking 300!! FUCK OFF WITH THIS BULLSHIT!!
So now I'm going through this torture slowly but surely deleting globals and putting them into some sort of scope and always MANUALLY test if something broke. Again, this company sucks ass and there's nothing that could even be considered a "unit test" or something like that, so fuck that, too.
After two hours I've brought down the count of global variables to about 260, so there's progress being made..
But then, there comes more!
"But how???" you may ask, and you're right, I've asked that myself.
Now to resolve the global stuff in each file some of the initial globals are used, we got about 20-30 files which do different stuff, all fair and square, at least there was an attempt at seperating functions but god this mess is so fucking fucked up. So in order to "safely" delete a global variable I have to check if any of the variables are used in another file, and if so, in which scope and how they are used.
Spaghetti would be a compliment for this fucking disgusting piece of utter bullshit.
Let alone the code quality of this "code"
Indendation? Dafuq is dat?
Scope? Nah, we got everything global anyway
Function size? Well, some are 5 lines, some are 900 lines, who cares anyways, right?
I'm so fucking glad once I leave this shithole, for real.6
Python: RandInt(0, 2) generates a random value between 0 and 2. Range(0, 2) generates a list of all numbers between 0 and 1. Boy, there's some consistent syntax.
I just had such a forfilling moment.
Normally, i often (force myself) go to bed at night, after i worked on a project of mine, with these thought saying "oh man i wanted to get that feature done today" or "i want to finish this and that part of my code".I am sure everyone of you knows the feeling, when your brain communicates that you are just not done for today.
Today it was different. I got a project of mine working in it's first state, where i put much heart, love and time in.Just a few minutes before i finished for today i got my server responding the expected numbers(some kind of pin-code). It's a very easy system: Someone(at the time only me and my debug mode :3) on a android phone request a verification which is checked and processed by the server. The server creates a random six-digit number, returns it encoded to the client and sends an email to the user, which currently sends it in plain text(shame on me).
Yeah, the user enters the number and voilà
And of course, all the Pincodes can only be used once.
I got to bed with this feeling of luck and succes.
I hope tomorrow is going to be a productive day!
I am so lucky right now.
Have a good day everyone!
Professor: writes a loop to sum up first five numbers and asks the output.
Other random student: 15
Prof praises him.
He runs the code.
Output: 500 ( internal server error)
(He had a missing semicolon) 😅6
This is another high school story. mostly because i’m in high school.
like most schools we have horrible forced passwords. Our school recently purchased microsoft 365. which means we all use outlook for our emails. the logins for our district follow the sand format.
s + first five of last name (x’s for missing letters) + first letter of your first name + the last three of your student id.
so for example Sean Peterson 456705 would be speters705. since we have outlook we can look up a persons name and get their email which gives you the last three of their password. All passwords start with a 4 and most are followed by a five so you pretty much can get 5 out of the 6 numbers in their password.
so to mess with my friends i signed into all of their accounts and messed with their emails so they thought they were getting random emails. and then i made word documents on all of their accounts and just pretty much messed with all of their school stuff.
so that’s my “hacking” story. my district doesn’t allow you to change your password so i’m pretty much stuck. pls help.4
During my first semester of CS we were mostly using MatLab for basal scripting - assigning variables, learning about scope, that type of thing. I was excited to start learning programming but wanted to actually make something rather than reversing arrays and incrementing counters for weeks.
I discovered the image() function which takes a float matrix and displays it as an image. I generated my arrays of random numbers and made a simple nested loop where I iterated over each element, averaging it with its neighbours, and - it worked on the first run! I made a freaking noise and blur filter!
That rush of planning it out, making it, and seeing it work I think is my main drive in coding. All the hours of undefined-but-they-are-tho import paths and mystery segfaults are worth it once there is that moment of "it lives!".
In an IT management class, the professor wanted us to estimate the operation costs for a small IT company, breaking them down by service offered. I remember creating a markdown file, multiple times executing the line `echo $RANDOM >> estimations.md`. We rounded the numbers slightly, pimped the document a bit and submitted a nice PDF. When we had to present our work, the professor asked us how we had proceeded to calculate those results. We told him a story about an Excel file we worked on, but did not submit, because we thought he'd be interested in the end result and not care about those details. He asked us to submit that Excel calculation, because he wanted to comprehend our method. So we got together, created an Excel sheet, copied our "estimations" into column C and called it "service cost". For column B, we used the same "cost per man hour" value (scientifically estimated using the RAND() function) for every row. Finally, we divided the "service cost" by the "cost per man hour" for every row, put the result in column A and called it "effort (in man hours)". The professor, being able to "reproduce" our estimation, accepted our solution.2
Apple for the love of god, how to do you progressively make keychain worse with every update. For years now it has at least worked ok on desktop without a problem. So now what? You ran out of other ways to fuck it up, you had to start in on the one thing that was actually working?
Tell me what fucking good does it do me for you to suggest a password if your not going to turn around and save the goddamn password you suggested. What, you expect me to write it down now? The fuck do I even need you for then?
I can scribble random letters and numbers between hyphens down on a napkin then lose it all by my damn self. An guess what, I can just take out the hyphens when the site doesn't accept that password.
I mean I got it with the phone apps. They don't run on safari and your brilliant asses didn't think that developers might need access to it so that account could be updated there. Fine.
Why you started suggesting a password there before you started allowing for it to be saved is a little beyond my understanding but whatev's, developers should know after 10+ years of the iphone, not to prompt the user to create a new password there.
But now we want to suggest them in safari without saving them? The fuck? What the system doesn't know there's a password there to be saved? Then how did you know to suggest one in the first goddamn place? Seriously Apple it's time to get you shit together.2
How does random number generation work? I'm curious. What are different methods in which you can generate random numbers?
If you could link me to an article or some docs, that'd be appreciated. How far does your understanding of it go?
Thanks for your time.8
How do you approach generating "random" unique numbers/strings ? Exactly, when you have to be sure the generated stuff is unique overtime? Eg. as few collisions in future as possible.
Now I don't mean UUIDs but when there is a functionality that needs some length defined, symbol specific and definitely unique data, every time it does it's stuff.
TLDR STORY: Generating 8 digits long numbers so they are (deterministically - wink wink) unique is hard but Format Preserving Encryption saves the day. (for me)
I had to deal with both strings and codes today.
One was to generate shortlink word for url, luckily found a library that does exactly this. (Hashids)
BUT generating 8 digits long, somewhat random number was harder then I thought, found out on SO something like "sha256(seed) => bytes => ascii/numbers mangling" but that had a lot of collisions because of how the hash got mangled to actually output numbers and also to fit the length.
After some hours I stumbled upon Format Preserving encryption (pyffx) and man it did what I wanted and it had max 2 collisions in 100k values. Still the solution with this feels hacky af. (encrypting straddled unix timestamp with lots of decimals)6
#just Bluetooth headphones things
When you're sitting on crowded public transportation and can't hear anything unless your phone is closer to your headphones than anyone else's, i.e. unless it's close as shit to your face 😍😍😍
When you want to listen to music for longer than 2 hours or several times during your workday but can't because the BT headphones last 2-3 hours 😍😍😍
When the left and right side don't pair with each other but you can pair with each individually 😍😍😍
When half of the button presses and user interactions aren't documented and there's no way to forget a device 😍😍😍
When you try to connect a new device to them in a public area and just see a dozen random serial numbers, so you have to wait and hope they get resolved to the headphone brand name 😍😍😍
When Satan takes your soul and the Bluetooth connection drops in hell 😍😍😍
When the music quality is lower and can experience static and maybe even skip in between 😍😍😍
When the bus hits a road bump, it falls out of your ear, and rolls halfway down the bus 😍😍😍
When it takes a long time to find them because they tiny af, and just as long to find the charging cable 😍😍😍
When manufacturers cannot agree on a standard volume sync system and so you have to check the volume and adjust every time you connect and disconnect your headphones 😍😍😍
Can we please just stop making everything Bluetooth?
Someone who just wanted to listen to a 2 minute billie eilish song but found it easier to sing in his head13
Wanted to test out random number generation in different distributions. So did it using HTML/JS using google charts APIs, just to find out after sometime that R does what i did by default..2
Got a phone call from a scammer claiming to be my Cell Phone Provider saying “Congratulations! You just recieved unlimited calls and messages for a year, now to win this please give the 4 digit pins given to you” then I recieved a 4 digit pin and warning label not to give this message to anyone else. I then noticed that this was a scammer, i got his probably fake number and I tried to mess with him by giving random codes, he then noticed that the numbers were fake in the 5 try.
I truly feel bad for this idiot and just call him a scammer and end the call...1
A long time ago, I used AIDE (Android IDE) to write a simple application to output random numbers for the lottery. I test it out and head to the gas station. I pulled out my phone to generate numbers, and received something like 36892789, 3, 78921593, 5.
After hours of staring at my code, I transferred and compiled with Eclipse and the problem disappeared.4
We have an unit test that tests the average of a sequence of numbers generated randomly using a gaussian distribution. Of course it fails from time to time, it's random! Failing to fail, would mean that the generator is not generating random numbers, therefore failure means success, but success does not mean failure.
Wait, why did we add this test in the first place?
When I close my eyes I see identical objects in array, forming random numbers.
Last time it was a 7.
Anyways, gotta sleep.1
After my first ever "thing" I wrote (see story here: https://devrant.com/rants/2132057/...) fast forward 7 years to my first project when I /* thought I */ knew what I was doing and didn't write just for myself.
I worked in a very small company distributing various materials for medical research, many of them bought from manufacturers and then relabelled as if we had produced it. One part of that was to indicate a production batch / lot number. Before I started there, they would just invent a random number on the spot and use that on the new label and somewhere write it down to document that, I at least used an Excel sheet to have numbers prepared and document it on the same line (still crappy but more than nothing). After some time my boss got the idea to have all of that documented in MS Access (because that was the only database he knew). I had just started with HTML, PHP and MySQL in apprentice school around the same time, so I proposed writing an appropriate solution using those and got permission.
I started coding and learnt so much that I didn't need to pay attention at school anymore as I was years ahead of the curriculum (the others were struggling with If-statements and the likes).
When I was done with Version 1.0 of my web application, it was of course still crude as hell. I used html forms to save input (like editor.php -> submit to save.php, do save -> redirect to editor.php), but it did what had not been done before: keeping it all together and force people to do it properly. 2 years later I wrote a version 2, adding features that showed to be useful and with improved structure, as my last project before leaving, and as far as I know, they are still using it, which is at this point 2 years after I've left.
Looking back I would do it differently, but for what I knew back then it was not bad at all.2
nothing new, just another rant about php...
php, PHP, Php, whatever is written, wherever is piled, I hate this thing, in every stack.
stuff that works only according how php itself is compiled, globals superglobals and turbo-globals everywhere, == is not transitive, comparisons are non-deterministic, ?: is freaking left associative, utility functions that returns sometimes -1, sometimes null, sometimes are void, each with different style of usage and naming, lowercase/under_score/camelCase/PascalCase, numbers are 32bit on 32bit cpus and 64bit on 64bit cpus, a ton of silent failing stuff that doesn't warn you, references are actually aliases, nothing has a determined type except references, abuse of mega-global static vars and funcs, you can cast to int in a language where int doesn't even exists, 25236 ways to import/require/include for every different subcase, @ operator, :: parsed to T_PAAMAYIM_NEKUDOTAYIM for no reason in stack traces, you don't know who can throw stuff, fatal errors are sometimes catchable according to nobody knows, closed-over vars are passed as functions unless you use &, functions calls that don't match args signature don't fail, classes are not object and you can refer them only by string name, builtin underlying types cannot be wrapped, subclasses can't override parents' private methods, no overload for equality or ordering, -1 is a valid index for array and doesn't fail, funcs are not data nor objects when clojures instead are objects, there's no way to distinguish between a random string and a function 'reference', php.ini, documentation with comments and flame wars on the side, becomes case sensitive/insensitive according to the filesystem when line break instead is determined according to php.ini, it's freaking sloooooow...
enough. i'm tired of this crap.
it's almost weekend! 🍻2
I'm doing a project for uni in Omnet (C++ framework that should facilitate working with networks of queues, simulating and displaying statistics).
I needed to retrieve a random value from an exponential distribution, and the function to do so requires a random number generator as input. The framework has 2 implementations of the RNG and I picked the first one.
I spent 3 hours trying every possible thing, using both the exponential() function and its class wrapper (both provided by the framework), it was always returning 0 or NaN.
The RNG was spitting out values correctly, so I thought it was okay.
When I was almost ready to give up, I figured I could try and change to the second implementation of RNG, expecting nothing to change. And it fucking worked.
Zero reports on this behavior on Google, no apparent reason why it would work with one and not with the other when the two RNGs literally implement the same abstract class and spit out the same exact numbers... Just black magic...
Oh and cherry on top, it works with the raw function but not with the class wrapper on that same function... IF YOU GOTTA IMPLEMENT SOMETHING IN YOUR DAMN FRAMEWORK THAT DOESN'T WORK, FUCKING DON'T! 1 combination working out of 4 is not good! Or at least document it!
Sorry just had to share my pain
Want to see hair falling of a developer's head?
Just watch him trying to get some millions of fast and good random numbers.7
Okay so I'm new to C++ and my competition is either tomorrow or Thursday. And before I go into the comp I need a good random number generator but the problem is I can't get a good one . And when I run mine I either get the same number a few times in a row then when it changes it just increments a few until it hits 99 then restarts. And I only want it to generate different numbers everytime with a 1/99 chance to get the same number.4
This semester in college we're supposed to learn some machine learning using mostly Matlab. The first laboratories (technically the second, but the first we actually do something) we're learning basics of Matlab.
We were given an instruction PDF that talks about assigning variables, creating functions and classes, and some basic operators.
A the end of the instruction are exercises, but the thing is, they require knowledge of a lot of Matlab functions, like linspace, reshape, random numbers, vectors and matrices, but it does not tell anywhere about then or how to use them.
An example: exercise 4 tells us to read docs about 'ezplot' and plot sin^2(x).
Then, exercise 5 tells us to generate a 100 element linear space for -2pi to 2pi, calculate the sigmoid value of each point and plot it.
The professor looked personally offended that we had no idea what a sigmoid is and that we were all struggling to calculate it. He almost shouted at us for trying to use ezplot (which we assumed is what we're supposed to use based on exercise 4) instead of regular plot do visualize it.
I fucking hate this kind of professors.
Also, the real fuckfest is in the last exercise. I'll try to translate it to English as close as I can:
Create a 100 element vector of random positive integers and then save it as a matrix with the amount of rows equal to the amount of unique values in the vector and 100 columns and then for each element of the original vector encode it's value in the form of 1 in the field whose index equals the value of that element increased by one.
Yes it's all in one sentence, and no, nowhere in the instruction does it say how to do any of that.
Also, we have a test about all of that tommorow and I don't think anyone will pass it2
Crypto. I've seen some horrible RC4 thrown around and heard of 3DES also being used, but luckily didn't lay my eyes upon it.
Now to my current crypto adventure.
Rule no.1: Never roll your own crypto.
So let's encrypt a file for upload. OK, there doesn't seem to be a clear standard, but ya'know combine asymmetric cipher to crypt the key with a symmetric. Should be easy. Take RSA and whatnot from some libraries. But let's obfuscate it a bit so nobody can reuse it. - Until today I thought the crypto was alright, but then there was something off. On two layers there were added hashes, timestamps or length fields, which enlarges the data to encrypt. Now it doesn't add up any more: Through padding and hash verification RSA from OpenSSL throws an error, because the data is too long (about 240 bytes possible, but 264 pumped in). Probably the lib used just didn't notify, silently truncating stuff or resorting to other means. Still investigation needed. - but apart from that: why the fuck add own hash verification, with weak non-cryptographic hashes(!) if the chosen RSA variant already has that with SHA-256. Why this sick generation of key material with some md5 artistic stunts - is there no cryptographically safe random source on Windows? Why directly pump some structs (with no padding and magic numbers) into the file? Just so it's a bit more fucked up?
Thanks, that worked.3
So let's do a "community building" exercise.
What was your biggest tech pet peeve?
I hate it when people (especially teachers) give us a printout with a link to a website (like a good docs link) without shorting it.
I mean, we have to type out that 100+ character string of random numbers and letters. Then you make a mistake and have to retype it. (I.k,. First world problems)
Let's here yours. It can be about employers, teachers, or anyone else you can think of.3
Russians Engineer a Brilliant Slot Machine Cheat
...But as the “pseudo” in the name suggests, the numbers aren’t truly random. Because human beings create them using coded instructions, PRNGs can’t help but be a bit deterministic. (A true random number generator must be rooted in a phenomenon that is not manmade, such as radioactive decay.) PRNGs take an initial number, known as a seed, and then mash it together with various hidden and shifting inputs—the time from a machine’s internal clock, for example—in order to produce a result that appears impossible to forecast. But if hackers can identify the various ingredients in that mathematical stew, they can potentially predict a PRNG’s output. That process of reverse engineering becomes much easier, of course, when a hacker has physical access to a slot machine’s innards...
When is devrant going to fix the notification counter? I've never seen it work properly. The numbers spins through several seemingly random numbers and end on a wrong number 😕1