Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
How would I properly do my file management with NodeJS?
Currently I have a complete garbage app.js, I'd like to place my websocket stuff in /functions/websocket.js and UDP dgram server in /functions/udp.js.
How would I do this? I mean, I doubt all the logic is supposed to go in app.js...
If I use module.exports = {
myfunction: function() {}
}
I'd still have to call it in app.js, right? So what would be the correct way to work, considering I have a lot of "websocket.on('message', function() {})" lines.
[QUOTE=Cyberuben;45372287]How would I properly do my file management with NodeJS?
Currently I have a complete garbage app.js, I'd like to place my websocket stuff in /functions/websocket.js and UDP dgram server in /functions/udp.js.
How would I do this? I mean, I doubt all the logic is supposed to go in app.js...
If I use module.exports = {
myfunction: function() {}
}
I'd still have to call it in app.js, right? So what would be the correct way to work, considering I have a lot of "websocket.on('message', function() {})" lines.[/QUOTE]
/functions/websocket.js:
[code]
exports.myfunction = function() {
}
[/code]
app.js:
[code]
var websocket = require('./functions/websocket.js');
websocket.myfunction();
[/code]
[QUOTE=supersnail11;45372829]/functions/websocket.js:
[code]
exports.myfunction = function() {
}
[/code]
app.js:
[code]
var websocket = require('./functions/websocket.js');
websocket.myfunction();
[/code][/QUOTE]
But the thing is, I want to get as many things away from my app.js, just like in Garry's Mod Lua scripting you don't jam everything in your init.lua and PHP not everything is in your index.php.
I want to run a websocket and UDP server when I start app.js but minimalize the amount of things I have to run in app.js, meaning, I want to run it in a seperate file.
[editline]13th July 2014[/editline]
[QUOTE=Cyberuben;45372862]But the thing is, I want to get as many things away from my app.js, just like in Garry's Mod Lua scripting you don't jam everything in your init.lua and PHP not everything is in your index.php.
I want to run a websocket and UDP server when I start app.js but minimalize the amount of things I have to run in app.js, meaning, I want to run it in a seperate file.[/QUOTE]
app.js
[code]var chathandling = require("./includes/chathandling.js");
// other code
chathandling();
[/code]
./includes/chathandling.js
[code]
// require() for everything that's neccesary
module.exports = function() {
udplistener.on('message', function() {})
udplistener.bind(PORT)
console.log("UDP listener running at "+PORT)
}
[/code]
Guess that works :V
thanks 4 answering my question u fucking jerks.
[QUOTE=ifaux;45370597]i'm diving headfirst into a vps - any suggestions as to which one i should purchase from ramnode for personal hosting & low traffic websites? i'm looking at either the 128mb CVZ or SVZ - the former comes w/ 80gb & the latter 10gb - what is the difference here[/QUOTE]
Do you want more space or better performance? SVZ will give you better I/O due to storage remaining solely on solid state drives. CVZ will give you more disk at the cost of (some) performance. Heavily read files get cached on an SSD, but as far as how effective that process is, is dependent on RamNode.
I have [code]$(function(){
$('input[value=reserve],input[value=unreserve]').click(function(){
$.post('php/reserved.php', {reserve:$(this).attr("name")}, function(data){
alert(data);
});
return false;
});
});[/code]
how do I make it post "unreserve" when value = "unreserve" and "reserve" when value = "reserve"?
I tried this already and it didn't work.
[code]$(function(){
$('input[value=reserve],input[value=unreserve]').click(function(){
$.post('php/reserved.php', {$(this).attr("name"):$(this).attr("name")}, function(data){
alert(data);
});
return false;
});
});[/code]
Any help appreciated.
[QUOTE=Coment;45367032]He does, or at least he did previously (I got a ticket with him), on the support team.[/QUOTE]
Tyler is (as far as I'm aware) one of their technicians. RAMNode is owned by a guy called Nick A.
[QUOTE=ifaux;45370597]i'm diving headfirst into a vps - any suggestions as to which one i should purchase from ramnode for personal hosting & low traffic websites? i'm looking at either the 128mb CVZ or SVZ - the former comes w/ 80gb & the latter 10gb - what is the difference here[/QUOTE]
For a small personal site you probably won't notice the difference. As far as I am aware the difference is that their CVZ plan is HDD with cache, and SVZ is SSD based. The SSD plan would have faster random IOPS but you probably wouldn't notice the difference on a personal site.
thanks y'all
i figured it out by looking a little harder
Don't know is this the right thread, but does anyone know of any grease/tampermonkey scripts to bypass steam's piece of shit linkfilter? It should be pretty easy to make given that steam even includes the original link in the URL
[QUOTE=damnatus;45389610]Don't know is this the right thread, but does anyone know of any grease/tampermonkey scripts to bypass steam's piece of shit linkfilter? It should be pretty easy to make given that steam even includes the original link in the URL[/QUOTE]
I wrote one yesterday: [url]http://pastebin.com/ttJmJ1Ju[/url]
[QUOTE=supersnail11;45390371]I wrote one yesterday: [url]http://pastebin.com/ttJmJ1Ju[/url][/QUOTE]
Well what do you know, it actually fuckin' works. Thanks!
[QUOTE=supersnail11;45390371]I wrote one yesterday: [url]http://pastebin.com/ttJmJ1Ju[/url][/QUOTE]
or you could just
[code]
document.getElementById("proceedButton").click();
[/code]
Say I have a single form field with multiple checkboxes (currently I have six, I may have to add more). The user can select any combination of these options.
What's the best way of storing this information in a database?
[B]Note: [/B]Using Python (Flask) and SQLite
So far I've come up with these methods:
[IMG]http://www.facepunch.com/fp/ratings/tick.png[/IMG] A different attribute for each checkbox with a boolean type
[IMG]http://www.facepunch.com/fp/ratings/information.png[/IMG] A single integer 'code' attribute worked out by assigning each option a power of two, then adding them together:
[QUOTE]Option 1: 1
Option 2: 2
Option 3: 4
...
Option 6: 32[/QUOTE]
So selecting Option 1,3, and 6 would give a value of 1+4+32 = 37
[img]http://www.facepunch.com/fp/ratings/cross.png[/img] Something completely different
[QUOTE=Goz3rr;45391241]or you could just
[code]
document.getElementById("proceedButton").click();
[/code][/QUOTE]
But then the page has to load before it redirects, which is annoying.
I just finished up the CodeAcadamy course on Ruby as a hope to jump back into the web development scene. Any other good similar resources out there that I can follow along with instead of just jumping into the deep end?
Obviously I'm interested in Rails in particular so anything on it would be sweet.
[QUOTE=PieClock;45391588]I just finished up the CodeAcadamy course on Ruby as a hope to jump back into the web development scene. Any other good similar resources out there that I can follow along with instead of just jumping into the deep end?
Obviously I'm interested in Rails in particular so anything on it would be sweet.[/QUOTE]
Rails isn't a good starting point in my opinion. Check out Sinatra, it's pretty easy to learn.
Will do, thanks. :)
I have a masterpage with some a script that loads a titlebar into a header div on each of the pages that loads the masterpage. Every other page works great except one.
In the js file where I load the titlebar, I have this.
[code]
$('<section/>', { id: 'TitleBar' }).prependTo('#viewport');
$('#TitleBar').load('TitleBar.html');
[/code]
The problem is it doesn't load the id 'TitleBar' onto the section it prepends. It prepends a section with no id, so then without the id, it cannot load the html. Why would it not load the id on this page, and work fine on the other pages?
[QUOTE=supersnail11;45391412]But then the page has to load before it redirects, which is annoying.[/QUOTE]
Also your script breaks links like this:
[url]https://steamcommunity.com/linkfilter/?url=http://facepunch.com/showthread.php?t=1250244[/url]
which it'll redirect to
[url]http://facepunch.com/showthread.php?t[/url]
[QUOTE=Goz3rr;45398674]Also your script breaks links like this:
[url]https://steamcommunity.com/linkfilter/?url=http://facepunch.com/showthread.php?t=1250244[/url]
which it'll redirect to
[url]http://facepunch.com/showthread.php?t[/url][/QUOTE]
[URL="https://github.com/cpancake/SteamAutoRedirect/blob/master/steamautoredirect.user.js"]fine :([/URL]
I'm looking for a (hopefully free) admin panel for VPSes / dedicated servers. I run a lot of small websites for people I know on my VPS and I'd like to seperate my web and mailserver. Are you guys aware of any panel that allows me to split up tasks? I currently have 2 VPSes running with Webmin / Virtualmin but I hate having to log in on both, create "Virtual Servers" on both etc.
So wait, you're spinning up a VPS for each small website and need a panel for that? Or you need a panel for each small website on one VPS?
[QUOTE=Banana Lord.;45400631]So wait, you're spinning up a VPS for each small website and need a panel for that? Or you need a panel for each small website on one VPS?[/QUOTE]
No lol, sorry, but I have a small VPS that hosts about 5 websites. 2 of them are mine. The people I host the websites for know fuck-all about hosting, so it's not that THEY need the control panel, but since I have a web server and a mail server, seperated (2 VPSes with each it's own goal), I now constantly have to log in to 2 Webmin instances. The problem being, if I add a new website to my server, I need to do the following steps to make the website + mail work:
- Log in to VPS 1
- Create virtual server
- Set up username + password
- Select all services I'm going to run for that particular domain
- If needed, set up domain aliases (.com and .co.uk, same hosting)
- Log in to VPS 2
- Create virtual server
- Set up username + password (same as on other server)
- Create all email accounts for that domain that are neccesary
- Log in to SMTP2GO
- Create SMTP accounts for every e-mail account used by this domain
I'd like to combine all these things together, so I have a control panel on my VPS that sets up webhosting for that domain on 'localhost', sets up the standard mail account for that domain on 'VPS 2' and then creates the standard SMTP account on SMTP2GO.com (they don't have an API, but I'm considering switching SMTP hosts).
If there is no one to be found, I'll just write my own in NodeJS, however, I'd have to look everything up and I hardly feel like doing that. Reason being that most control panels have web statistics and everything automatically included and I don't want to build this in myself.
ok i am having issues w/ my vps. so i set up nginx and php and everything correctly (or at least i believe so), and i've made a /example.com/public_html/index.php and all but i get a 404 on the main page & when i go to /index.php it says no file input specified. what the fuck.
should i just keep restarting fresh and installing everything again until it eventually works
[QUOTE=ifaux;45401020]ok i am having issues w/ my vps. so i set up nginx and php and everything correctly (or at least i believe so), and i've made a /example.com/public_html/index.php and all but i get a 404 on the main page & when i go to /index.php it says no file input specified. what the fuck.
should i just keep restarting fresh and installing everything again until it eventually works[/QUOTE]
You haven't set up FastCGI correctly and you haven't defined a route for / in the nginx config file.
oh my god i got it working this is a good feeling
[editline]15th July 2014[/editline]
[QUOTE=supersnail11;45401071]You haven't set up FastCGI correctly and you haven't defined a route for / in the nginx config file.[/QUOTE]
i FUCKING GOT IT YEAH WOO
You know what, I'll just write my own webpanel on a seperate VPS with it's own domain, then use that as a control panel for my clients :v: In that case, I don't have to set up email for anyone, I can give them webmail, everything really.
Anyone know of an icon set with operating system logos? Monochrome preferred, but not required
Looking for Win, Mac, Linux, Android, iOS and Web if possible
I've been searching but can't find anything
[QUOTE=HarryG321;45402713]Anyone know of an icon set with operating system logos? Monochrome preferred, but not required
Looking for Win, Mac, Linux, Android, iOS and Web if possible
I've been searching but can't find anything[/QUOTE]
[url]http://www.flaticon.com/[/url]
I love these
[QUOTE=HarryG321;45402713]Anyone know of an icon set with operating system logos? Monochrome preferred, but not required
Looking for Win, Mac, Linux, Android, iOS and Web if possible
I've been searching but can't find anything[/QUOTE]
[url]http://fortawesome.github.io/Font-Awesome/[/url]
Sorry, you need to Log In to post a reply to this thread.