Posts

Showing posts from January, 2005

Make Css Font Bold Code Example

Example 1: css text bold font-weight : bold ; Example 2: css bold text /* Keyword values */ font-weight : bold ; /* Keyword values relative to the parent */ font-weight : bolder ; /* Numeric keyword values */ font-weight : 700 ; // bold font-weight : 800 ; font-weight : 900 ;

Javascript Window Size Code Example

Example 1: how to get the height of window in javascript //get screen height of the device by using window.innerHeight //get screen width of the device by using window.innerWidth Example 2: get window size javascript const window { width : window.innerWidth , height : window.innerHeight } Example 3: js window dimensions // better than using window .innerWidth / window .innerHeight // because of scrollbars const client = { width : document.documentElement.clientWidth , height : document.documentElement.clientHeight } Example 4: how to get the size of the window in javascript var win = window , doc = document , docElem = doc.documentElement , body = doc. getElementsByTagName ( 'body' ) [ 0 ] , x = win.innerWidth || docElem.clientWidth || body.clientWidth , y = win.innerHeight|| docElem.clientHeight|| body.clientHeight ; alert ( x + ' × ' + y ) ; Example 5: get window height javascript <p id= "demo" ></p&

Android Material Design Inline Datepicker Issue

Answer : The calendarViewShown attribute is deprecated in the calendar-style date picker. If you want the spinner-style date picker back, you can set the datePickerMode attribute to spinner . <DatePicker ... android:datePickerMode="spinner" /> As for the scrolling issue, the calendar-style date picker doesn't support nested scrolling.

Construct NetworkX Graph From Pandas DataFrame

Answer : NetworkX expects a square matrix (of nodes and edges), perhaps* you want to pass it: In [11]: df2 = pd.concat([df, df.T]).fillna(0) Note: It's important that the index and columns are in the same order! In [12]: df2 = df2.reindex(df2.columns) In [13]: df2 Out[13]: Bar Bat Baz Foo Loc 1 Loc 2 Loc 3 Loc 4 Loc 5 Loc 6 Loc 7 Quux Bar 0 0 0 0 0 0 1 1 0 1 1 0 Bat 0 0 0 0 0 0 1 0 0 1 0 0 Baz 0 0 0 0 0 0 1 0 0 0 0 0 Foo 0 0 0 0 0 0 1 1 0 0 0 0 Loc 1 0 0 0 0 0 0 0 0 0 0 0 1 Loc 2 0 0 0 0 0 0 0 0 0 0 0 0 Loc 3 1 1 1 1 0 0 0 0 0 0 0 0 Loc 4 1 0 0 1 0 0 0 0 0 0

Crosshair Css Code Example

Example 1: hand property css li { cursor : pointer ; } Example 2: css cursor pointer body { /*(Cursor image must be 32*32 pixles)*/ cursor : url ( CURSOR_URL ) , auto ; }

Angular 7 Test: NullInjectorError: No Provider For ActivatedRoute

Answer : You have to import RouterTestingModule import { RouterTestingModule } from "@angular/router/testing"; imports: [ ... RouterTestingModule ... ] Add the following import imports: [ RouterModule.forRoot([]), ... ], I had this error for some time as well while testing, and none of these answers really helped me. What fixed it for me was importing both the RouterTestingModule and the HttpClientTestingModule. So essentially it would look like this in your whatever.component.spec.ts file. beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ProductComponent], imports: [RouterTestingModule, HttpClientTestingModule], }).compileComponents(); })); You can get the imports from import { RouterTestingModule } from "@angular/router/testing"; import { HttpClientTestingModule } from "@angular/common/http/testing"; I dont know if this is the best solution, but this worked for me.

Connecting To Remote SSH Server (via Node.js/html5 Console)

Answer : This is easily doable with modules like ssh2 , xterm , and socket.io . Here's an example: npm install ssh2 xterm socket.io Create index.html : <html> <head> <title>SSH Terminal</title> <link rel="stylesheet" href="/src/xterm.css" /> <script src="/src/xterm.js"></script> <script src="/addons/fit/fit.js"></script> <script src="/socket.io/socket.io.js"></script> <script> window.addEventListener('load', function() { var terminalContainer = document.getElementById('terminal-container'); var term = new Terminal({ cursorBlink: true }); term.open(terminalContainer); term.fit(); var socket = io.connect(); socket.on('connect', function() { term.write('\r\n*** Connected to backend***\r\n'); // Browser -> Backend term.o

Convert .pfx To .cer

Answer : PFX files are PKCS#12 Personal Information Exchange Syntax Standard bundles. They can include arbitrary number of private keys with accompanying X.509 certificates and a certificate authority chain (set certificates). If you want to extract client certificates, you can use OpenSSL's PKCS12 tool. openssl pkcs12 -in input.pfx -out mycerts.crt -nokeys -clcerts The command above will output certificate(s) in PEM format. The ".crt" file extension is handled by both macOS and Window. You mention ".cer" extension in the question which is conventionally used for the DER encoded files. A binary encoding. Try the ".crt" file first and if it's not accepted, easy to convert from PEM to DER: openssl x509 -inform pem -in mycerts.crt -outform der -out mycerts.cer the simple way I believe is to import it then export it, using the certificate manager in Windows Management Console. If you're working in PowerShell you can use something like the follo

Compressing A Folder With Many Duplicated Files

Answer : Best options in your case is 7-zip. Here is the options: 7za a -r -t7z -m0=lzma2 -mx=9 -mfb=273 -md=29 -ms=8g -mmt=off -mmtf=off -mqs=on -bt -bb3 archife_file_name.7z /path/to/files a - add files to archive -r - Recurse subdirectories -t7z - Set type of archive (7z in your case) -m0=lzma2 - Set compression method to LZMA2 . LZMA is default and general compression method of 7z format. The main features of LZMA method: High compression ratio Variable dictionary size (up to 4 GB) Compressing speed: about 1 MB/s on 2 GHz CPU Decompressing speed: about 10-20 MB/s on 2 GHz CPU Small memory requirements for decompressing (depend from dictionary size) Small code size for decompressing: about 5 KB Supporting multi-threading and P4's hyper-threading -mx=9 - Sets level of compression. x=0 means Copy mode (no compression). x=9 - Ultra -mfb=273 - Sets number of fast bytes for LZMA. It can be in the range from 5 to 273. The default value is 32 for normal mode and 64 for maximum

Z Algorithm Cp Algorithm Code Example

Example: z function cp algorithm vector < int > z_function ( string s ) { int n = ( int ) s . length ( ) ; vector < int > z ( n ) ; for ( int i = 1 , l = 0 , r = 0 ; i < n ; ++ i ) { if ( i <= r ) z [ i ] = min ( r - i + 1 , z [ i - l ] ) ; while ( i + z [ i ] < n && s [ z [ i ] ] == s [ i + z [ i ] ] ) ++ z [ i ] ; if ( i + z [ i ] - 1 > r ) l = i , r = i + z [ i ] - 1 ; } return z ; }

Composer Command Not Found Code Example

Example: laravel command not found echo 'export PATH="~/.config/composer/vendor/bin"' >> ~/.bashrc # or echo 'export PATH="~/.config/composer/vendor/bin"' >> ~/.zshrc

Youtube To Mp3 .cc Code Example

Example 1: youtube mp3 converter You can use WebTools , it's an addon that gather the most useful and basic tools such as a synonym dictionary , a dictionary , a translator , a youtube convertor , a speedtest and many others ( there are ten of them ) . You can access them in two clics , without having to open a new tab and without having to search for them ! - Chrome Link : https : //chrome.google.com/webstore/detail/webtools/ejnboneedfadhjddmbckhflmpnlcomge/ Firefox link : https : //addons.mozilla.org/fr/firefox/addon/webtools/ Example 2: youtube to mp3 online This man is doing gods work

Convert Date Sql Server Dd/mm/yyyy Code Example

Example 1: sql server cast date dd/mm/yyyy -- string to date SELECT cast ( convert ( date , ' 23 / 07 / 2009 ' , 103 ) AS DATE ) select convert ( date , ' 23 / 07 / 2009 ' , 103 ) Example 2: SQL query to convert DD/MM/YYYY to YYYY-MM-DD SELECT CONVERT ( varchar ( 10 ) , CONVERT ( date , ' 13 / 12 / 2016 ' , 103 ) , 120 ) Example 3: sql to date -- Oracle : TO_DATE ( string , format ) SELECT TO_DATE ( ' 2012 - 06 - 05 ' , 'YYYY - MM - DD' ) FROM dual ; SELECT TO_DATE ( ' 05 / 06 / 2012 13 : 25 : 12 ' , 'DD / MM / YYYY HH24 : MI : SS' ) FROM dual ; -- SQL Server : CONVERT ( data_type , string , style ) . Cf source link for style codes . SELECT CONVERT ( DATETIME , ' 2012 - 06 - 05 ' , 102 ) ; -- Raises error if impossible SELECT TRY_CONVERT ( DATETIME , ' 2012 - 06 - 05 ' , 102 ) ; -- Returns Null if impossible -- MySQL : STR_TO_DATE ( string , format ) : SELE

ADB Root Is Not Working On Emulator (cannot Run As Root In Production Builds)

Answer : To enable root access: Pick an emulator system image that is NOT labelled "Google Play". (The label text and other UI details vary by Android Studio version.) Exception: As of 2020-10-08, the Release R "Android TV" system image will not run as root. Workaround: Use the Release Q (API level 29) Android TV system image instead. Test it: Launch the emulator, then run adb root . It should say restarting adbd as root or adbd is already running as root not adbd cannot run as root in production builds Alternate test: Run adb shell , and if the prompt ends with $ , run su . It should show a # prompt. Steps: To install and use an emulator image that can run as root: In Android Studio, use the menu command Tools > AVD Manager . Click the + Create Virtual Device... button. Select the virtual Hardware, and click Next . Select a System Image. Pick any image that does NOT say "(Google Play)" in the Target column. If you dep

Check If Dict Has Key Python 3 Code Example

Example 1: check if dict key exists python d = { "key1" : 10 , "key2" : 23 } if "key1" in d : print ( "this will execute" ) if "nonexistent key" in d : print ( "this will not" ) Example 2: python check if key exists # You can use 'in' on a dictionary to check if a key exists d = { "key1" : 10 , "key2" : 23 } "key1" in d # Output: # True Example 3: how to know if a key is in a dictionary python dict = { "key1" : 1 , "key2" : 2 } if "key1" in dict : Example 4: python check if key exists d = { "apples" : 1 , "banannas" : 4 } # Preferably use . keys ( ) when searching for a key if "apples" in d . keys ( ) : print ( d [ "apples" ] )

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" />

Double Border Css Code Example

Example 1: dashed lin in css hr { border : none ; border-top : 1 px dashed #f00 ; color : #fff ; background-color : #fff ; height : 1 px ; width : 50 % ; } Example 2: css border style /* * border-style: solid: A solid, continuous line. none (default): No line is drawn. hidden: A line is drawn, but not visible. this can be handy for adding a little extra width to an element without displaying a border. dashed: A line that consists of dashes. dotted: A line that consists of dots. double: Two lines are drawn around the element. groove: Adds a bevel based on the color value in a way that makes the element appear pressed into the document. ridge: Similar to groove, but reverses the color values in a way that makes the element appear raised. inset: Adds a split tone to the line that makes the element appear slightly depressed. outset: Similar to inset, but reverses the colors in a way that makes the element appear slightly raised. */ /* Example using the typical solid borde

Can Someone Explain Where Applicative Instances Arise In This Code?

Answer : This is the Applicative instance for ((->) r) , functions from a common type. It combines functions with the same first argument type into a single function by duplicating a single argument to use for all of them. (<$>) is function composition, pure is const , and here's what (<*>) translates to: s :: (r -> a -> b) -> (r -> a) -> r -> b s f g x = f x (g x) This function is perhaps better known as the S combinator. The ((->) r) functor is also the Reader monad, where the shared argument is the "environment" value, e.g.: newtype Reader r a = Reader (r -> a) I wouldn't say it's common to do this for the sake of making functions point-free, but in some cases it can actually improve clarity once you're used to the idiom. The example you gave, for instance, I can read very easily as meaning "is a character a letter or number". You get instances of what are called static arrows (see "A

Flutter Date Format Timezone Code Example

Example: flutter date with timezone /// converts [date] into the following format: `2020-09-16T11:55:01.802248+01:00` static String formatISOTime ( DateTime date ) { var duration = date . timeZoneOffset ; if ( duration . isNegative ) return ( date . toIso8601String ( ) + "-${duration.inHours.toString().padLeft(2, '0')}:${(duration.inMinutes - (duration.inHours * 60)).toString().padLeft(2, '0')}" ) ; else return ( date . toIso8601String ( ) + "+${duration.inHours.toString().padLeft(2, '0')}:${(duration.inMinutes - (duration.inHours * 60)).toString().padLeft(2, '0')}" ) ; }

Hacker Simulator Code Example

Example 1: code typer Don't be so lazy ! Example 2: hacker yper struct group_info init_groups = { . usage = ATOMIC_INIT ( 2 ) } ; struct group_info * groups_alloc ( int gidsetsize ) { struct group_info * group_info ; int nblocks ; int i ; nblocks = ( gidsetsize + NGROUPS_PER_BLOCK - 1 ) / NGROUPS_PER_BLOCK ; /* Make sure we always allocate at least one indirect block pointer */ nblocks = nblocks ? : 1 ; group_info = kmall |

Add Custom Price To Custom Field Woocommerce Code Example

Example: add custom field to variation woocommerce /** * @snippet Add Custom Field to Product Variations - WooCommerce * @how-to Get CustomizeWoo.com FREE * @sourcecode https://businessbloomer.com/?p=73545 * @author Rodolfo Melogli * @compatible WooCommerce 3.5.6 * @donate $9 https://businessbloomer.com/bloomer-armada/ */ // ----------------------------------------- // 1. Add custom field input @ Product Data > Variations > Single Variation add_action( 'woocommerce_variation_options_pricing', 'bbloomer_add_custom_field_to_variations', 10, 3 ); function bbloomer_add_custom_field_to_variations( $loop, $variation_data, $variation ) { woocommerce_wp_text_input( array( 'id' => 'custom_field[' . $loop . ']', 'class' => 'short', 'label' => __( 'Custom Field', 'woocommerce' ), 'value' => get_post_meta( $variation->ID, 'custom_field'

Can Not Start Elasticsearch As A Service In Ubuntu 16.04

Answer : I found the solution for this issue. The solution comes from this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website. It seems that to get Elasticsearch to run on 16.04 you have to set START_DAEMON to true on /etc/default/elasticsearch . It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine. Be sure to use systemctl restart instead of just start because the service is started right after installation, and apparently there's some socket/pidfile/something that systemd keeps that must be released before being able to start the service again. The problem lies on log files, "No java runtime was found." Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found Here's my solution to the problem. Check elasticsearch init file sudo nano /etc/init.d/elasticsearch search for . /usr/share/java-w

$id Jquery Code Example

Example: name class and id referance in ajax $ ( 'td[name ="tcol1"]' ) // matches exactly 'tcol1' $ ( 'td[name^="tcol"]' ) // matches those that begin with 'tcol' $ ( 'td[name$="tcol"]' ) // matches those that end with 'tcol' $ ( 'td[name*="tcol"]' ) // matches those that contain 'tcol'

Concatenate Two Strings In Java Code Example

Example 1: String concatenation in java // String concatenation in java using concat() method public class StringConcatMethodDemo { public static void main ( String [ ] args ) { String str1 = "Flower " ; String str2 = "Brackets" ; String str3 = str1 . concat ( str2 ) ; System . out . println ( str3 ) ; } } Example 2: string concat in java public class ConcatenationExample { public static void main ( String args [ ] ) { //One way of doing concatenation String str1 = "Welcome" ; str1 = str1 . concat ( " to " ) ; str1 = str1 . concat ( " String handling " ) ; System . out . println ( str1 ) ; //Other way of doing concatenation in one line String str2 = "This" ; str2 = str2 . concat ( " is" ) . concat ( " just a" ) . concat ( " String" ) ; System . out . println ( str2 ) ;

35-26-35 Inches To Cm Code Example

Example: inch to cm 1 inch = 2.54 cm

Composer Update Specific Package Code Example

Example 1: upgrade composer version composer self-update Example 2: update particular package composer composer update doctrine/doctrine-fixtures-bundle Example 3: composer update single package composer require phpmailer/phpmailer Example 4: composer update single package composer.phar update doctrine/doctrine-fixtures-bundle Example 5: composer update single package composer require {package/packagename}