Posts

Showing posts from April, 2009

Bootstrap Installer Code Example

Example 1: install bootstrap npm install bootstrap //OR npm install bootstrap@latest Example 2: bootstrap setup <! DOCTYPE html > < html lang = " en " > < head > < meta charset = " utf-8 " > < meta http-equiv = " X-UA-Compatible " content = " IE=edge " > < meta name = " viewport " content = " width=device-width, initial-scale=1 " > <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> < title > Bootstrap 101 Template </ title > <!-- Bootstrap --> < link href = " css/bootstrap.min.css " rel = " stylesheet " > <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!-- WARNING: Respond.js doesn't work if you view the page via file:// --> <!--[if lt IE 9]> &

Add Attribute Js Code Example

Example 1: javascript change attribute var element = document.getElementById("elemId"); element.setAttribute("attributeName", "value"); Example 2: setAttribute() element.setAttribute(name, value); element.setAttribute("style", "background-color: red;"); Example 3: set attribute javascript Element.setAttribute(name, value); Example 4: put new attribute on html tag using javascript // Here's what you do for the style attribute span.setAttribute("style", "width:110%;float:center;left-margin:-10px;top-margin:-10;"); Example 5: set property dom javascrpt document.getElementsByTagName("H1")[0].setAttribute("class", "democlass"); Example 6: js setattribute const link = document.querySelector('a'); console.log(link.getAttribute('href')); link.setAttribute('href', 'https://yandex.ru'); link.innerText = 'The Next Link'; const mssg = docum

Check If String Contains Exact Substring Php Code Example

Example 1: php check if string contains word $myString = 'Hello Bob how are you?' ; if ( strpos ( $myString , 'Bob' ) !== false ) { echo "My string contains Bob" ; } Example 2: php contains substring <?php $mystring = 'abc' ; $findme = 'a' ; $pos = strpos ( $mystring , $findme ) ; // Note our use of ===. Simply == would not work as expected // because the position of 'a' was the 0th (first) character. if ( $pos === false ) { echo "The string ' $findme ' was not found in the string ' $mystring '" ; } else { echo "The string ' $findme ' was found in the string ' $mystring '" ; echo " and exists at position $pos " ; } ?>

Angular-ui-router: Ui-sref-active And Nested States

Answer : Instead of this- <li ui-sref-active="active"> <a ui-sref="posts.details">Posts</a> </li> You can do this- <li ng-class="{active: $state.includes('posts')}"> <a ui-sref="posts.details">Posts</a> </li> Currently it doesn't work. There is a discussion going on here (https://github.com/angular-ui/ui-router/pull/927) And, it will be added soon. UPDATE: For this to work, $state should be available in view. angular.module('xyz').controller('AbcController', ['$scope', '$state', function($scope, $state) { $scope.$state = $state; }]); More Info UPDATE [2]: As of version 0.2.11 , it works out of the box. Please check the related issue: https://github.com/angular-ui/ui-router/issues/818 Here's an option for when you are nesting multiple states that are not hierarchically related and you don't have a controller ava

Calloc Vs Malloc Vs Realloc Code Example

Example: difference between malloc and calloc and realloc if ( ! ( int * ptr = malloc ( sizeof ( int ) * NUM_ELEM ) ) ) { // ERROR CONDITION HERE}

Can I Edit The Text Of Sign In Button On Google?

Image
Answer : Here is the technique that I used: protected void setGooglePlusButtonText(SignInButton signInButton, String buttonText) { // Find the TextView that is inside of the SignInButton and set its text for (int i = 0; i < signInButton.getChildCount(); i++) { View v = signInButton.getChildAt(i); if (v instanceof TextView) { TextView tv = (TextView) v; tv.setText(buttonText); return; } } } Here is the easiest way that I used: TextView textView = (TextView) signInButton.getChildAt(0); textView.setText("your_text_xyz"); Problem: Other answers have mentioned a workaround. The underlying implementation of the button may change any time which would cause the code to break. I felt uncomfortable trying to use the hacks. For a clean solution, you would think that setting android:text on the com.google.android.gms.common.SignInButton in your layout file would do the trick. However it turns

Best Way Of Getting Base URL Inside KnockoutJS .html File

Answer : I managed to do this in app/design/frontend/<Vendor>/<Theme>/Magento_OfflinePayments/web/template/<Filename>.html , but the solution should work in the Magento_Checkout as well. When you inspect the window variable in the dev-console of your browser, you will see that the checkout and checkoutConfig objects are available on checkout-pages. Here are the relevant parts: checkout.baseUrl checkout.checkoutUrl checkout.customerLoginUrl checkout.removeItemUrl checkout.shoppingCartUrl checkout.updateItemQtyUrl checkoutConfig.cartUrl checkoutConfig.checkoutUrl checkoutConfig.defaultSuccessPageUrl checkoutConfig.forgotPasswordUrl checkoutConfig.pageNotFoundUrl checkoutConfig.registerUrl checkoutConfig.staticBaseUrl In my case, I wanted to display an image; here's the code: <img data-bind="attr: {'src':checkoutConfig.staticBaseUrl + 'frontend/<Vendor>/<Theme>/<Locale>/images/logo.png'}" alt="&quo

Python String Reverse Code Example

Example 1: python reverse string 'String' [ :: - 1 ] # -> 'gnirtS' Example 2: how to reverse a string in python # in order to make a string reversed in python # you have to use the slicing as following string = "racecar" print ( string [ :: - 1 ] ) Example 3: reverse string in python 'hello world' [ :: - 1 ] 'dlrow olleh' Example 4: how to reverse a string in python 'your sting' [ :: - 1 ] Example 5: python string reverse 'hello world' [ :: - 1 ] # 'dlrow olleh' Example 6: reverse string method python # linear def reverse ( s ) : str = "" for i in s : str = i + str return str # splicing 'hello world' [ :: - 1 ] # reversed & join def reverse ( string ) : string = "" . join ( reversed ( string ) ) return string

Change User-agent For Selenium Web-driver

Answer : There is no way in Selenium to read the request or response headers. You could do it by instructing your browser to connect through a proxy that records this kind of information. Setting the User Agent in Firefox The usual way to change the user agent for Firefox is to set the variable "general.useragent.override" in your Firefox profile. Note that this is independent from Selenium. You can direct Selenium to use a profile different from the default one, like this: from selenium import webdriver profile = webdriver.FirefoxProfile() profile.set_preference("general.useragent.override", "whatever you want") driver = webdriver.Firefox(profile) Setting the User Agent in Chrome With Chrome, what you want to do is use the user-agent command line option. Again, this is not a Selenium thing. You can invoke Chrome at the command line with chrome --user-agent=foo to set the agent to the value foo . With Selenium you set it like this: fr

CString.Compare("") C++ Code Example

Example: strcmp c++ # include <stdio.h> # include <string.h> int main ( ) { char char1 [ ] = "coucou" ; char char2 [ ] = "coucou" ; if ( strcmp ( char1 , char2 ) == 0 ) printf ( "Strings are the same" ) ; else prinf ( "Strings are differentes" ) ; return 0 ; }

Cannot Execute RUN Mkdir In A Dockerfile

Answer : The problem is that /var/www doesn't exist either, and mkdir isn't recursive by default -- it expects the immediate parent directory to exist. Use: mkdir -p /var/www/app ...or install a package that creates a /var/www prior to reaching this point in your Dockerfile. When creating subdirectories hanging off from a non-existing parent directory(s) you must pass the -p flag to mkdir ... Please update your Dockerfile with RUN mkdir -p ... I tested this and it's correct. You can also simply use WORKDIR /var/www/app It will automatically create the folders if they don't exist. Then switch back to the directory you need to be in.

A C++ Library For IIR Filter

Answer : There's octave, an open-source MatLab clone, you could use its implementation (but it will likely require you use use its special matrix type). Searching for "C++ IIR filter" finds a bunch of other projects, such as: Signal Processing using C++ dspfilterscpp There are also a variety of books on the subject, for example: C++ algorithms for digital signal processing In general, implementation of an IIR filter is very easy. Numerical robustness and efficient use of your computer hardware are more difficult, but they require knowledge of your specific application (e.g. resampling, etc) so aren't really suited for library implementations. You could also try GNURadio (gnuradio.org), which contains all sorts of components for software defined radio (including iir filters). It was originally all C++, now it is a bunch of modules written in C++ with python bindings, but you should still be able to use the C++ code directly.

AWS RDS Connection Limits

Answer : Solution 1: AWS RDS max_connections limit variable is based on Instance type, so you can upgrade your RDS or make more replica. The RDS types with max_connections limit: t2.micro 66 t2.small 150 m3.medium 296 t2.medium 312 m3.large 609 t2.large 648 m4.large 648 m3.xlarge 1237 r3.large 1258 m4.xlarge 1320 m2.xlarge 1412 m3.2xlarge 2492 r3.xlarge 2540 Referring by max_connections at AWS RDS MySQL Instance Sizes in 2015 Update 2017-07 The current RDS MySQL max_connections setting is default by {DBInstanceClassMemory/12582880} , if you use t2.micro with 512MB RAM, the max_connections could be (512*1024*1024)/12582880 ~= 40, and so on. Each Web server could have many connections to RDS, which depends on your SQL requests from Web server. Solution 2: You can change the max_connections value by either updating the default parameter policy or create a new one - I'd suggest going with the latter. Go to RDS Parameter Groups Create a new

Brave Browser Wiki Code Example

Example 1: brave browser sudo apt install apt-transport-https curl gnupg curl -s https://brave-browser-apt-release.s3.brave.com/brave-core.asc | sudo apt-key --keyring /etc/apt/trusted.gpg.d/brave-browser-release.gpg add - echo "deb [arch=amd64] https://brave-browser-apt-release.s3.brave.com/ stable main" | sudo tee /etc/apt/sources.list.d/brave-browser-release.list sudo apt update sudo apt install brave-browser Example 2: brave web browser sudo pacman -S brave sudo pacman -S brave-beta

AWS EMR Spark Python Logging

Answer : I've found that EMR's logging for particular steps almost never winds up in the controller or stderr logs that get pulled alongside the step in the AWS console. Usually I find what I want in the job's container logs (and usually it's in stdout). These are typically at a path like s3://mybucket/logs/emr/spark/j-XXXXXX/containers/application‌​_XXXXXXXXX/container‌​_XXXXXXX/... . You might need to poke around within the various application_... and container_... directories within containers . That last container directory should have a stdout.log and stderr.log .

Check Python Version Mac Code Example

Example 1: check python version mac # To check python 3 version type in the terimnal: python3 --version # To check python 2 version just type: python --version # If any errors come up then that means python isn't installed on your # system. Example 2: how to check python version # To check your Python version in the command line use: python --version # To check your Python verson inside a script use: import sys print(sys.version) Example 3: terminal python version # in python $ python --version # in python3 $ python3 --version Example 4: how to check python version python --version Example 5: how to check if python is installed on mac Hi this is way simple.. Open terminal on your mac Then type python - - version If its give an error that means there is no python installed if it gives you the version number then python is installed.. Any by default python comes installed but the answer was just to make sure you do understand.. Good luck with learning python.. If

Check / Uncheck Checkbox Using Jquery?

Answer : For jQuery 1.6+ : .attr() is deprecated for properties; use the new .prop() function instead as: $('#myCheckbox').prop('checked', true); // Checks it $('#myCheckbox').prop('checked', false); // Unchecks it For jQuery < 1.6: To check/uncheck a checkbox, use the attribute checked and alter that. With jQuery you can do: $('#myCheckbox').attr('checked', true); // Checks it $('#myCheckbox').attr('checked', false); // Unchecks it Cause you know, in HTML, it would look something like: <input type="checkbox" id="myCheckbox" checked="checked" /> <!-- Checked --> <input type="checkbox" id="myCheckbox" /> <!-- Unchecked --> However, you cannot trust the .attr() method to get the value of the checkbox (if you need to). You will have to rely in the .prop() method. You can use prop() for this, as Before jQuery 1.6 , the .attr() me

Check If A Variable Is Null In Plsql

Answer : if var is NULL then var :=5; end if; Use: IF Var IS NULL THEN var := 5; END IF; Oracle 9i+: var = COALESCE(Var, 5) Other alternatives: var = NVL(var, 5) Reference: COALESCE NVL NVL2 In PL/SQL you can't use operators such as '=' or '<>' to test for NULL because all comparisons to NULL return NULL . To compare something against NULL you need to use the special operators IS NULL or IS NOT NULL which are there for precisely this purpose. Thus, instead of writing IF var = NULL THEN... you should write IF VAR IS NULL THEN... In the case you've given you also have the option of using the NVL built-in function. NVL takes two arguments, the first being a variable and the second being a value (constant or computed). NVL looks at its first argument and, if it finds that the first argument is NULL , returns the second argument. If the first argument to NVL is not NULL , the first argument is returned. So you c

28 Inch To Cm Code Example

Example 1: inch to cm 1 inch = 2.54 cm Example 2: cm to inch 1 cm = 0.3937 inch

Blender Split Mesh Into Separate Objects Code Example

Example: separate object blender Select the faces to seperate in edit mode press 'P' and choose "By selection"

Brew Install Mysql On MacOS

Answer : I think one can end up in this position with older versions of mysql already installed. I had the same problem and none of the above solutions worked for me. I fixed it thus: Used brew's remove & cleanup commands, unloaded the launchctl script, then deleted the mysql directory in /usr/local/var , deleted my existing /etc/my.cnf (leave that one up to you, should it apply) and launchctl plist Updated the string for the plist. Note also your alternate security script directory will be based on which version of MySQL you are installing. Step-by-step: brew remove mysql brew cleanup launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist rm ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist sudo rm -rf /usr/local/var/mysql I then started from scratch: installed mysql with brew install mysql ran the commands brew suggested: (see note: below) unset TMPDIR mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)&qu

Activate Windows 10 Batch Code Example

Example 1: activate win 10 batch file @echo off title Activate Windows 10 ALL versions for FREE! WireDroid.com&cls&echo ============================================================================&echo #Project: Activating Microsoft software products for FREE without software(WireDroid.com)&echo ============================================================================&echo.&echo #Supported products:&echo - Windows 10 Home&echo - Windows 10 Home N&echo - Windows 10 Home Single Language&echo - Windows 10 Home Country Specific&echo - Windows 10 Professional&echo - Windows 10 Professional N&echo - Windows 10 Education N&echo - Windows 10 Education N&echo - Windows 10 Enterprise&echo - Windows 10 Enterprise N&echo - Windows 10 Enterprise LTSB&echo - Windows 10 Enterprise LTSB N&echo.&echo.&echo ============================================================================&echo Activating your Window

Collapsing Sidebar With Bootstrap

Answer : Bootstrap 3 Yes, it's possible. This "off-canvas" example should help to get you started. https://codeply.com/p/esYgHWB2zJ Basically you need to wrap the layout in an outer div, and use media queries to toggle the layout on smaller screens. /* collapsed sidebar styles */ @media screen and (max-width: 767px) { .row-offcanvas { position: relative; -webkit-transition: all 0.25s ease-out; -moz-transition: all 0.25s ease-out; transition: all 0.25s ease-out; } .row-offcanvas-right .sidebar-offcanvas { right: -41.6%; } .row-offcanvas-left .sidebar-offcanvas { left: -41.6%; } .row-offcanvas-right.active { right: 41.6%; } .row-offcanvas-left.active { left: 41.6%; } .sidebar-offcanvas { position: absolute; top: 0; width: 41.6%; } #sidebar { padding-top:0; } } Also, there are several more Bootstrap sidebar examples here Bootstrap 4 Create a responsive navbar sidebar "dra