[ home ] [ q / soy / qa / r / nate ] [ a / health / incel / int / mtv / pol / psy / raid / sci ] [ overboard ] [ rules ] [ bans ] [ wiki ] [ booru ] [ archive ] [ merch ] [ donate ]

/tech/ - Technology

Name
Options
Comment
File
Embed
Password (For file deletion.)

File: 1679680073392.png (52 KB, 623x808, Screenshot_2023-03-24_17-4….png)ImgOps

 2781

what did he mean by this

 2782

why isn't this server side code php can just read folder contents and choose a random image that way

 2788

handmade craftsmanship gem

 2790

>>2781
Simple but effective, peak Russia engineering.

 2791

>>2781
the greastest python schoolar tries xyr hand at the sharty codebase

 2792

is this real

 2803

Lol what the fuck is this real

 2804

>make most efficient and malleable code possible to hold the banners
>WHERE IS THE HECKIN WEIRD ITERATOR THAT ONLY TAKES 1 LINE AND LOOKS LIKE BLACK VOODOO MAGIC

 2805

>>2804
Shut the fuck up you coder tranny faggot

 2808

File: 1679730230878.jpg (10.96 KB, 234x250, 1627364563442.jpg)ImgOps

>>2804
>for loops are black magic
you are a CIA MIT nigger

 2817

>>2810
kek

 2819

>>2804
It's not 'efficient', it's not even performant necessarily (implementation detail of JS engine). Please learn the dinstinction between the 2 terms, I'd show you where I learned it from myself but I can't seem to find the source right now. Efficient would be simply throwing a file (ambiguous) in a directory and then the JS picking a random entry from it. There's no need to give the image a number especially if you're not doing any sort of automatization (although using said numbers would still be poor/misguided). The problem here is very much so overcomplicated, not the other way around as you seem to imply.

 2822

>>2810
Oh LMAO I remember that banner now it makes sense

 2833

>>2782
Because that would require some chud who has at least finished the "Beginners PHP" tutorial, which is far beyond the resources of this place.

 2836

dunning kruger thread

 2838

>>2837
we checked the (((source))) and that was precisely why we thought he implemented datamining kys nigger

 2852

⛓️

 2853

%%te⛓️%%

 2863

File: 1679832299374.gif (1.57 MB, 255x144, 1679600713284.gif)ImgOps

>>2836
tsmt

 2866

>>2863
ultra gemmy

 2886


 2973

[code]
// Total banner count - this is the only variable that has to be defined
const count = 45;
// This function will return whether the banner is a .png or .gif by checking if the image exists on the server by creating a JavaScript Image() object and getting it's height
function pngOrGif(url)
{
var img = new Image();
img.src = url;
return img.height != 0;
}

function getRandomImage(count) {
// Selects a random whole number from 0 to the total banner count
var number = Math.floor(Math.random() * count);
// Get the banner URL
var randomImageURL = "https://soyjak.party/static/banner/" + number;
var fileType = ".png";
if( !pngOrGif( randomImageURL + fileType ) ) {
fileType = ".gif";
}
randomImageURL = randomImageURL + fileType;
var imgHTML = "<img border='1' src='" + randomImageURL + "' style='max-width: 300px;'/>";
document.write(imgHTML);
}
[/code]

 2974

File: 1680310374858.png (47.31 KB, 1017x346, Screenshot from 2023-03-31….png)ImgOps

SOOOT ADD CODE TAGS NOW

 2986

>>2973
>>2974
holy bloat

 3653

up

 3672

javascript in ohio ?

 3673

>>2782
Why would it be server side, the server doesn't care which banner it shows you..

 3676


 4826

we go up

 4854

the only thing that's wrong with this is that you have to update it every time a new banner is added, imo there should be a route on the server like /static/banner/random to return a random image, and the server implementation wouldnt have this manual sh£$ since it could just read from the directory
also idk why he's doing the randomImage[x] = "..." bullshit on every line instead of just var randomImage = [urls here]
also it should be a const not a var
this isnt a case of "muh readability muh dunning kruger" its actually just bad code

 5418

uppy

 5477

>>3673
because the server can actually read a directory and see all of the banners available instead of having a huge ass array of all of them

 5481

>>3672
OhioScript ?



[Return][Go to top] Catalog [Post a Reply]
Delete Post [ ]
[ home ] [ q / soy / qa / r / nate ] [ a / health / incel / int / mtv / pol / psy / raid / sci ] [ overboard ] [ rules ] [ bans ] [ wiki ] [ booru ] [ archive ] [ merch ] [ donate ]