Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
[QUOTE=Richy19;47278587]Are there any services/API's that let you see how many times a keyword/something has been mentioned on the internet in a given period of time? Say the last hour[/QUOTE]
I am certain it would take more than one hour to index the entire internet, even for large search engines like Google - so the answer probably is no to that, unless the service is very unreliable. Note that there are currently 1.2 billion websites on the internet right now.
You could probably be more specific than "the internet" and narrow it down to certain categories that matches the particular keyword - and even then you'd probably have to write your own crawler. What are you trying to make exactly? Maybe there's a better way to do it?
[QUOTE=Svenskunganka;47279418]You could probably be more specific than "the internet" and narrow it down to certain categories that matches the particular keyword - and even then you'd probably have to write your own crawler. What are you trying to make exactly? Maybe there's a better way to do it?[/QUOTE]
Yea, maybe news sites relevant to the industry? So say im looking for all information on facebook posted in the last X then it would search big technology news sites for it. I was thinking of doing something that could draw heatmaps on how many times X has been mentioned in the last Y
[QUOTE=Rocket;47279926]Sounds like you want Twitter.[/QUOTE]
Haha that could be an interesting way to do it, but I think im just going to write my own RSS crawler or something like that
So, cloud providers... Im starting to look into cloud providers for live webservices,
I have discounted AWS because they are too expensive,
Google cloud have a $300 free trial for 2 months or something like that but I always thought with google you just upload your node/ror/... app and they just run it, you dont actually get a linux box? correct me if I am wrong.
Azure I have not really looked into, but given I am developing in a unix environment and will be using redis/other unix tools I dont think its going to work for me
These are the 3 big boys which I think may become too expensive on the long run, even though they offer trials to get started with, for example amazon costs $50/month for a m3.medium instance and its tiny
So my 2 main options are Linode and DigitalOcean, having read a few comparisons it seems Linode has a slight advantage with their hardware (slightly more performant) but DO gives a bit more bang for buck (instances have slightly more SSD space) and seem cheaper overall and have a $5/month instance which is good for prototyping (they also accept paypal which isnt a biggy but I guess is a plus)
Does anyone have any horror stories or suggestions on which is better? Maybe other service providers I havent mentioned?
Opinions on Linode/DO are based on this: [url]http://www.itekhost.net/digitalocean-vs-linode/[/url] and [url]http://joshtronic.com/2014/06/22/ten-dollar-showdown-linode-versus-digitalocean/[/url]
[QUOTE=Richy19;47281276]So, cloud providers... Im starting to look into cloud providers for live webservices,
I have discounted AWS because they are too expensive,
Google cloud have a $300 free trial for 2 months or something like that but I always thought with google you just upload your node/ror/... app and they just run it, you dont actually get a linux box? correct me if I am wrong.
Azure I have not really looked into, but given I am developing in a unix environment and will be using redis/other unix tools I dont think its going to work for me
These are the 3 big boys which I think may become too expensive on the long run, even though they offer trials to get started with, for example amazon costs $50/month for a m3.medium instance and its tiny
So my 2 main options are Linode and DigitalOcean, having read a few comparisons it seems Linode has a slight advantage with their hardware (slightly more performant) but DO gives a bit more bang for buck (instances have slightly more SSD space) and seem cheaper overall and have a $5/month instance which is good for prototyping (they also accept paypal which isnt a biggy but I guess is a plus)
Does anyone have any horror stories or suggestions on which is better? Maybe other service providers I havent mentioned?
Opinions on Linode/DO are based on this: [url]http://www.itekhost.net/digitalocean-vs-linode/[/url] and [url]http://joshtronic.com/2014/06/22/ten-dollar-showdown-linode-versus-digitalocean/[/url][/QUOTE]
I'm using [URL="https://hosthatch.com/openvz-ssd-vps"]HostHatch[/URL] which provides better hardware for better prices than both DO and Linode. Last month's server report from Pingdom reported 99.99% uptime with 2 outages 1 minute respectively 3 minutes, which is nothing. I've used DO and I had more downtime with them than with HostHatch. Support is amazing, I've always gotten a response within the hour. They also support net neutrality and accepts BitCoins. Their policy on privacy is really good and choosing to purchase with BitCoins you can be completely anonymous if you want to, which is always a plus feature.
One of our servers are using ~80% of the CPU almost all day long and uses all available RAM and they haven't said a word about it, even though this has been going on for 1 and a ½ month now.
[editline]8th March 2015[/editline]
I got my servers in the Stockholm datacenter, which is actually just a couple of kilometers away from me. That datacenter is known for being the absolute best in Sweden, which is really nice. It's gotten an award for being nuclear-proof :v:
How can I manipulate visibility of a div on index page from admin page?
[QUOTE=Svenskunganka;47281396]It's gotten an award for being nuclear-proof :v:[/QUOTE]
At least nice to know that once the whole world is blown away, your server is still up and running :v:
[QUOTE=Cyberuben;47281810]At least nice to know that once the whole world is blown away, your server is still up and running :v:[/QUOTE]
Indeed!
Although I believe the "nuclear-proof"-label covers most nature catastrophies like tornados and earthquakes, not just the warhead.
[QUOTE=Rocket;47282815]Store the visibility of it on the server in a database or on the client in a cookie or in localStorage.[/QUOTE]
I have two div's currently, one is slideshow and another one is youtube video. I need to change the active div from the admin panel, but I can't figure it out.
I thought creating slideshow/youtube div generator in php , which will output content.html with #content and in my index page I will use ajax .load()... But I can't change my user permissions in the server( for creating the .html files in php).
[QUOTE=Svenskunganka;47281931]Indeed!
Although I believe the "nuclear-proof"-label covers most nature catastrophies like tornados and earthquakes, not just the warhead.[/QUOTE]
I assume you're referring to [URL="https://www.bahnhof.net/"]Bahnhof[/URL]'s Pionen datacenter. Damn you're lucky to have servers there (that's gotta be expensive). ThePirateBay hosts their load balancer there as far as i know.
The datacenter itself is built into a big mountain, and it used to be a swedish nuclear fallout shelter from the Cold War, and at the time it would sustain a warhead hitting it directly, but they may have evolved since then.
[QUOTE=TrinityX;47283685]I assume you're referring to [URL="https://www.bahnhof.net/"]Bahnhof[/URL]'s Pionen datacenter. Damn you're lucky to have servers there (that's gotta be expensive). ThePirateBay hosts their load balancer there as far as i know.
The datacenter itself is built into a big mountain, and it used to be a swedish nuclear fallout shelter from the Cold War, and at the time it would sustain a warhead hitting it directly, but they may have evolved since then.[/QUOTE]
No, I mean Portlane in Nacka:
[quote]
Nacka Station Datacenter is located inside a gigantic, nuclear-safe super bunker cavern at Värmdövägen 87, Nacka. The facility is a former power station and connected directly to the Stockholm high voltage grid. Nacka Station provides a stable, secure and environmental friendly housing environment for your IT & network equipment with a guaranteed 99.995% availability in terms of power and cooling. The facility also has redundant fiber-optic connections via multiple operators to the internet backbone.
[/quote]
Bahnhof's Pionen has been praised a ton, and the best part with Bahnhof is their net neutrality stands. Luckily for TPB Pionen is protected by a political party (The Pirate Party), so the tunnel server is still up and being hosted there, but the real servers were confiscated from "the real mountain" as one of the founders phrases it. The funny thing is that there is only two datacenters in Stockholm located within mountains and that is Pionen and Portlane, so I am almost 100% certain the real servers were being hosted in Portlane.
Portlane is an old [URL="http://www.portlane.com/pdf/nackastation_en.pdf"]power station[/URL] located within the bedrock, and from the looks of TPB AFK video (particularly at [URL="https://www.youtube.com/watch?v=eTOKXCEwo_8&t=3661"]this time[/URL]), it looks a lot like an old power station to me.
Maybe it's just me putting on my foilhat, who knows? :tinfoil:
[editline]9th March 2015[/editline]
Forgot, TPB were actually hosted in the same datacenter as my servers:
[quote]
According to the police the raid targeted a data center in Nacka which is built into a “mountain.”
[/quote]
Source: [URL="http://torrentfreak.com/swedish-police-raid-the-pirate-bay-site-offline-141209/"]TorrentFreak[/URL]
Any tips for overcoming the sickening depression associated with rewriting PHP written 10 years ago by 14 year olds (plural)?
How is web development?
Pretty good.
So I made a simple searchbar and I ran into an issue. the way I want things to work is that the user can search for a new catagory and once he found that ( and presses enter or something in thet extbox ) I want to echo the new catagory from a .txt file. how does one communicate between js and php? or should I just use php? I'd appreciate some help here.
[QUOTE=robbert^^;47292589]So I made a simple searchbar and I ran into an issue. the way I want things to work is that the user can search for a new catagory and once he found that ( and presses enter or something in thet extbox ) I want to echo the new catagory from a .txt file. how does one communicate between js and php? or should I just use php? I'd appreciate some help here.[/QUOTE]
I suggest you read up on Ajax requests. Basically, you create a .php file that listens to POST / GET requests, takes parameters and echos something once it found what you need, or errors when necessary.
Then, using JavaScript, you send an Ajax request to your PHP file and then echo it.
I'm using this for a search form of mine:
[code]
$.get("/api/aanbod/objects/"+type, function (data) {
if(data.success) {
$("#aanbodWrapper > .row").html(data.items);
$(".aanbodcount").html(data.count);
}else{
$("#aanbodWrapper > .row").html("<h2>Er is iets fout gegaan. Probeer het later nog eens</h2>");
$(".aanbodcount").html(0);
console.log(data.errorMessage);
}
});[/code]
What this code does, it makes a GET request to the URL "http://mydomain.com/api/aanbod/objects/<type>" where type is dependent on what page I am on. The GET request returns a JSON object, with at least a "success" member and some more information. If "success" is true, it means that the parameters were as expected and it returned the found results (this can be 0, mind you, so here it's lacking a "No results found" bit). If "success" is false, an error occured, and I console log the error, it probably won't make sense to the end user anyway.
Thanks! i already found out that i had to use ajax before i read your post and found a solution, might aswell share ( probably not the best way of doing this... but ):
JS stuff
[code]
var test = [];
test[ 0 ] = "schooling";
test[ 1 ] = "werk";
var searchbar = {
getSelectedFromList : function()
{
var value = document.getElementById("searchBarMain").value;
var options = '';
for ( var i = 0; i <= test.length; i++ )
{
if ( value.indexOf( test[ i ] ) == -1 )
{
continue;
}
options += '<option value ="' + test[ i ] + '" >' + test [ i ] + '</option>';
}
document.getElementById("datalistSearch").innerHTML = options;
},
getArticleFromServer : function( )
{
var catagory = document.getElementById("searchBarMain").value;
var canProceed = false;
for ( var i = 0; i < test.length; i++ )
{
if ( catagory == test[ i ] )
{
canProceed = true;
break;
}
}
if ( canProceed )
{
myCall();
}
},
};
function myCall()
{
var request =
$.ajax(
{
url: "ajax.php",
type: "GET",
data: "file=" + document.getElementById("searchBarMain").value,
dataType: "html"
});
request.done( function( msg )
{
if ( document.getElementById( document.getElementById("searchBarMain").value ) == null )
{
var newElem = document.createElement( "div" );
var articleId = document.getElementById("searchBarMain").value;
newElem.setAttribute( "id", articleId );
var textField = document.getElementById( 'mainPage' );
var child = document.getElementById( 'ding' );
textField.insertBefore( newElem, child );
document.getElementById(articleId).innerHTML = msg;
}
});
request.fail( function( issue, textStatus )
{
alert( "Request failed: " + textStatus );
});
}
[/code]
the array will be replaces with a mysql database when i get to it :v:
PHP stuff:
[code]
<?php
if( $_SERVER['REQUEST_METHOD']=="GET" )
{
$file = $_GET['file'];
$myfile = fopen( "catagorys/". $file .".txt", "r" ) or die( "Unable to open file!" );
echo fread( $myfile, filesize("catagorys/". $file .".txt" ) );
fclose( $myfile );
}
?>
[/code]
again, probably not the best stuff in the world but it works perfectly!
That looks good. I'm still unfamiliar with Ajax but nice to know that this is a work around. :) [img]https://imagicon.info/cat/6-4/1.gif[/img]
[QUOTE=robbert^^;47294209]Thanks! i already found out that i had to use ajax before i read your post and found a solution, might aswell share ( probably not the best way of doing this... but ):
-- code --
again, probably not the best stuff in the world but it works perfectly![/QUOTE]
What I do not understand, you're using jQuery, why all the document.getElementById? jQuery is way easier. Though, your quoting and indentation is inconsistent, and I noticed you sometimes have twice the indentation needed. May I ask why?
First thing I spotted was you defining the "test" array.
These are better approaches:
[code]
// This would be if you literally define it, like you did now
var test = ["schooling", "werk"];
// This would be if you want to fill it using code
var test = [];
test.push("schooling");
test.push("werk");
[/code]
Instead of "document.getElementById()", use "$('#<id>')", instead of ".value", you can use ".val()" on a jQuery object and instead of ".innerHTML" you can use ".html(content)" to set the HTML of an element.
Either way, if you need any more help, just ask here.
that is actually my tab size in notepad++, you can see it as a personal preference :v:
As for the array's, it's a filthy habit that got from lua that is burned into my brain by the fires of hell and it just doesn't want to get out..
I'm just starting to learn jQuery and what i can do with it ( and it seems really, really nice ) but my college isn't there yet so i'd have to learn it on my own. i do really appreciate the help though!
[QUOTE=robbert^^;47295187]that is actually my tab size in notepad++, you can see it as a personal preference :v:
As for the array's, it's a filthy habit that got from lua that is burned into my brain by the fires of hell and it just doesn't want to get out..
I'm just starting to learn jQuery and what i can do with it ( and it seems really, really nice ) but my college isn't there yet so i'd have to learn it on my own. i do really appreciate the help though![/QUOTE]
What do you mean your tab size is like that? I'm not talking about the width of your indentation, because that is up to your editor, but you inserted 2 tabs where one would be sufficient.
[img]http://i.imgur.com/YR725SW.png[/img]
2 functions that have the same parent, but have different levels of indentation
oh wow, I actually have no idea why that is like that.. it's normal for me in the file :v:
don't worry though, I know how to use it. some of it is me moving shit around while testing stuff and forgetting to make it pretty. m I'll fix it up next time!
I figured out you can send emails through PHP. But can the receiver find out who sent it or from where it is from?
[URL="http://pastebin.com/g7Kvyv0P"]Example[/URL]
I don't mind if the receiver can figure out that it is from my website or not, the receiver just should not be able to figure out who sent it.
[QUOTE=diwako;47339590]I figured out you can send emails through PHP. But can the receiver find out who sent it or from where it is from?
[URL="http://pastebin.com/g7Kvyv0P"]Example[/URL]
I don't mind if the receiver can figure out that it is from my website or not, the receiver just should not be able to figure out who sent it.[/QUOTE]
IP or email?
The receiver should not be able to find out who sent it, the email should not leave any IP or Email from the client who sent it.
The code I am using is this:
[code]
<?php
$name = 'John Doe';
$to = 'my email';
$subject = 'the subject';
$message = 'hello';
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: " . $name . " <anon@anon.anon>";
// $headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: " . $name . " <anon@anon.anon>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
echo mail($to, $subject, $message, implode("\r\n", $headers));
?>
[/code]
Later the message, subject, name and reply-to will be changeable. But for now all I need to know if it is traceable in any way.
probably not the perfect place to ask this, but, i need to set up a 3d art portfolio (for the future, and as part of an assignment)
where's the best place for me to buy/rent a domain?
i've got quite a bit of web design experience so could happily make my own website but don't have the time to do so, so I'm thinking of just using a Carbonmade site but getting my own domain. it's around $6 a month. my other option is to use a free template or something that takes minimal effort, and get some cheap hosting. what's best?
[QUOTE=diwako;47340590]The receiver should not be able to find out who sent it, the email should not leave any IP or Email from the client who sent it.
The code I am using is this:
[code]
<?php
$name = 'John Doe';
$to = 'my email';
$subject = 'the subject';
$message = 'hello';
$headers = array();
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-type: text/plain; charset=iso-8859-1";
$headers[] = "From: " . $name . " <anon@anon.anon>";
// $headers[] = "Bcc: JJ Chong <bcc@domain2.com>";
$headers[] = "Reply-To: " . $name . " <anon@anon.anon>";
$headers[] = "Subject: {$subject}";
$headers[] = "X-Mailer: PHP/".phpversion();
echo mail($to, $subject, $message, implode("\r\n", $headers));
?>
[/code]
Later the message, subject, name and reply-to will be changeable. But for now all I need to know if it is traceable in any way.[/QUOTE]
First of all, headers should not be an array, but a string with each header ending with CRLF.
[url]http://php.net/manual/en/function.mail.php[/url]
Change $headers = array(); to $headers = ""; and replace the [] with dots. ($headers .=)
[QUOTE=Cyberuben;47341708]First of all, headers should not be an array, but a string with each header ending with CRLF.
[url]http://php.net/manual/en/function.mail.php[/url]
Change $headers = array(); to $headers = ""; and replace the [] with dots. ($headers .=)[/QUOTE]
See comment [URL="http://php.net/manual/en/function.mail.php#108368"]#108368[/URL]
He's imploding the array in the mail function.
[QUOTE=Svenskunganka;47341754]See comment [URL="http://php.net/manual/en/function.mail.php#108368"]#108368[/URL]
He's imploding the array in the mail function.[/QUOTE]
Oops I'm blind, missed that bit
[QUOTE=zerosix;47341532]probably not the perfect place to ask this, but, i need to set up a 3d art portfolio (for the future, and as part of an assignment)
where's the best place for me to buy/rent a domain?
i've got quite a bit of web design experience so could happily make my own website but don't have the time to do so, so I'm thinking of just using a Carbonmade site but getting my own domain. it's around $6 a month. my other option is to use a free template or something that takes minimal effort, and get some cheap hosting. what's best?[/QUOTE]
[img]http://5crat.ch/a/q7gj[/img]
[url]https://education.github.com/pack[/url]
Saying it's for an assignment tells me you are indeed a student
Sorry, you need to Log In to post a reply to this thread.