Jump to content

FrancisChung

Members
  • Posts

    472
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by FrancisChung

  1. Just realised most of PW tables are MyISAM so the -single-transaction flag is kinda useless absolutely futureproof.
  2. Out of interest, how much would the TinyJPG compressed image be ?
  3. @szabesz @pwired : Sorry for the late response. Been very busy with a deadline that inevitably dragged on and on ... For those who are interested, I've got the following for automating my deployment. By all means, it's not perfect nor is it complete but it does the job with a minimal investment of my time. I have structured my DB scripts into 2 categories. The dump_<xxx> scripts and the restore_<yyy2zzz> scripts. The dump scripts are to dump the DB contents as a whole where <xxx> signifies an identifier to the DB you're dumping (e.g. Dev, UAT, Live etc). So my dump_local.sh script looks like #!/bin/bash _now=$(date +"%Y%m%d") _file="../dumps/Dump$_now-LOCAL.sql" echo "Starting Dump to $_file..." /Applications/MAMP/Library/bin/mysqldump -h localhost -P 8889 -u root -p'PasswordHereWithTheQuotes' --single-transaction [DBNAME] "$_file" echo "Dump to $_file finished" Key things to note here is : 1) 1st line of code generates a datestamp 2) It then creates a path of the dump file in the dump folder 3) Then it calls MySQLDump using the predefined parameters. Obviously this is for my local installation, so for a server dump file you'll want to change the dump suffix (from LOCAL to DEV,UAT,LIVE or whatever), the hostname, user, password, port (which will be different to 8889 most likely. Mine is 3306 on our service provider) and DBName. If you;re wondering what the single transaction flag is ... The restore files are similar except for my scripts, I've chosen to do a specific one for each XXX2YYY variation. Not the most efficient, but I'm not a bash script ninja either. XXX being Source, YYY being destination in case your'e wondering. So my restore_local2dev.sh looks like : #!/bin/bash _now=$(date +"%Y%m%d") _file="../Dumps/Dump$_now-LOCAL.sql" echo "Starting restoring from $_file to dev ..." /Applications/MAMP/Library/bin/mysql -h [HostDBServerAddress] -P [HostDBServerPort] -u [HostDBUserLogin] -p'[HostDBUserPwdInSingleQuotes]' [HostDBName] < "$_file" echo "Restoring from $_file to dev finished" Notes : 1) I'm using mysql instead of mysqldump here 2) I'm assuming you already created a dump today of the DB file you're uploading (line 2 & 3) 3) There's a bit more involved here with the parameters but I hope the long descriptive labels are self explanatory. Feel free to contact me on this forum if you're unsure. By all means these should cover the basics that you need. Things to improve upon are obviously in the security side of things. There's -ssl options and SSL certificate options that I haven't looked in at detail. If anyone is using them and willing to give us a quick primer ....
  4. FrancisChung

    i <? php

    I <3 PW but I'm definitely not in love with PHP
  5. I just wanted to update saying the module doesn't work. The problem is that the actual PHP module it depends on, mobiledetect.php is using $_SERVER['HTTP_USER_AGENT'] which is an outdated way of detecting devices from the server. It failed on Safari where it couldn't distinguish whether you were using it from the Desktop or a mobile device. (You could argue PHP is probably not the way to go, compared to JS but that's another post ) I must have tried every PHP based solution out there in the last couple of weeks. The only thing that has worked for me is UserAgentInfo. I'm posting an example here, in case some one wants to update this module function IsMobile() { $ua = UserAgentInfoPeer::getMy(); $mobile = $ua->isMobile(); return $mobile; } P/S You will need to add a reference to this class (You may need to change the path to suit your code structure) require_once(__DIR__.'/../vendor/UserAgentInfo/UserAgentInfoPeer.class.php'); and then you may need to configure UserAgentInfoConfig class if the caching mechanism (Redis by default) is not what you want. Just change the CACHE_CLASS_NAME to the class you want. //const CACHE_CLASS_NAME = 'UaiCachePhpredis'; //Not installed locally //const CACHE_CLASS_NAME = 'UaiCacheMemcached'; //Not installed on Provider //const CACHE_CLASS_NAME = 'UaiCacheAPC'; //Not installed on Provider const CACHE_CLASS_NAME = 'UaiCacheDebug'; FYI I had to go for the non cached version (UaiCacheDebug) because of the hosting solution we currently have (i.e. el cheapo solution)
  6. I have some automated scripts that dump the whole database into a file and uploads that to a dbserver and db of choice. I use this to do my deployments for testing and going live. I normally don't touch config.php unless there's been a version upgrade of PW. Let me know if you're interested and I can post it here.
  7. Are you using a VPN or anything that is changing your IP Address? I normally see this when my IP address has changed and I try to login to the backend again.
  8. @adrian, it was failing on this 1 particular call. All the other calls were working fine. In any case, I will change it to "pages" as it's the correct method.
  9. I've used wire(pages) everywhere on my codebase. This was the first time I've had an issue with it. I probably will leave it alone but I'll keep your post it mind. Thanks for the pointer, @Christophe. Much appreciated.
  10. The problem turned out to be a bug in PW 2.6.1. I didn't realise my local PW version was on 2.8.35 and not 2.6.1. The bug was in $ad = wire(pages)->get("/ads/")->children->getRandom(); It was not returning an object in PW 2.6.1 despite data being present. Live and (hopefully) learn ....
  11. Hi there, I'm having a weird issue with the instanceof operator where it works locally and not on my server. I'm using PW3 + PHP7. I've posted the question on Stackoverflow but I was wondering if anyone here have seen it? http://stackoverflow.com/questions/42552855/php-instanceof-works-locally-but-not-on-host-server Thanks in advance.
  12. I've just installed it on a PW 3.x site. It seems to detect Desktop correctly but I think it's returning an empty string for mobile. Haven't tested for Tablet but for my purposes I can live with this as I'm only interested in whether it's Desktop or not. Will update if it can't detect Desktops correctly. if (wire(config)->mobileDetect->deviceType<>'desktop') { .... }
  13. A snowboard attached underneath would be just ....
  14. It looks like it could be useful to those using Chrome & CDNs , so thought I would share. http://www.ghacks.net/2017/02/15/local-cdn-for-chrome/
  15. Surely you would trust .... Processflier?
  16. robots.txt is a good start, but it may not stop some crawlers from crawling your pages anyway. Have you tried hiding your other pages / templates?
  17. The code is from a function. I tried your suggestion before the Ajax call but unfortunately, it didn't work. I have found another way around the issue, but thanks for your suggestion. It gave me an idea for the workaround.
  18. Hi there, I have a globally declared variable where I want to store a mapping table. var _Pagelist=new Map(); The following Ajax call doesn't seem to set _Pagelist above. I think I have set the context parameter correctly to 'this'. I've scoured through Stackoverflow and JQuery documentation but I can't figure out what is wrong. Any pointers would be much appreciated. Thanks if (!pagelist){ SearchWaitDisplay(true); $.ajax({ url: '/site/pagelist.php', context : this , success: function(result) { //here this._Pagelist is null, can't refer to This._Pagelist for (var x=0;x<result.length;x++) { this._Pagelist.set(result[x].id, result[x].url); //This will throw an error as _Pagelist is NULL. }; window.localStorage.setItem('pagelist', JSON.stringify(_Pagelist)); //The following will not update _Pagelist. Next 2 lines are just test code. this._Pagelist = result; window._Pagelist = result; SearchWaitDisplay(false); }, error: function (xhr, ajaxOptions, thrownError) { alert(xhr.status + ' ' + thrownError); } }); } else { //InitialiseSearchField(autocompletelist); }
  19. Yes I couldn't understand myself either. I've corrected myself
  20. @szabesz I trialed a few years ago and didn't really like the interface as compared to Winmerge on Windows. Didn't realise they have a OS X Client now. @adrian Thanks for the head's up. I've discovered something called SyncThing so I'll probably look at this first. If I'm not happy with it, I'm definitely getting a commerical solution.
  21. I guess you don't have to own a powerful highend notebooks to be able to code. Just need a net/notebook or a fast internet connection and in theory, you're good to go. If the web IDEs tied that with an integrated ability to run and test your code on the cloud, then watch out.
  22. Hi there, I have an older Macbook Pro which I'm trying to use as a Desktop Machine for the occasional work-at-home machine. I was using Resilio Sync to sync my projects between my main laptop and every time there's a problem with the sync, it seems to delete random files and folders. So anyone using Resilio Sync, think again. I would have used rsync but if I recall correctly, I couldn't the get the command to work with my other laptop (rsync wouldn't accept my destination path). I also have some files I sync between the main laptop and my Windows box, so that was another reason why I opted for Resilio Sync at the time. So after spending a few hours recovering my files today, I've decided enough is enough (3rd time it's failed) and am looking for a new way to sync files between 2 OSX Laptops and a Windows box. Anyone have a foolproof, stress-free solution that they use? Thanks!
  23. @netcarver, @LostKobrakai, @Martijn Geerts, Thanks for your generous input. I think I will try netcarver's suggestion first and see how I go. The fire + forget could be useful for storing extra debugging logs. If I need more heavy duty threading options, I will look into reactPHP and Elixir.
  24. Hi there, I was wondering if page->url and page->httpUrl are stored anywhere in the backend? I haven't been able to locate it so I'm beginning to think these are generated or calculated on the fly? Thanks in advance
  25. I was afraid someone might say this. I haven't seen anything out there that indicates otherwise.
×
×
  • Create New...