Posts

Showing posts from August, 2010

How To Find A Bastion Remnant Minecraft Code Example

Example 1: types of bastions minecraft lol no i'm a speedrunner Example 2: types of bastion minecraft hey , are you into modding or something ?

403 Forbidden On Nginx/1.4.6 (Ubuntu) - Laravel

Answer : You need to specify an absolute path for your root directive. Nginx uses the directory set at compile time using the --prefix switch. By default this is /usr/local/nginx . What this means is that your root, which is currently set to root home/laravel-app/ causes nginx to look for files at /usr/local/nginx/home/laravel-app/ which presumably isn't where your files are. If you set your root directive to an absolute path such as /var/www/laravel-app/public/ nginx will find the files. Similarly you'll note that I added /public/ to the path above. This is because Laravel stores it's index.php file there. If you were to just point at /laravel-app/ there's no index file and it'd give you a 403.

Android Studio Setting Background Color Code Example

Example: android studio set background color YourView.setBackgroundColor(Color.argb(255, 255, 255, 255));

Can You Use If/else Conditions In CSS?

Answer : Not in the traditional sense, but you can use classes for this, if you have access to the HTML. Consider this: <p class="normal">Text</p> <p class="active">Text</p> and in your CSS file: p.normal { background-position : 150px 8px; } p.active { background-position : 4px 8px; } That's the CSS way to do it. Then there are CSS preprocessors like Sass. You can use conditionals there, which'd look like this: $type: monster; p { @if $type == ocean { color: blue; } @else if $type == matador { color: red; } @else if $type == monster { color: green; } @else { color: black; } } Disadvantages are, that you're bound to pre-process your stylesheets, and that the condition is evaluated at compile time, not run time. A newer feature of CSS proper are custom properties (a.k.a. CSS variables). They are evaluated at run time (in browsers supporting them). With them you could do somet

Woocommerce Update Cart Ajax Hook Code Example

Example: woocommerce update mini cart ajax add_filter ( 'woocommerce_add_to_cart_fragments' , function ( $fragments ) { ob_start ( ) ; ? > < div class = "cart-contents" > < ? php echo WC ( ) -> cart -> get_cart_contents_count ( ) ; ? > < / div > < ? php $fragments [ 'div.cart-contents' ] = ob_get_clean ( ) ; return $fragments ; } ) ; add_filter ( 'woocommerce_add_to_cart_fragments' , function ( $fragments ) { ob_start ( ) ; ? > < div class = "header-quickcart" > < ? php woocommerce_mini_cart ( ) ; ? > < / div > < ? php $fragments [ 'div.header-quickcart' ] = ob_get_clean ( ) ; return $fragments ; } ) ;

Assert A Function/method Was Not Called Using Mock

Answer : This should work for your case; assert not my_var.called, 'method should not have been called' Sample; >>> mock=Mock() >>> mock.a() <Mock name='mock.a()' id='4349129872'> >>> assert not mock.b.called, 'b was called and should not have been' >>> assert not mock.a.called, 'a was called and should not have been' Traceback (most recent call last): File "<stdin>", line 1, in <module> AssertionError: a was called and should not have been Though an old question, I would like to add that currently mock library (backport of unittest.mock) supports assert_not_called method. Just upgrade yours; pip install mock --upgrade You can check the called attribute, but if your assertion fails, the next thing you'll want to know is something about the unexpected call, so you may as well arrange for that information to be displayed from the start. Using unittest , you can

Android - Programmatically Change The State Of A Switch Without Triggering OnCheckChanged Listener

Answer : Set the listener to null before calling setCheck() function, and enable it after that, such as the following: switch.setOnCheckedChangeListener (null); switch.setChecked(true); switch.setOnCheckedChangeListener (this); Reference : Change Checkbox value without triggering onCheckChanged Well, just before doing things in code with the switch you could just unregister the Listener, then do whatever you need to, and again register the listener. Every CompoundButton (two states button - on/off) has a pressed state which is true only when a user is pressing the view . Just add a check in your listener before starting the actual logic: if(compoundButton.isPressed()) { // continue with your listener } That way, changing the checked value programmatically won't trigger the unwanted code. From @krisDrOid answer.

Js Cast Int 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: Javascript string to int var myInt = parseInt ( "10.256" ) ; //10 var myFloat = parseFloat ( "10.256" ) ; //10.256 Example 3: string to number javascript // Method - 1 ### parseInt() ### var text = "42px" ; var integer = parseInt ( text , 10 ) ; // returns 42 // Method - 2 ### parseFloat() ### var text = "3.14someRandomStuff" ; var pointNum = parseFloat ( text ) ; // returns 3.14 // Method - 3 ### Number() ### Number ( "123" ) ; // returns 123 Number ( "12.3" ) ; // returns 12.3 Number ( "3.14someRandomStuff" ) ; // returns NaN Number ( "42px" ) ; // returns NaN Example 4: how to change a string to number in javascript let theInt = parseInt ( "5.90123" ) ; //5 let theFloat = parseFloat ( "5.90123" ) ;

Attributeerror Module 'tensorflow' Has No Attribute 'placeholder' Tensorflow 2.0 Joblib Code Example

Example: AttributeError: module 'tensorflow' has no attribute 'placeholder' #replace import tensorflow as tf by following import tensorflow.compat.v1 as tf tf.disable_v2_behavior()

All GIT Patches I Create Throw Fatal: Unrecognized Input

Answer : There is format problem in patch file. To fixthe path file: Open your patch file in notepad++ then enter these two menus: Encoding/Convert to UTF-8 Edit/EOL conversion/Unix (LF) Run: git apply --reject --whitespace=fix your_patch.patch Updated You might have a file which was not encoded to UTF-8. To fix that on *nix systems (MacOS, Linux etc.) iconv -f ascii -t utf-8 fix.patch -o fix_utf8.patch For windows you can try: Get-Content .\fix.patch | Set-Content -Encoding utf8 fix_utf8.patch If your file may already have color codes in it you can try: git apply --reject --whitespace myfile.patch Passing in color param seems to fix the problem. git diff HEAD --color=never > fix.patch And now check returns no error message. git apply fix.patch --check Changing my .gitconfig file from [color] ui = always change to always [color] ui = auto Fixed my problem so I do not have to pass color option when diffing to patch file. UPDATE:

Bootstrap Validator Example

Example 1: form validation javascript bootstrap <script > // Example starter JavaScript for disabling form submissions if there are invalid fields ( function ( ) { 'use strict' ; window .addEventListener ( 'load' , function ( ) { // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document. getElementsByClassName ( 'needs-validation' ) ; // Loop over them and prevent submission var validation = Array .prototype .filter .call ( forms , function ( form ) { form .addEventListener ( 'submit' , function ( event ) { if ( form .checkValidity ( ) === false ) { event. preventDefault ( ) ; event. stopPropagation ( ) ; } form.classList. add ( 'was-validated' ) ; } , fa

999 Dollars In Euro Code Example

Example: dollars in euros Stonks in european

1hr 20 Minutes Timer Code Example

Example: 20 minute timer for good eyesight every 20 minutes look out the window at something 20 feet away for 20 seconds

Add Header To Pandas Dataframe Code Example

Example 1: how to add column headers in pandas #suppose team is a df that has unnamed columns (0,1...) team . columns = [ 'Name' , 'Code' , 'Age' , 'Weight' ] Example 2: how to add headings to data in pandas Cov = pd . read_csv ( "path/to/file.txt" , sep = '\t' ) Frame = pd . DataFrame ( Cov . values , columns = [ "Sequence" , "Start" , "End" , "Coverage" ] ) Frame . to_csv ( "path/to/file.txt" , sep = '\t' ) Example 3: how to create new header of a dataframe in python pythonCopy # python 3.x import pandas as pd import numpy as np df = pd . DataFrame ( data = np . random . randint ( 0 , 10 , ( 6 , 4 ) ) ) df . columns = [ "a" , "b" , "c" , "d" ] print ( df ) Example 4: pandas heading pd . read_csv ( "directory" , heading = None )