Web Dev Questions That Don't Need Their Own Thread v4
5,001 replies, posted
ok i fucking got it.
for future reference when i eventually fuck up and have to start over:
had the root in location and not server in my nginx config.
[editline]18th July 2014[/editline]
im a piece of shit dont look at me
[editline]18th July 2014[/editline]
i am literally about to give up on installing ghost because node.js is apparently so impossible to install on debian and hit up wordpress or something. using every single normal tutorial involving git & make ends w/ make: *** [node] error 2 and doesnt work, every wheezy backports repository just doesnt fucking work and trying from the sid repo totally fucked my shit.
wtf yo.
[editline]18th July 2014[/editline]
the last few lines every time i try to use make:
[code]
g++: internal compiler error: Killed (program cc1plus)
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-4.7/README.Bugs> for instructions.
make[1]: *** [/root/node/out/Release/obj.target/v8_base/deps/v8/src/api.o] Error 4
make[1]: Leaving directory `/root/node/out'
make: *** [node] Error 2
[/code]
[editline]18th July 2014[/editline]
ok i always fix things right after i post in this thread. ignore me. can someone explain that though
Are you close to your memory limit? The process could be OOM killed - especially if you're running that in a VPS.
ok so i got as far as installing node and npm and now i am trying to install ghost a la their own guide on their own website ([url]http://docs.ghost.org/installation/linux/[/url]). node is installed correctly as is npm. running the npm install --production command fails (apparently):
[code]root@isekkiwa:~/ghost# npm install --production
> sqlite3@2.2.0 install /root/ghost/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
Command failed:
module.js:356
Module._extensions[extension](this, filename);
^
Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /root/ghost/node_modules/sqlite3/lib/node_sqlite3.node)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/ghost/node_modules/sqlite3/lib/sqlite3.js:1:77)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
node-pre-gyp ERR! Testing pre-built binary failed, attempting to re-download
make: Entering directory `/root/ghost/node_modules/sqlite3/build'
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c
TOUCH Release/obj.target/deps/action_before_build.stamp
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3080200/sqlite3.o
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c: In function 'porter_stemmer':
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131970:41: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131974:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131987:35: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131992:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131998:41: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132003:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132012:38: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132019:37: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132062:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132082:34: warning: value computed is not used [-Wunused-value]
Killed
root@isekkiwa:~/ghost# AR(target) Release/obj.target/deps/sqlite3.a
COPY Release/sqlite3.a
CXX(target) Release/obj.target/node_sqlite3/src/database.o
CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
CXX(target) Release/obj.target/node_sqlite3/src/statement.o
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node: Finished
COPY Release/node_sqlite3.node
COPY ../lib/node_sqlite3.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory `/root/ghost/node_modules/sqlite3/build'[/code]
any ideas
[QUOTE=ifaux;45432531]ok so i got as far as installing node and npm and now i am trying to install ghost a la their own guide on their own website ([url]http://docs.ghost.org/installation/linux/[/url]). node is installed correctly as is npm. running the npm install --production command fails (apparently):
any ideas[/QUOTE]
you're missing glibc, install it.
[QUOTE=ifaux;45432531]ok so i got as far as installing node and npm and now i am trying to install ghost a la their own guide on their own website ([url]http://docs.ghost.org/installation/linux/[/url]). node is installed correctly as is npm. running the npm install --production command fails (apparently):
[code]root@isekkiwa:~/ghost# npm install --production
> sqlite3@2.2.0 install /root/ghost/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
Command failed:
module.js:356
Module._extensions[extension](this, filename);
^
Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /root/ghost/node_modules/sqlite3/lib/node_sqlite3.node)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/root/ghost/node_modules/sqlite3/lib/sqlite3.js:1:77)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
node-pre-gyp ERR! Testing pre-built binary failed, attempting to re-download
make: Entering directory `/root/ghost/node_modules/sqlite3/build'
ACTION deps_sqlite3_gyp_action_before_build_target_unpack_sqlite_dep Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c
TOUCH Release/obj.target/deps/action_before_build.stamp
CC(target) Release/obj.target/sqlite3/gen/sqlite-autoconf-3080200/sqlite3.o
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c: In function 'porter_stemmer':
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131970:41: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131974:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131987:35: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131992:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:131998:41: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132003:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132012:38: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132019:37: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132062:39: warning: value computed is not used [-Wunused-value]
Release/obj/gen/sqlite-autoconf-3080200/sqlite3.c:132082:34: warning: value computed is not used [-Wunused-value]
Killed
root@isekkiwa:~/ghost# AR(target) Release/obj.target/deps/sqlite3.a
COPY Release/sqlite3.a
CXX(target) Release/obj.target/node_sqlite3/src/database.o
CXX(target) Release/obj.target/node_sqlite3/src/node_sqlite3.o
CXX(target) Release/obj.target/node_sqlite3/src/statement.o
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node
SOLINK_MODULE(target) Release/obj.target/node_sqlite3.node: Finished
COPY Release/node_sqlite3.node
COPY ../lib/node_sqlite3.node
TOUCH Release/obj.target/action_after_build.stamp
make: Leaving directory `/root/ghost/node_modules/sqlite3/build'[/code]
any ideas[/QUOTE]
[code]Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.14' not found (required by /root/ghost/node_modules/sqlite3/lib/node_sqlite3.node)[/code]
This is the line of the error you should be looking at :)
[QUOTE=TrinityX;45432689]you're missing glibc, install it.[/QUOTE]
can you tell me what package i should be installing? i googled around and it said it was part of build-essentials (which i already have) and then found libpackagekit-glib2-14 but it's still spitting out the same error
[QUOTE=ifaux;45432977]can you tell me what package i should be installing? i googled around and it said it was part of build-essentials (which i already have) and then found libpackagekit-glib2-14 but it's still spitting out the same error[/QUOTE]
What version of glibc do you have installed? Run /lib/x86_64-linux-gnu/libc.so.6 and it should tell you.
I used this guide for CentOS. I'm not sure if it's the same on other Linux distros.
[url=https://www.digitalocean.com/community/tutorials/how-to-install-and-run-a-node-js-app-on-centos-6-4-64bit]Clicky[/url]
[QUOTE=supersnail11;45433066]What version of glibc do you have installed? Run /lib/x86_64-linux-gnu/libc.so.6 and it should tell you.[/QUOTE]
2.13 :v:
[editline]19th July 2014[/editline]
oy downloading glibc-2.19 from the testing branch after following instructions on keeping a mixed debian system
hopefully i dont fuck everything up wish me luck
it works y'all
now lets see what the next error code it spits out is
[editline]19th July 2014[/editline]
what the fuck my automerge
-snip-
If you want them on a new line, just throw a <br> after "All rights reserved.". If you don't want that, and you mean vertical alignment, set a negative margin depending on the size of the icons and the size of your text.
Try - ((size of icon) - (size of text) / 2)
[QUOTE=ifaux;45434363]it works y'all
now lets see what the next error code it spits out is
[editline]19th July 2014[/editline]
what the fuck my automerge[/QUOTE]
This is actually somewhat cute to watch since I learned to do this only a few months ago as well.
Don't worry, you'll figure it all out in time.
I finished all of the PHP lessons on Codeacademy! Woo! Now I want to get into databases and stuff.
What's the best way to run SQL on my desktop just for testing purposes?
(Note: I stopped learning Node.JS because all of the tutorials expect you to know PHP or something similar, and I'd have to pay extra to use Node.JS as an actual dedicated server from my host. It's sitting on the backburner for now and I'll return to it because it's pretty interesting and seems like a nice thing to get into after I have an understanding of PHP and what not.)
On my Dev site which can be seen [URL="http://development.jonathanmaby.co.uk/"]here[/URL], the block/text area displays behind the slideshow. If you refresh the page several times rapidly, you will see the text load before the slideshow (briefly). How would I get the text under the slideshow?
[QUOTE=wauterboi;45453244]I finished all of the PHP lessons on Codeacademy! Woo! Now I want to get into databases and stuff.
What's the best way to run SQL on my desktop just for testing purposes?
(Note: I stopped learning Node.JS because all of the tutorials expect you to know PHP or something similar, and I'd have to pay extra to use Node.JS as an actual dedicated server from my host. It's sitting on the backburner for now and I'll return to it because it's pretty interesting and seems like a nice thing to get into after I have an understanding of PHP and what not.)[/QUOTE]
I would install WAM[ySQL]P, which also allows you to practice with PHP.
[QUOTE=wauterboi;45453244]I finished all of the PHP lessons on Codeacademy! Woo! Now I want to get into databases and stuff.
What's the best way to run SQL on my desktop just for testing purposes?
(Note: I stopped learning Node.JS because all of the tutorials expect you to know PHP or something similar, and I'd have to pay extra to use Node.JS as an actual dedicated server from my host. It's sitting on the backburner for now and I'll return to it because it's pretty interesting and seems like a nice thing to get into after I have an understanding of PHP and what not.)[/QUOTE]
I got [URL="https://www.apachefriends.org/index.html"]XAMPP[/URL] installed to work with PHP locally, just make sure to disable the ports being used by Skype in case you also use Skype:
[IMG]http://i.imgur.com/siNU24K.png[/IMG]
[b]FIXED THE ISSUE! READ BELOW![/b]
I have two problems. I'm using PassportJS for my user authentication.
I can create accounts, create cookies and log in users.
The problem I am facing, is that my logout function does not work, and my remember-me is not being authenticated.
Here's a snippet of code:
[b]website.js[/b] (the file I run)
[code]/////////////////////////////
// SETTING UP EXPRESS
/////////////////////////////
var app = express();
require('./config/passport')(passport);
// Set up view engine
app.set("views", path.join(__dirname, "layout"));
app.set("view engine", "jade");
app.use(favicon());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
app.use(cookieParser());
// Passport
app.use(session({ secret: "snip"}));
app.use(passport.initialize());
app.use(passport.session());
app.use(flash());
app.use(passport.authenticate("remember-me"));
/////////////////////////////
// PAGE HANDLING
/////////////////////////////
require("./routes.js")(app);[/code]
[b]routes.js[/b]
[code]var pages = {
home: require("./pages/home"),
about: require("./pages/about"),
register: require("./pages/register"),
login: require("./pages/login"),
api: require("./api/index"),
};
module.exports = function(app) {
app.all("*", function(req, res, next) {
if(req.isAuthenticated()) {
app.locals.user = req.user;
}
app.locals.successFlash = req.flash("success");
next();
});
app.use("/", pages['home']);
for (page in pages) {
app.use("/" + page, pages[page]);
}
app.get("/logout", function(req, res) {
console.log("Getting here?");
res.clearCookie("scjs_rememberme");
req.logout();
req.session.destroy();
console.log("Should be logged out");
res.redirect("/");
});
}[/code]
The weird thing is, it NEVER logs me out. The console.log()s are both printed in the console and I am redirected where-ever I want (res.redirect("/"); works fine). So this, the not being able to log out, is one of my problems. There are no errors whatsoever. I also tried the "solutions" given [url=http://stackoverflow.com/questions/13758207/why-is-passportjs-in-node-not-removing-session-on-logout]here[/url]
Other than that, I followed [url=https://github.com/jaredhanson/passport-remember-me/blob/master/examples/login/server.js]this structure[/url] for my remember-me. The problem now being, it NEVER reaches the remember me code. The cookie is existing on my computer, but it never even reaches my passport.use(new rememberMeStrategy()). Here's the code:
[b]/config/passport.js[/b]. Other passport.use() from this file work fine, it's just this one that doesn't work.
[code]passport.use(new rememberMeStrategy(
function(token, done) {
console.log("Getting here?");
userStructure.UseCookieToken(token, function(err, uid) {
if(err) {
return done(err);
}
if(!uid) {
return done(null, false);
}
userStructure.LoadUser(uid, function(err, user) {
if(err) {
return done(err);
}
if(!user) {
return done(null, false);
}
return done(null, user);
});
});
},
userStructure.CreateCookie
));[/code]
The "Getting here?" is never printed, while my set up seems the same as in the example. I hope anyone here has experience with all this, I have been trying for a good 4-5 hours...
-edit-
Problem had todo with this snippet of code:
[code]app.all("*", function(req, res, next) {
if(req.isAuthenticated()) {
app.locals.user = req.user;
}else{
app.locals.user = null;
}
app.locals.successFlash = req.flash("success");
next();
});[/code]
I did not have an "else" statement setting app.locals.user to null. I didn't expect app.locals to cache. Either way, it now works. I still have the issue with the remember-me cookie though.
-edit2-
I resolved my issue. I read the source code for the RememberMeStrategy and it had 3 arguments instead of 2. In the example file, only 2 arguments are passed, but the strategy does the following:
[code]if (typeof options == 'function') {
issue = verify;
verify = options;
options = {};
}[/code]
Meaning, I just had to specify options to support my custom cookie name, as the default is "remember_me".
My problem still stands that my main content div goes behind the content I have at the top of the page. The homepage has a slideshow at the top (under the header/nav) and the other pages have an image at the top (under the header/nav). For each page the content I want displays behind, and not under...
[URL="http://development.jonathanmaby.co.uk"]The site can be seen here[/URL]
I have no idea what's gone wrong :/
-snip-
It is due to the fact that you use "position: absolute;" to make your slider full width. This is not the correct way to do it.
Make a class called "container", make that one the width you want, i.e., 960px.
[code].container {
width: 960px;
margin: 0 auto; /* centers it in your page */
}[/code]
Then make your slider just full-width, without the position absolute everywhere. If you do it that way, you will have a block that takes up 100% of the page, and a 960px width block below it for your page content.
This counts for all your pages.
-edit-
Your problems are really caused by the fact you use "position: absolute" a lot. Fix it, rebuild your page from scratch, leave out the position.
Im confused asf right now
[QUOTE=ENG.jonny;45455488]Im confused asf right now[/QUOTE]
You should maybe read more about [URL=http://www.responsivegridsystem.com/]Responsive Grids[/URL] if you want your stuff to move around on resize (or you could just use CSS3 Media Queries).
Rails routing question:
I currently have a Player model in my app that is routed like so:
[code]
resources :players, only: [:index, :show] do
get ":skill(/:time)", to: :show
end
[/code]
My problem is that the get matcher is bugging me since it feels like a hack. I don't want to nest resources and end up with "/players/some_player/skill/some_skill/time/some_time" as my route since it's just silly long and the "skill" and "time" parts are redundant.
Is there a more concise, clear and less hardcoded way of routing this?
[QUOTE=sambooo;45456750]Rails routing question:
I currently have a Player model in my app that is routed like so:
[code]
resources :players, only: [:index, :show] do
get ":skill(/:time)", to: :show
end
[/code]
My problem is that the get matcher is bugging me since it feels like a hack. I don't want to nest resources and end up with "/players/some_player/skill/some_skill/time/some_time" as my route since it's just silly long and the "skill" and "time" parts are redundant.
Is there a more concise, clear and less hardcoded way of routing this?[/QUOTE]
That [i]is[/i] the most concise method, mainly because "/players/some_player/skill/some_skill/time/some_time" doesn't take that route. If you drop the /skill and /time, it routes:
"/players/some_player/some_skill/some_time"
And that should cause it to take the proper route.
[editline]21st July 2014[/editline]
To be honest, you'd probably want something more like
[code]
resources :players, only: [:index, :show] do
resources :skills do
get ":time", to: :show
end
end
[/code]
mainly because you might want to display the player and the skills separately.
I'm not sure it makes sense to have a skill model since they aren't something that ever changes or needs to be updated. If it helps the context is that I'm rewriting [url]http://crystalmathlabs.com[/url] in rails.
[editline]21st July 2014[/editline]
Also part of the reason I don't want/link the hardcoded route like that is that it feels like duplication when I intend to write a helper for it. Should this just be something I do and then make sure it works with a test?
I am a bit confused about Jade and so on, what's the real benefit of using it other than you don't have to type a shit-ton of < > etc?
[QUOTE=Moofy;45461082]I am a bit confused about Jade and so on, what's the real benefit of using it other than you don't have to type a shit-ton of < > etc?[/QUOTE]
What else do you need? It's a templating language that makes it easier to write HTML.
[QUOTE=supersnail11;45461250]What else do you need? It's a templating language that makes it easier to write HTML.[/QUOTE]
Well maybe it has some other benefits other than a easier way to write HTML, for example with SASS and stuff you get functions, variables & more to work with in CSS. :v:
[QUOTE=Moofy;45461271]Well maybe it has some other benefits other than a easier way to write HTML, for example with SASS and stuff you get functions, variables & more to work with in CSS. :v:[/QUOTE]
It's a templating language, it has features that a templating language has. I don't know what you can add to HTML that a templating language wouldn't have and that shouldn't be in your controller.
[QUOTE=Moofy;45461271]Well maybe it has some other benefits other than a easier way to write HTML, for example with SASS and stuff you get functions, variables & more to work with in CSS. :v:[/QUOTE]
You can use javascript in Jade too. It is also really using variables and creating "modular" websites. You can (for example) define a "block myContent" and define that in another file. i.e.
[b]main.jade[/b]
[code]doctype html
html
body
block myContent
[/code]
[b]home.jade[/b]
[code]extends main.jade
block myContent
h1 Hello world #{username}
[/code]
Then render the whole thing with res.render("home", { username: "Moofy" });
That'll output a file with Hello world Moofy, including the defined <doctype html> in main.jade and such.
[editline]22nd July 2014[/editline]
Also, I'm struggling with my MySQL.
After not using my page for x amount of seconds (or minutes, can't really give you any numbers), my page load takes a lot longer than expected and I receive the following error:
[code]read ECONNRESET
Error: read ECONNRESET
at errnoException (net.js:904:11)
at TCP.onread (net.js:558:19)
--------------------
at Protocol._enqueue (D:\Projects\sourcechatjs.com\node_modules\mysql\lib\protocol\Protocol.js:110:48)
at Connection.query (D:\Projects\sourcechatjs.com\node_modules\mysql\lib\Connection.js:166:25)
at Object.module.exports.userStructure.LoadUser (D:\Projects\sourcechatjs.com\includes\objects\user.js:36:14)
at D:\Projects\sourcechatjs.com\config\passport.js:13:17
at pass (D:\Projects\sourcechatjs.com\node_modules\passport\lib\authenticator.js:353:9)
at Authenticator.deserializeUser (D:\Projects\sourcechatjs.com\node_modules\passport\lib\authenticator.js:358:5)
at SessionStrategy.authenticate (D:\Projects\sourcechatjs.com\node_modules\passport\lib\strategies\session.js:49:28)
at attempt (D:\Projects\sourcechatjs.com\node_modules\passport\lib\middleware\authenticate.js:337:16)
at Layer.authenticate [as handle] (D:\Projects\sourcechatjs.com\node_modules\passport\lib\middleware\authenticate.js:338:7)
at trim_prefix (D:\Projects\sourcechatjs.com\node_modules\express\lib\router\index.js:240:15)[/code]
Does anyone know how to fix this?
My MySQL file looks like this:
[code]var mysql = require("mysql"),
mysqlConfig = require("../config/mysql");
connection = mysql.createConnection(mysqlConfig);
connection.connect(function(error) {
if(error) {
console.error("[MySQL] Error connecting to the database: "+error.stack);
}else{
console.log("[MySQL] Connected to "+mysqlConfig.host+":"+mysqlConfig.port+" with ID "+connection.threadId);
}
});
function HandleDisconnect(connection) {
console.log("[MySQL] Setting up reconnection on error");
connection.on("error", function(err) {
if(!err.fatal) {
return;
}
if(err.code !== "PROTOCOL_CONNECTION_LOST") {
console.log("[MySQL] Lost connection to "+mysqlConfig.host+":"+mysqlConfig.port);
throw err;
}
console.log("[MySQL] Connection lost, reconnecting to "+mysqlConfig.host+":"+mysqlConfig.port);
connection = mysql.createConnection(mysqlConfig);
HandleDisconnect(connection);
connection.connect();
});
}
HandleDisconnect(connection);
exports = connection;[/code]
Sorry, you need to Log In to post a reply to this thread.