Posts

Filter Sqlalchemy Query Return Code Example

Example: sqlalchemy filter or from sqlalchemy import or_ filter ( or_ ( User.name == 'ed' , User.name == 'wendy' ))

Color Ids Minecraft Code Example

Example: minecraft color codes Color Chat Code MOTD Code Decimal Hexadecimal Dark Red § 4 \u00A74 11141120 AA0000 Red §c \u00A7c 16733525 FF5555 Gold § 6 \u00A76 16755200 FFAA00 Yellow §e \u00A7e 16777045 FFFF55 Dark Green § 2 \u00A72 43520 00 AA00 Green §a \u00A7a 5635925 55 FF55 Aqua §b \u00A7b 5636095 55 FFFF Dark Aqua § 3 \u00A73 43690 00 AAAA Dark Blue § 1 \u00A71 170 0000 AA Blue § 9 \u00A79 5592575 5555 FF Light Purple§d \u00A7d 16733695 FF55FF Dark Purple § 5 \u00A75 11141290 AA00AA White §f \u00A7f 16777215 FFFFFF Gray § 7 \u00A77 11184810 AAAAAA Dark Gray § 8 \u00A78 5592405 555555 Black § 0 \u00A70 0 000000

Can An Idempotent Matrix Be Complex?

Answer : A assume that by "can A A A be complex", you mean "can A A A have any non-real entries". Well, it can! For instance, take A = \pmatrix{1&i\\0&0} In general: for any complex column-vector x x x , A = x x ∗ x ∗ x A = \frac{xx^*}{x^*x} A = x ∗ x x x ∗ ​ (where ∗ * ∗ denotes the conjugate-transpose) is such a matrix. A projection to a subspace is idempotent. Therefore A A A has no reason to be real. For example, take a subspace S S S of C 2 \mathbb{C}^2 C 2 and A A A be the matrix of the projection on to S S S with respect to the standard basis. Any matrix A = \pmatrix{a&b\\c&1-a} will be idempotent provided that a 2 + b c = a a^2+bc=a a 2 + b c = a

Catching Errors In JavaScript Promises With A First Level Try ... Catch

Answer : You cannot use try-catch statements to handle exceptions thrown asynchronously, as the function has "returned" before any exception is thrown. You should instead use the promise.then and promise.catch methods, which represent the asynchronous equivalent of the try-catch statement. (Or use the async/await syntax noted in @Edo's answer.) What you need to do is to return the promise, then chain another .catch to it: function promise() { var promise = new Promise(function(resolve, reject) { throw('Oh no!'); }); return promise.catch(function(error) { throw(error); }); } promise().catch(function(error) { console.log('Caught!', error); }); Promises are chainable, so if a promise rethrows an error, it will be delegated down to the next .catch . By the way, you don't need to use parentheses around throw statements ( throw a is the same as throw(a) ). With the new async/await syntax you can achieve this...

Change Font Size Without Messing With Tkinter Button Size

Answer : Typically, when you give a button a width, that width is measured in characters (ie: width=1 means the width of one average sized character). However, if the button has an image then the width specifies a size in pixels.   A button can contain both an image and text, so one strategy is to put a 1x1 pixel as an image so that you can specify the button size in pixels. When you do that and you change the font size, the button will not grow since it was given an absolute size. Here is an example that illustrates the technique. Run the code, then click on "bigger" or "smaller" to see that the text changes size but the button does not. import Tkinter as tk import tkFont def bigger(): size = font.cget("size") font.configure(size=size+2) def smaller(): size = font.cget("size") size = max(2, size-2) font.configure(size=size) root = tk.Tk() font = tkFont.Font(family="Helvetica", size=12) toolbar = tk.Fra...

Arduino Substring Code Example

Example: arduino substring myString.substring(from, to)

Add Two Numbers In X86 Assembly Code Example

Example: add two numbers in assembly language data segment a db 09h b db 02h c dw ? data ends code segment assume cs:code,ds:data start: mov ax,data mov ds,ax mov al,a mov bl,b add al,bl mov c,ax int 3 code ends end start

Check If The File Exists In Bucket Ruby Code Example

Example: ruby check if a file exists # file? will only return true for files File.file?(filename) # Will also return true for directories File.exist?(filename)

Color Hex Code Generator Code Example

Example 1: rgb purple color ( 128 , 0 , 128 ) Hex # 800080 Example 2: html color codes < ! -- Check these best user friendly html color codes -- > # 1 ca69d #e31ce0 #c13e72 # 99 b34d # 3 affb9 # 6 c7093 #b35ba0 # 1 b1452

Can't Play This Video. Android VideoView Mp4 Recorded By Android Device

Answer : Please refer below code snippet...problem was with the path declaration.. String uriPath = "android.resource://"+getPackageName()+"/"+R.raw.aha_hands_only_cpr_english; Uri uri = Uri.parse(uriPath); mVideoView.setVideoURI(uri); Thats it... I tried everything mentioned before but it turns out that internet permission is needed to play a mp4 file. <uses-permission android:name="android.permission.INTERNET" />

Baguettebox Doesn't Show Next/previous Stepper

Answer : in your script add this {buttons: true} in baguetteBox try this baguetteBox.run('.labrador',{ buttons: true }); baguetteBox.run('.labrador',{ buttons: true }); <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> <link href="https://feimosi.github.io/baguetteBox.js/css/baguetteBox.css" rel="stylesheet"/> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/baguettebox.js/1.10.0/baguetteBox.min.js"></script> <div class="labrador"> <a href="https:...

Bootstrap Button Class With Icon Code Example

Example 1: bootstrap 4 button with icon <!-- Add icon library --> < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css " > < button class = " btn " > < i class = " fa fa-home " > </ i > </ button > Example 2: how to icon button in html <! DOCTYPE html > < html > < head > < meta name = " viewport " content = " width=device-width, initial-scale=1 " > <!-- Add icon library --> < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css " > < style > .btn { background-color : DodgerBlue ; border : none ; color : white ; padding : 12 px 16 px ; font-size : 16 px ; cursor : pointer ; } /* Darker background on mouse-over */ .btn :hover { background-color...

Array Without First Element Code Example

Example 1: javascript remove first element from array var arr = [ 1 , 2 , 3 , 4 ] ; var theRemovedElement = arr . shift ( ) ; // theRemovedElement == 1 console . log ( arr ) ; // [2, 3, 4] Example 2: javascript remove first element from array let numbers = [ "I'm Not A Number!" , 1 , 2 , 3 ] ; numbers . shift ( ) ; Example 3: es6 remove first element of array var myarray = [ "item 1" , "item 2" , "item 3" , "item 4" ] ; //removes the first element of the array, and returns that element. alert ( myarray . shift ( ) ) ; //alerts "item 1" //removes the last element of the array, and returns that element. alert ( myarray . pop ( ) ) ; //alerts "item 4"

Bootstrap Class Float Right Code Example

Example 1: float right bootstrap < div class = " float-left " > Float left on all viewport sizes </ div > < br > < div class = " float-right " > Float right on all viewport sizes </ div > < br > < div class = " float-none " > Don't float on all viewport sizes </ div > Example 2: bootstrap align right To aligning div in bootstrap you can use bootstrap classes like 1. float-left 2. float-right 3. float-none < div class = " float-left " > Float left on all viewport sizes </ div > < br > < div class = " float-right " > Float right on all viewport sizes </ div > < br > < div class = " float-none " > Don't float on all viewport sizes </ div > Example 3: bootstrap 5 float right .float-start .float-end .float-none .float-sm-start .float-sm-end .float-sm-none .float-md-start .float-md-end .float-md-none .float-lg-s...

Chart.js Number Format

Answer : There is no built-in functionality for number formatting in Javascript. I found the easiest solution to be the addCommas function on this page. Then you just have to modify your tooltipTemplate parameter line from your Chart.defaults.global to something like this: tooltipTemplate: "<%= addCommas(value) %>" Charts.js will take care of the rest. Here's the addCommas function: function addCommas(nStr) { nStr += ''; x = nStr.split('.'); x1 = x[0]; x2 = x.length > 1 ? '.' + x[1] : ''; var rgx = /(\d+)(\d{3})/; while (rgx.test(x1)) { x1 = x1.replace(rgx, '$1' + ',' + '$2'); } return x1 + x2; } Put tooltips in 'option' like this: options: { tooltips: { callbacks: { label: function(tooltipItem, data) { return tooltipItem.yLabel.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,'); } } ...

Check If Two Arrays Have Same Elements Javascript Code Example

Example 1: check if 2 arrays are equal javascript const a = [1, 2, 3]; const b = [4, 5, 6]; const c = [1, 2, 3]; function arrayEquals(a, b) { return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((val, index) => val === b[index]); } arrayEquals(a, b); // false arrayEquals(a, c); // true Example 2: check if 2 arrays are equal javascript var arraysMatch = function (arr1, arr2) { // Check if the arrays are the same length if (arr1.length !== arr2.length) return false; // Check if all items exist and are in the same order for (var i = 0; i < arr1.length; i++) { if (arr1[i] !== arr2[i]) return false; } // Otherwise, return true return true; }; Example 3: javascript Compare two arrays regardless of order const isEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b); // Examples isEqual([1, 2, 3], [1, 2, 3]); // true isEqual([1, 2, 3], [1, '2', 3]); // false