The "No Dev Question is Stupid" Thread - Basic HTML / CSS / Etc.

Discussion in 'DevOps' started by Ryuzaki, Mar 17, 2017.

  1. JasonSc

    •  
    JasonSc

    Joined:
    Mar 30, 2016
    Messages:
    75
    Likes:
    104
    Degree:
    0
    Under a $100 a month is not an issue. The solutions I was finding where $200+ a month or a one time fee of $1K+.

    I'm going to take this for a test drive. It looks very promising. Thank you for your help!
     
  2. Tao

    Tao

    Joined:
    Apr 29, 2017
    Messages:
    88
    Likes:
    75
    Degree:
    0
    Could you use Mturk for this activity?
     
  3. Ryuzaki

    •  
    •  
    Ryuzaki 女性以上のお金 Staff Member

    Joined:
    Sep 3, 2014
    Messages:
    2,546
    Likes:
    4,693
    Degree:
    6
    Sounds like an easy bot to write up. Python, Python Requests, and some Regex. If they're using the same contact form plugin or the same roll-your-own, you can likely get it done with one chunk of code iterating through an array that includes the URLs to the contact pages. Requests & being able to grab Regex right out of the developer console of your browser should make this a walk in the park.

    Some Google searches show people doing similar tasks, like logging into a set of websites with a username, email address, and password, in as little as 15 lines of code and less, using Python & Requests. Since it's a form on the page you can probably just grab the HTML "value=" attribute to tell it which input to use for each piece of text, and skip Regex altogether.
     
    SmokeTree likes this.
  4. JasonSc

    •  
    JasonSc

    Joined:
    Mar 30, 2016
    Messages:
    75
    Likes:
    104
    Degree:
    0
    @turbin3 Thank you!
    Just a quick update. Katalon Studio did the trick. For a nonprogrammer such as myself, it was rather easy to get setup and running. It took about an hour to get a functioning script together.

    Katalon does not have a scheduler, but it has a built in feature which will make batch files, so you can just use Task Manager to schedule to run a batch file.

    I'm not a developer, but this program looks like it could be really hand for simple repeatable tasks.
     
    turbin3 likes this.
  5. turbin3

    •  
    •  
    turbin3

    Joined:
    Oct 9, 2014
    Messages:
    508
    Likes:
    953
    Degree:
    2
    Awesome! Glad to hear it. It certainly looked to be well-developed. Glad to hear the barrier to entry wasn't too high either.
     
  6. ryandiscord

    ryandiscord

    Joined:
    Apr 7, 2016
    Messages:
    208
    Likes:
    127
    Degree:
    1
    I made an image repeater with ACF pro but it doesn't show the wordpress image sizes. Is there a setting or component I'm missing or is this not an option with the ACF image field?
     
  7. mmm91492

    mmm91492

    Joined:
    Dec 5, 2014
    Messages:
    49
    Likes:
    46
    Degree:
    0
    You'll have to get the correct image size when you go to call the image in your PHP template:

    Code:
    $image = get_field('image');
    $size = 'full'; // (thumbnail, medium, large, full or custom size)
    
    if( $image ) {
    
        echo wp_get_attachment_image( $image, $size );
    
    }
     
    ryandiscord likes this.
  8. ryandiscord

    ryandiscord

    Joined:
    Apr 7, 2016
    Messages:
    208
    Likes:
    127
    Degree:
    1
    Thanks, this worked great! I ended up echoing it like this:
    Code:
    <img class="aligncenter" src="<?php echo $image[0]; ?>" alt="<?php echo $alt_text ?>" />
     
    mmm91492 likes this.
  9. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    How difficult would it be to code an algorithm that can create its own RegEx expression if provided with two identical elements on a website? For use in scraping price on websites.
     
  10. Rageix

    •  
    Rageix

    Joined:
    Jan 11, 2017
    Messages:
    76
    Likes:
    90
    Degree:
    0
    Normally it's not all that hard, but depends on how complex the regex is. For scraping prices on websites it's typically not all that difficult because most stores are laid out in a sane, predictable, fashion. RegEx might not even be the best choice honestly there are lots of different ways to scrape a website, xPath can work really well, or you run in to random things like goquery which help out scraping a ton because you can just use css selectors like in jQuery.
     
  11. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    Hey man, I know how to scrape a little, what I need is something else. There's a plugin I used to have that would be able to figure out regex expressions just from selecting 2 prices from 2 unique products. Do I make sense? Like it would ask for product url 1 and price 1, then product url 2 and price 2, and then you'd be able to scrape prices without writing any regex yourself. So there had to be some kind of smart detection going on behind the scenes.
     
  12. Rageix

    •  
    Rageix

    Joined:
    Jan 11, 2017
    Messages:
    76
    Likes:
    90
    Degree:
    0
    Hmm that's interesting I've never seen anything like that, at least not for regex.

    However something along those lines are Chrome and Firefox both have dev tools. Right click the page and open your dev tools, from the Inspector tab (Firefox), or Elements tab (Chrome) you can right click any element and then copy it's XPath. From there it can be pretty simple to just use XPath to scrape. My guess is that is probably what it was, but you never know.
     
  13. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    I don't know, probably wasn't regex then :smile: it did and does work though, do you want me to send you a link to the plugin?
     
  14. Rageix

    •  
    Rageix

    Joined:
    Jan 11, 2017
    Messages:
    76
    Likes:
    90
    Degree:
    0
    Sure, I'd take a look at it.
     
    ragnar likes this.
  15. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    What is the easiest way to create a python gui on Linux (debian)?

    I have a script which gets my earnings across networks. I run it in the browser now, but would prefer a gui, maybe even one with the option of casting to chromecast.
     
  16. Rageix

    •  
    Rageix

    Joined:
    Jan 11, 2017
    Messages:
    76
    Likes:
    90
    Degree:
    0
    Generally I think just making a web app out of it is the easiest option. Flask is a personal favorite framework.

    I'm not sure if you can beam an entire web page from Chrome to a Chromecast so I can't really say. The only thing I know about it is you can send video from Chrome to it.

    There are some other possible options to stream to your Chromecast, you could use something like AirParrot 2 to stream an entire entire desktop to the Chromecast device.

    Also old fashion HDMI but that's not too sexy.
     
    ragnar likes this.
  17. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    Hehe, I already have the webapp with Flask. I suppose it is a bit down the list of priorities to make a gui/chromecast. Ideally though it would be cool to integrate into linux debian os, perhaps in the status line, but I don't know if it is possible.
     
  18. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    A css/javascript issue.

    I have a conflict with css or javascript. I have a wordpress theme with a shortcode that does numbered headings with a circle. Then I install Table of Contents Plus plugin and it breaks these numbered headings. The circle with a number stays in place, but the header now moves straight down vertically, not horizontally.

    I can't figure out what goes on, no css overlap as far as I can tell, could it be javascript? How would I go about debugging this? I was thinking just going on Fiverr to get someone to fix it, but would like to learn how to do it.
     
  19. Ryuzaki

    •  
    •  
    Ryuzaki 女性以上のお金 Staff Member

    Joined:
    Sep 3, 2014
    Messages:
    2,546
    Likes:
    4,693
    Degree:
    6
    You'd want to use your browser's developer tools to view the CSS being applied to the elements. For instance, I'd turn on the ToC plugin and let my header be vertically oriented. Then I'd open the developer console and see exactly the CSS being applied to that element and look for the piece that's making it go vertical. When you find it, you can see under which CSS rule it's being applied and determine if that's coming from the ToC plugin or not.

    Here's a visual example, where the CSS rules are on the left, with the top ones being the ones with the most priority and then descending down to more general rules:

    [​IMG]

    The fix would be to either load a 2nd CSS file last in the header after the wp_head() hook, so that the CSS fix overrides the plugin's CSS file. Or you could inline the CSS fix in your header itself.
     
  20. ragnar

    ragnar

    Joined:
    Dec 31, 2016
    Messages:
    99
    Likes:
    49
    Degree:
    0
    Yeah, I tried that, but I couldn't figure it out, all very confusing to be honest with Wordpress themes, so much css everywhere. I ended up making a fix where I made new circles in css, div/span/h2, which I suppose I could just make into a shortcode myself. Looked better in the end. Still annoys me I can't figure out this stuff. Can't spend an hour here an hour there on minute things like this.
     
  21. turbin3

    •  
    •  
    turbin3

    Joined:
    Oct 9, 2014
    Messages:
    508
    Likes:
    953
    Degree:
    2
    With so many WP themes and plugins, it's pretty typical for CSS to be setup to overwrite lots of things. What I mean by that is, you'll have a lot of default styles, and things will usually be setup to load the CSS files in a certain order. So your custom CSS loads last and....hopefully...overwrites default stuff.

    This is why it's so easy to break styles by inadvertently tweaking things to the point certain files load out of order. That or various performance plugins that concatenate resource files.

    I normally start with the browser developer tools, like Ryuzaki said. What I also like to do is pick an element I'm having problems with, click that element in the HTML. Then I'll pick one of the relevant classes or ID's in the CSS window, pick one of its styles, and I'll "!important" it at the end. When in doubt, !important all the things. :wink: Usually throwing a few of those on a few elements (in the browser purely for debugging) will find the culprit pretty quick.

    Where possible, I wouldn't actually use !important in your production CSS, as it can cause its own issues. It might just be a matter of tweaking your CSS with more specific class / ID paths. Another option is actually adding new classes / IDs into the HTML element (on top of the existing like class="original new") in your plugin or theme template.

    @ragnar, on the Python question, not sure if this would work for what you were asking about. Have you ever used Jupyter (ipython) notebooks? That's a pretty quick and easy way to get you something more GUI-oriented, and working in the browser. That plus something like the Matplotlib library could probably get you up and running pretty quickly with some decent visuals.
     
    ragnar likes this.
  22. Future State

    Future State

    Joined:
    Jul 22, 2014
    Messages:
    108
    Likes:
    86
    Degree:
    0
    I wouldn't recommend this unless you've designed your own theme or plugin, or have set up a child theme. If you edit the templates directly and then upgrade your theme or plugin, your changes will be overwritten each time. And you definitely want to keep your plugins up to date.

    To get around the problem of tools that combine and minify and screw up the order of CSS loading, you should either inline the changes in the header or define the loading of an extra CSS file (like fix.css) at the very end of the header, after wp_head, which is what plugins use to spit out extra files or changes they made.

    It's not elegant and creates either inline CSS (not desirable) or an extra HTTP request (not desirable) but that's the small price you pay when you rely on themes and plugins you didn't make.
     
  23. turbin3

    •  
    •  
    turbin3

    Joined:
    Oct 9, 2014
    Messages:
    508
    Likes:
    953
    Degree:
    2
    Sometimes I forget to be specific. To clarify, I always assume child theme and was speaking from that standpoint, and I shouldn't have mentioned plugins. Obviously doesn't quite apply to plugins.