Posts

Showing posts from March, 2011

Can You Use Scrapy And Selenium Together Code Example

Example: scrapy selenium screnshot #coding=utf-8 import time from selenium import webdriver from selenium . webdriver . chrome . options import Options def test_fullpage_screenshot ( self ) : chrome_options = Options ( ) chrome_options . add_argument ( '--headless' ) chrome_options . add_argument ( '--start-maximized' ) driver = webdriver . Chrome ( chrome_options = chrome_options ) driver . get ( "yoururlxxx" ) time . sleep ( 2 ) #the element with longest height on page ele = driver . find_element ( "xpath" , '//div[@class="react-grid-layout layout"]' ) total_height = ele . size [ "height" ] + 1000 driver . set_window_size ( 1920 , total_height ) #the trick time . sleep ( 2 ) driver . save_screenshot ( "screenshot1.png" ) driver . quit ( ) if __name__ == "__main__" : test_fullpage_screenshot ( )

Accessing Localhost (xampp) From Another Computer Over LAN Network - How To?

Image
Answer : Localhost is just a name given for the loopback, eg its like referring to yourself as "me" .. To view it from other computers, chances are you need only do http://192.168.1.56 or http://myPcsName if that doesnt work, there is a chance that there is a firewall running on your computer, or the httpd.conf is only listening on 127.0.0.1 Thanks for a detailed explanation. Just to Elaborate, in Windows, Go to Control Panel -> Firewall, in exceptions "add http and port 80". Then in Services check mark "http (web server port 80)" and "https (web server port 443)" ONLY if you need https to work also. Ok, OK, Close Then go to any computer on network and type http://computer-name (where you change the firewall and has the xampp running on it) in your web browser and happy days :) it's very easy Go to Your XAMPP Control panel Click on apache > config > Apache (httpd.conf) Search for Listen 80 and replace with Listen 8

:hover Javascript Code Example

Example 1: javascript hover event element .onmouseover = function ( ) { //Hovering } Example 2: javascript on hover <img onmouseover="enlargeImage ( this ) " border="0" src="smiley .gif " alt="Smiley" width="32" height="32" > <script > function enlargeImage ( x ) { x.style.height = "64px" ; x.style.width = "64px" ; } </script> Example 3: hover con js // Creamos el evento mouseover para cada imagen imagenes [ i ] .addEventListener ( "mouseover" , function ( e ) { document. getElementById ( "mostrar" ) .style.backgroundImage= "url('" +e.target.currentSrc+ "')" ; } ) ; // Creamos el evento mouseout para cada imagen imagenes [ i ] .addEventListener ( "mouseout" , function ( e ) { document. getElementById ( "mostrar" ) .style.backgroundImage= "" ; } ) ;

How To Remove Ul Li Dot Code Example

Example 1: remove bullets from list css ul { list-style-type : none ; margin : 0 ; padding : 0 ; } Example 2: eliminate dots li ul { list-style-type : none ; } Example 3: how to remove bullet point from li list-style-type : none ; Example 4: remove bullets from ul ul { list-style-type : none ; } Example 5: how to remove ul dots ul .ba { list-style-type : none ; }

Crontab Do Something Every 6 Hours Code Example

Example 1: cron every 3 hours 0 */3 * * * Example 2: cron every two hours 0 */2 * * *

Css Slider Vertical Code Example

Example 1: vertical slider html <!-- For Firefox: orient="vertical" For Chrome & Safari: -webkit-appearance: slider-vertical For IE: writing-mode: bt-lr --> <!-- Example range slider --> < input type = " range " min = " 0 " max = " 100 " value = " 50 " class = " vertical " orient = " vertical " style = " -webkit-appearance : slider-vertical ; writing-mode : bt-lr ; " > <!-- ***PLEASE NOTE*** The -webkit-appearance property is non-standard, so it's behaviour may change across different browsers --> Example 2: adding vertical sliders in css overflow-y: scroll;

Conda Install Scikit Learn Code Example

Example 1: install sklearn pip install scikit-learn Example 2: conda install scikit-learn conda install -c anaconda scikit-learn Example 3: conda install scipy conda install -c anaconda scipy Example 4: conda install sklearn conda install -c conda-forge scikit-learn Example 5: conda install sklearn 0.20 conda install scikit-learn = 0.20 Example 6: pip install sklearn specific version pip uninstall scikit-learn pip install scikit-learn == 0.18 .2

Montserrat Extra Bold Code Example

Example 1: montserrat font <link rel= "preconnect" href= "https://fonts.gstatic.com" > <link href= "https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel= "stylesheet" > Example 2: monserrat <link href= "https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel= "stylesheet" > font-family : 'Montserrat' , sans-serif ;

Can I Install An Alternative Window Manager On Mac OS X?

Answer : Is there an alternative window manager for OS X (…)? It depends on what you define as window manager. If you mean the entire framework that draws the windows, then no. This has always been the Window Server in conjunction with Quartz. If you mean apps that enhance some of the window switching and layouting behavior, there are plenty of those, but none of them really replaces anything. Have a look at the following projects or tools if you want to tweak the window behavior, mostly with respect to resizing automatically: xnomad, a keyboard based open-source tiling window manager Slate, based on xnomad Spectacle, keyboard-controlled window moving and resizing TylerWM, like Spectacle SizeUp, same as Spectacle, but costs something Cinch, Windows-like Aero Snap resizing BetterTouchTool, mostly for mouse and trackpad gestures, but has window snapping Optimal Layout, Mizage, Moom, Window Magnet, etc. Can I move the "stoplight" icons from the left to

Show Elements In Div Next To Each Other Code Example

Example: display div next to eachother display : inline-block ;

Android Studio Flutter Sdk Path Windows Code Example

Example 1: flutter sdk path flutter doctor -v Example 2: flutter sdk path where flutter

Can \cref Be Made To Ignore Spaces?

Image
Answer : Normalization with removal of spaces before and after label names and removing of empty entries. The following example uses the comma parser of package kvsetkeys for parsing the label name list of the referencing commands of package cleveref . The internal \@cref with the list in its second argument is redefined for this: \documentclass{article} \usepackage{cleveref} \usepackage{kvsetkeys} \makeatletter \let\org@@cref\@cref \renewcommand*{\@cref}[2]{% \begingroup \toks@={}% \comma@parse{#2}\add@cref@item \edef\process@me{\endgroup \noexpand\org@@cref{#1}{\the\toks@}% }\process@me } \newcommand*{\add@cref@item}[1]{% \expandafter\ifx\expandafter\\\the\toks@\\% \toks@{#1}% \else \toks@\expandafter{\the\toks@,#1}% \fi } \makeatother \begin{document} \noindent We can use \cref{1,2}, and now \cref{1, 2},\\ and even with a leading or trailing comma: \Cref{ , 1 , 2 ,}. \section{Section 1} \label{1} \section{Section

Syntax For Pure Virtual Function Is Code Example

Example 1: pure virtual function in c++ # include <iostream> # include <string> //Pure virtual function or inteface allows us to define a function in a base class that doesn't have an implementation or definition in the base class and force sub classes to implement that function //Pure virtual function is also called an interface in other languages class Entity { public : //virtual std::string GetName() { return "Entity"; }//This is a function that is just virtual .Overriding this function in sub class is optional we can instantiate subcllass without overriding or implementing this function //Below is an example a Pure Virtual Function //It is an unimplemented function ant it forces the sub class to implement it and define it //You will not be able to instantiate sub class without implementing or defining the function in sub class virtual std :: string GetName ( ) = 0 ; //the pure virtual function must have virtual writ

Como Convertir String A Int En Javascript Code Example

Example 1: how to convert string to int js let string = "1" ; let num = parseInt ( string ) ; //num will equal 1 as a int Example 2: string to int javascript var text = '42px' ; var integer = parseInt ( text , 10 ) ; // returns 42

Can I Use The PlantUML Language In LaTeX?

Image
Answer : It is possible to use the PlantUML language direcly inside LaTeX using the plantuml package. Here is a minimal example: \documentclass{scrartcl} \usepackage{plantuml} \begin{document} \begin{plantuml} @startuml Alice -> Bob: Hello Alice <- Bob: Hi! @enduml \end{plantuml} \end{document} For building LaTeX with PlantUML the PLANTUML_JAR environment variable has to be set and Java must be installed. To build this document, run lualatex --shell-escape documentname The result should look like this: A more detailed example can be found here: https://koppor.github.io/plantuml/

Math Module In Python 3 Code Example

Example 1: math pyhon ? Arithmetic : operator | name | example | + Addition x + y - Subtraction x - y * Multiplication x * y / Division x / y % Modulus x % y ** Exponentiation x ** y // Floor division x // y Comparison : Operator | Name | Example | == Equal x == y != Not equal x != y > Greater than x > y < Less than x < y >= Greater than or equal to x >= y <= Less than or equal to x <= y Assignment : Operator | Example | = x = 5 += x += 3 -= x -= 3 *= x *= 3 /= x /= 3 %= x %= 3 //= x //= 3 **= x **= 3 &= x &= 3 |= x |= 3 ^= x ^= 3 >>= x >>= 3 <<= x <<= 3 Example 2: python mathematics // Python mathematical functions include but are not limited to : print ( 10 + 10 ) // Returns 20 ( Addition ) print ( 1

CSS Font-weight Thicker Than 900?

Answer : In CSS 3 there's another way to make the font size bolder: color:#888888; text-shadow: 2px 0 #888888; letter-spacing:2px; font-weight:bold; EDIT: For some sort of weird reason this doesn't look as pretty as it did over an year ago. It only works with text-shadow of 1px (on most common fonts, other thicker fonts might still work with 2px). And with text-shadow of only 1px, there's no need for such a large letter-spacing. color:#888888; text-shadow: 1px 0 #888888; letter-spacing:1px; font-weight:bold; To add to Gogutz answer, you can go even bolder by stacking up the text-shadows in a grid. Comma separate each on the line: .extra-bold { text-shadow: 0px 1px, 1px 0px, 1px 1px; } You can use text-shadow instead of font-weight text-shadow: 0px 1px, 1px 0px, 1px 0px;

Convert Mongoose Docs To Json

Answer : You may also try mongoosejs's lean() : UserModel.find().lean().exec(function (err, users) { return res.end(JSON.stringify(users)); } Late answer but you can also try this when defining your schema. /** * toJSON implementation */ schema.options.toJSON = { transform: function(doc, ret, options) { ret.id = ret._id; delete ret._id; delete ret.__v; return ret; } }; Note that ret is the JSON'ed object, and it's not an instance of the mongoose model. You'll operate on it right on object hashes, without getters/setters. And then: Model .findById(modelId) .exec(function (dbErr, modelDoc){ if(dbErr) return handleErr(dbErr); return res.send(modelDoc.toJSON(), 200); }); Edit: Feb 2015 Because I didn't provide a solution to the missing toJSON (or toObject) method(s) I will explain the difference between my usage example and OP's usage example. OP: UserModel .find({}) // will get all

Converting Between Matrix Subscripts And Linear Indices (like Ind2sub/sub2ind In Matlab)

Answer : This is not something I've used before, but according to this handy dandy Matlab to R cheat sheet, you might try something like this, where m is the number of rows in the matrix, r and c are row and column numbers respectively, and ind the linear index: MATLAB: [r,c] = ind2sub(size(A), ind) R: r = ((ind-1) %% m) + 1 c = floor((ind-1) / m) + 1 MATLAB: ind = sub2ind(size(A), r, c) R: ind = (c-1)*m + r For higher dimension arrays, there is the arrayInd function. > abc <- array(dim=c(10,5,5)) > arrayInd(12,dim(abc)) dim1 dim2 dim3 [1,] 2 2 1 You mostly don't need those functions in R. In Matlab you need those because you can't do e.g. A(i, j) = x where i,j,x are three vectors of row and column indices and x contains the corresponding values. (see also this question) In R you can simply: A[ cbind(i, j) ] <- x

C# Select From List Linbque Code Example

Example 1: c# linq select from object list // this will return the first correct answer, // or throw an exception if there are no correct answers var correct = answers . First ( a => a . Correct ) ; // this will return the first correct answer, // or null if there are no correct answers var correct = answers . FirstOrDefault ( a => a . Correct ) ; // this will return a list containing all answers which are correct, // or an empty list if there are no correct answers var allCorrect = answers . Where ( a => a . Correct ) . ToList ( ) ; Example 2: c# linq list select List < Model > newList = list . Where ( m => m . application == "applicationname" ) . Select ( m => new Model { application = m . application , users = m . users . Where ( u => u . surname == "surname" ) . ToList ( ) } ) . ToList ( ) ;