• Web Dev Questions That Don't Need Their Own Thread v4
    5,001 replies, posted
[QUOTE=jetboy;42741256]DB table `seen_threads` with thread_id, user_id, timestamp[/QUOTE] And if there are no available entries, should I assume unread unless it's older than, say, 2 weeks?
What do you guys do all your web dev on?
[QUOTE=AndrewPH;42743873]And if there are no available entries, should I assume unread unless it's older than, say, 2 weeks?[/QUOTE] If it were to operate like FP then it wouldn't show at all if there was no entry in the table.
[QUOTE=littlefoot;42744027]If it were to operate like FP then it wouldn't show at all if there was no entry in the table.[/QUOTE] ..Wouldn't that mean that new threads would show up as read?
[QUOTE=Erasus;42743947]What do you guys do all your web dev on?[/QUOTE] Arch with Vim/Sublime Text
[QUOTE=Erasus;42743947]What do you guys do all your web dev on?[/QUOTE] I like using Netbeans. And Notepad++ for SQL
[QUOTE=AndrewPH;42744184]..Wouldn't that mean that new threads would show up as read?[/QUOTE] Just like FP? If you haven't visited it, then it doesn't show that new post were made.
If there isn't an entry for thread and user, it's unread. If there is an entry for thread and user and the last post in the thread was made AFTER `timestamp`, it's unread. If there is an entry for thread and user and the last post in the thread was made BEFORE `timestamp`, it's read.
[QUOTE=littlefoot;42747242]Just like FP? If you haven't visited it, then it doesn't show that new post were made.[/QUOTE] It shows up as [i]unread[/i]. Otherwise they wouldn't be bold.
[QUOTE=AndrewPH;42750439]It shows up as [i]unread[/i]. Otherwise they wouldn't be bold.[/QUOTE] Sorry, I misunderstood what you were going for. Was thinking of only FP's new post indicator, not the emboldening of titles. I wonder if Jetboy's solution is what FP actually uses, it'd work perfect but seems like it'd be intensive on a forum as large as FP. I have no sense of scaling as far as databases go though, so.
I got SFTP on my Sublime Text 3, however it doesn't work. I got a folder on my server called [B]furnitureandmore[/B] for a school project and I wan't to work on the server itself. Here's my setup: [code] { // The tab key will cycle through the settings when first created // Visit http://wbond.net/sublime_packages/sftp/settings for help // sftp, ftp or ftps "type": "sftp", "sync_down_on_open": true, "sync_same_age": true, "host": "math.wigf8.sde.dk", "user": "math.wigf8", "password": "password", "port": "21", "remote_path": "/furnitureandmore/", //"file_permissions": "664", //"dir_permissions": "775", //"extra_list_connections": 0, "connect_timeout": 30, //"keepalive": 120, //"ftp_passive_mode": true, //"ssh_key_file": "~/.ssh/id_rsa", //"sftp_flags": ["-F", "/path/to/ssh_config"], //"preserve_modification_times": false, //"remote_time_offset_in_hours": 0, //"remote_encoding": "utf-8", //"remote_locale": "C", } [/code] All my details are correct, accept for password which I deleted for this post. I'll be sure to have it in the actual config, the config is saved in the same folder with all the other files that should be uploaded as a "sftp-config.json". I literally can't find out what's wrong, any help?
[QUOTE=Moofy;42751710]I got SFTP on my Sublime Text 3, however it doesn't work. I got a folder on my server called [B]furnitureandmore[/B] for a school project and I wan't to work on the server itself. ..... I literally can't find out what's wrong, any help?[/QUOTE] Your port is set at 21 that's for FTP you should use 22 if you're using SFTP unless you changed the port for SFTP for some reason.
Hey, I need help writing a pattern/expression for javascript validation. I need the input for phone on a form to be in this format: (0X)XXXXXXXX (with the brackets).
[QUOTE=Superkipje;42751874]Your port is set at 21 that's for FTP you should use 22 if you're using SFTP unless you changed the port for SFTP for some reason.[/QUOTE] That might be the case, I'll look into it. Thanks!
[QUOTE=SammySung;42752472]Hey, I need help writing a pattern/expression for javascript validation. I need the input for phone on a form to be in this format: (0X)XXXXXXXX (with the brackets).[/QUOTE] var validate = (/^\(0\d\)\d{8}$/); if (validate.test(text)) { Should work if i'm not mistaken. I've embedded a google drive video (essentially the same as a youtube video i think) into a web page using an iframe. Now when i load the page it jumps down to where the video is and then jumps back up to the top, or sometimes it just stays at where the video is. I think it is something to do with the iframe getting focus when it loads or something similar. Any ideas how to stop it from happening?
[QUOTE=Moofy;42751710]I got SFTP on my Sublime Text 3, however it doesn't work. I got a folder on my server called [B]furnitureandmore[/B] for a school project [B]and I wan't to work on the server itself[/B].[/QUOTE] You shouldn't get in the habit of doing this. It's baaaad practice.
I'm having a hell of a time trying to find information about this for some reason. Getting the right time with Javascript shouldn't be this tricky. [code] <script type="text/javascript"> date = new Date().toISOString().substr(0,10); document.getElementById("dateinput").value = date </script> [/code] That's what I have to autofill a date into one of my textboxes. It works fine until you hit 7:00PM and it spits out tomorrow's date, since it doesn't seem to be taking into account the computer's timezone (EST -5:00). How can I have it use the local timezone?
[QUOTE=benjgvps;42760327]I'm having a hell of a time trying to find information about this for some reason. Getting the right time with Javascript shouldn't be this tricky. [code] <script type="text/javascript"> date = new Date().toISOString().substr(0,10); document.getElementById("dateinput").value = date </script> [/code] That's what I have to autofill a date into one of my textboxes. It works fine until you hit 7:00PM and it spits out tomorrow's date, since it doesn't seem to be taking into account the computer's timezone (EST -5:00). How can I have it use the local timezone?[/QUOTE] Check the docs for date and maybe try getting rid of the toISOString and concatenating the result of getMonth/getFullYear/getDate/whatever you need to get the right format. [url]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Methods[/url]
Anyone here good at mongodb? I have a collection with documents like this: userid: backpack: and in the backpack there are items. backpack{result{items{ and in that there are multiple arrays of items. [quote] { "result" : { "items" : [ { "id" : 375911790, "original_id" : 375911790, "defindex" : 312, "level" : 5, "quality" : 6, }, { "id" : 375911791, "original_id" : 375911791, "defindex" : 39, "level" : 10, "quality" : 6, }, ]}} [/quote] These are part of a subdocument. I want to return ONLY the [quote] { "id" : 375911791, "original_id" : 375911791, "defindex" : 39, "level" : 10, "quality" : 6, }, [/quote] part instead of the entire document. how would I do this? I can already go db.users.find({'backpack.result.items.quality' : 5 }); but that gives me the entire user and their backpack and everything. what should I modify to only get that part?
[QUOTE=KmartSqrl;42760380]Check the docs for date and maybe try getting rid of the toISOString and concatenating the result of getMonth/getFullYear/getDate/whatever you need to get the right format. [url]https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date#Methods[/url][/QUOTE] That's what I was doing before, I had this code: [code] <script type="text/javascript"> var d = new Date(); var day = d.getDate(); var month = d.getMonth() + 1; var year = d.getFullYear(); var date = year + "-" + month + "-" + day; document.getElementById("dateinput").value = date </script> [/code] And it gets the right day, though the day (And possibly the month, I haven't bothered checking) is only represented as one digit (2013-11-5). So when I shove it into my sqlite database and sort it, the single digit day is at the top. I could make an if statement that tacks on a 0 to the front if it's less than ten, though that's more work than it should be and I feel that there has to be a better way.
[QUOTE=benjgvps;42771305]That's what I was doing before, I had this code: [code] <script type="text/javascript"> var d = new Date(); var day = d.getDate(); var month = d.getMonth() + 1; var year = d.getFullYear(); var date = year + "-" + month + "-" + day; document.getElementById("dateinput").value = date </script> [/code] And it gets the right day, though the day (And possibly the month, I haven't bothered checking) is only represented as one digit (2013-11-5). So when I shove it into my sqlite database and sort it, the single digit day is at the top. I could make an if statement that tacks on a 0 to the front if it's less than ten, though that's more work than it should be and I feel that there has to be a better way.[/QUOTE] Here, use this, this will be an even better solution since Javascript doesn't have strftime natively: [url]https://github.com/samsonjs/strftime[/url] It will let you get zero padded days and months.
[QUOTE=KmartSqrl;42771412]Here, use this, this will be an even better solution since Javascript doesn't have strftime natively: [url]https://github.com/samsonjs/strftime[/url] It will let you get zero padded days and months.[/QUOTE] Nifty, I'll bookmark that for next time I need to deal with dates. For this little thing I'm working on, I ended up finding a stackoverflow that was similar to my question and now I have: [code] <script type="text/javascript"> function pad(n) { if (n < 10) return "0" + n; return n; } var d = new Date(); var day = pad(d.getDate()); var month = pad(d.getMonth() + 1); var year = d.getFullYear(); var date = year + "-" + month + "-" + day; document.getElementById("dateinput").value = date </script> [/code] Which is pretty much my "Ugly" idea that I had above. But it works and it's smaller than that javascript file.
Is it possible to get the name of a variable as a string in php?
[QUOTE=gokiyono;42773453]Is it possible to get the name of a variable as a string in php?[/QUOTE] I hate to ask but why? I can't think of a scenario that would require this. It does sound like something that could be far better accomplished using an associative array or object.
[QUOTE=CBastard;42774314]I hate to ask but why? I can't think of a scenario that would require this. It does sound like something that could be far better accomplished using an associative array or object.[/QUOTE] I can't remember. But now I just wanted to see if it was possible.
[QUOTE=gokiyono;42774510]I can't remember. But now I just wanted to see if it was possible.[/QUOTE] The very first result from a google search for "php get variable name as string": [url]http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php[/url]
[QUOTE=KmartSqrl;42778935]The very first result from a google search for "php get variable name as string": [url]http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php[/url][/QUOTE] That highest rated answer is absolutely awful.
I saw this one which was good. [quote] function getvarname(&$var) { $ret = ''; $tmp = $var; $var = md5(uniqid(rand(), TRUE)); $key = array_keys($GLOBALS); foreach ( $key as $k ) if ( $GLOBALS[$k] === $var ) { $ret = $k; break; } $var = $tmp; return $ret; } //test: $another = 'test'; $testvar = 'test'; echo getvarname($testvar); //echoes 'testvar'[/quote]
[QUOTE=KmartSqrl;42778935]The very first result from a google search for "php get variable name as string": [url]http://stackoverflow.com/questions/255312/how-to-get-a-variable-name-as-a-string-in-php[/url][/QUOTE] Wouldn't getting all variables in the document be a bit overkill?
[code]RewriteRule ^([^/]*)/([^/]*)/([^/]*)/?$ /index.php?query=$1;$2;$3 [L][/code] How would i make this work with only one of the $'s? Having a whole row of them doesn't work. edit: [url=http://stackoverflow.com/questions/14621622/htaccess-mod-rewrite-url-with-multiple-optional-parameters]god damnit just found it[/url]
Sorry, you need to Log In to post a reply to this thread.