Posts

Showing posts from November, 2000

Index Dataframe By Row Number Code Example

Example: pandas df by row index indices = [ 133 , 22 , 19 , 203 , 14 , 1 ] df_by_indices = df . iloc [ indices , : ]

Montserrat Light Font Free Download Code Example

Example: 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" >

Converting EBCDIC To ASCII In Java

Answer : If I am interpreting this format correctly you have a binary file format with fixed-length records. Some of these records are not character data (COBOL computational fields?) So, you will have to read the records using a more low-level approach processing individual fields of each record: import java.io.*; public class Record { private byte[] kdgex = new byte[2]; // COMP private byte[] b1code = new byte[2]; // COMP private byte[] b1number = new byte[8]; // DISPLAY // other fields public void read(DataInput data) throws IOException { data.readFully(kdgex); data.readFully(b1code); data.readFully(b1number); // other fields } public void write(DataOutput out) throws IOException { out.write(kdgex); out.write(b1code); out.write(b1number); // other fields } } Here I've used byte arrays for the first three fields of the record but you could use other more suitable types where appropriate (like a short for the first field with rea

Bootswatch Cdn Code Example

Example 1: bootstrap cdn < link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css " > Example 2: bootstrap cdn CSS < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css " > JS < script src = " https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js " > </ script > JQuery < script src = " https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js " > </ script > Example 3: bootstrap cdn <!-- Latest compiled and minified CSS --> < link rel = " stylesheet " href = " https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css " integrity = " sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u " crossorigin = " anonymous " > <!-- Optional theme --> < link rel

Convert Python Datetime To Timestamp In Milliseconds

Answer : In Python 3 this can be done in 2 steps: Convert timestring to datetime object Multiply the timestamp of the datetime object by 1000 to convert it to milliseconds. For example like this: from datetime import datetime dt_obj = datetime.strptime('20.12.2016 09:38:42,76', '%d.%m.%Y %H:%M:%S,%f') millisec = dt_obj.timestamp() * 1000 print(millisec) Output: 1482223122760.0 strptime accepts your timestring and a format string as input. The timestring (first argument) specifies what you actually want to convert to a datetime object. The format string (second argument) specifies the actual format of the string that you have passed. Here is the explanation of the format specifiers from the official documentation: %d - Day of the month as a zero-padded decimal number. %m - Month as a zero-padded decimal number. %Y - Year with century as a decimal number %H - Hour (24-hour clock) as a zero-padded decimal number. %M - Minute as a ze

Box Shadow Tailwind Css Code Example

Example 1: tailwind box shadow < div class = " shadow-sm ... " > </ div > < div class = " shadow ... " > </ div > < div class = " shadow-md ... " > </ div > < div class = " shadow-lg ... " > </ div > < div class = " shadow-xl ... " > </ div > < div class = " shadow-2xl ... " > </ div > Example 2: tailwind bottom shadow <! DOCTYPE html > < html > < head > < title > Box Shadow </ title > < style type = " text/css " > .box { height : 150 px ; width : 300 px ; margin : 20 px ; border : 1 px solid #ccc ; } .top { box-shadow : 0 -5 px 5 px -5 px #333 ; } .right { box-shadow : -5 px 0 5 px -5 px #333 ; } .bottom { box-shadow : 0 5 px 5 px -5 px #333 ; } .left

Create (nested) List From Two Lists In Python

Answer : Use the builtin zip function. It's exactly what you want. From the python manuals: >>> x = [1, 2, 3] >>> y = [4, 5, 6] >>> zipped = zip(x, y) >>> zipped [(1, 4), (2, 5), (3, 6)] Or if you want a list of lists, instead of a list of tuples, you use zip with a list comprehension: >>> zipped = [list(t) for t in zip(x, y)] >>> zipped [[1, 4], [2, 5], [3, 6]] Try: listone = [1,2,3] listtwo = [4,5,6] merged = map(list, zip(listone, listtwo)) zip(listone, listtwo) will return a list of tuples. Since you want a list of lists you need to convert each tuple to a list. map(list, list_of_tuples) call will do exactly that.

Insertion Sort Time Complexity And Space Complexity Code Example

Example: what is time complexity of insertion sort Time Complexity is : If the inversion count is O ( n ) , then the time complexity of insertion sort is O ( n ) . Some Facts about insertion sort : 1. Simple implementation : Jon Bentley shows a three - line C version , and a five - line optimized version [ 1 ] 2. Efficient for ( quite ) small data sets , much like other quadratic sorting algorithms 3. More efficient in practice than most other simple quadratic ( i . e . , O ( n2 ) ) algorithms such as selection sort or bubble sort 4. Adaptive , i . e . , efficient for data sets that are already substantially sorted : the time complexity is O ( kn ) when each element in the input is no more than k places away from its sorted position 5. Stable ; i . e . , does not change the relative order of elements with equal keys 6. In - place ; i . e . , only requires a constant amount O ( 1 ) of additional memory space Online ; i . e . , can sort a list a

Add Controls Dynamically In Flowlayoutpanel

Answer : For a FlowLayoutPanel, you don't need to specify a .Location since the controls are arranged for you: Represents a panel that dynamically lays out its contents horizontally or vertically. ... The FlowLayoutPanel control arranges its contents in a horizontal or vertical flow direction. Its contents can be wrapped from one row to the next, or from one column to the next. Just change " flowLayoutPanel1 " to the name of your FlowLayoutPanel : for (int i = 0; i < 5; i++) { Button button = new Button(); button.Tag = i; flowLayoutPanel1.Controls.Add(button); }

Range Attribute Unity Code Example

Example: how to set a range for public int or float unity using UnityEngine ; public class Example : MonoBehaviour { // This integer will be shown as a slider, // with the range of 1 to 6 in the Inspector [ Range ( 1 , 6 ) ] public int integerRange ; // This float will be shown as a slider, // with the range of 0.2f to 0.8f in the Inspector [ Range ( 0.2f , 0.8f ) ] public float floatRange ; }

Build HashSet From A Vector In Rust

Answer : Because the operation does not need to consume the vector¹, I think it should not consume it. That only leads to extra copying somewhere else in the program: use std::collections::HashSet; use std::iter::FromIterator; fn hashset(data: &[u8]) -> HashSet<u8> { HashSet::from_iter(data.iter().cloned()) } Call it like hashset(&v) where v is a Vec<u8> or other thing that coerces to a slice. There are of course more ways to write this, to be generic and all that, but this answer sticks to just introducing the thing I wanted to focus on. ¹This is based on that the element type u8 is Copy , i.e. it does not have ownership semantics. The following should work nicely; it fulfills your requirements: use std::collections::HashSet; use std::iter::FromIterator; fn vec_to_set(vec: Vec<u8>) -> HashSet<u8> { HashSet::from_iter(vec) } from_iter() works on types implementing IntoIterator , so a Vec argument is sufficient. Ad

Pyplot.legend Code Example

Example 1: matplotlib legend import numpy as np import matplotlib . pyplot as plt x = np . linspace ( 0 , 20 , 1000 ) y1 = np . sin ( x ) y2 = np . cos ( x ) plt . plot ( x , y1 , "-b" , label = "sine" ) plt . plot ( x , y2 , "-r" , label = "cosine" ) plt . legend ( loc = "upper left" ) plt . ylim ( - 1.5 , 2.0 ) plt . show ( ) Example 2: plt.legend( plt . legend ( [ 'first' , 'second' ] ) ; Example 3: python how to add a figure legend at the best position # Short answer : # matplotlib . pyplot places the legend in the "best" location by default # To add a legend to your plot , call plt . legend ( ) # Example usage : import matplotlib . pyplot as plt x1 = [ 1 , 2 , 3 ] # Invent x and y data to be plotted y1 = [ 4 , 5 , 6 ] x2 = [ 1 , 3 , 5 ] y2 = [ 6 , 5 , 4 ] plt . plot ( x1 , y1 , label = "Dataset_1" ) # Use label = "data_name"

Android Button Border Radius Code Example

Example 1: rounded corners button in android <?xml version="1.0" encoding="utf-8"?> < shape xmlns: android = " http://schemas.android.com/apk/res/android " > < corners android: radius = " 24dp " /> < solid android: color = " #F00 " /> </ shape > Example 2: how to add corner radius in android button < shape xmlns: android = " http://schemas.android.com/apk/res/android " android: shape = " rectangle " > < solid android: color = " @color/primary " /> < corners android: radius = " 5dp " /> </ shape >

Bootstrap Multi Tags Input Cdn Code Example

Example: bootstrap multi tags input cdn Bootstrap Tagsinput how to get multiple values as an array ...

Cannot Connect To The Docker Daemon At Tcp://localhost:2375. Is The Docker Daemon Running? Wsl Code Example

Example: WSL connect docker daemon to docker for windows echo "export DOCKER_HOST=tcp://localhost:2375" >> ~/.bashrc && source ~/.bashrc

Crontab Every 3 Hours Code Example

Example 1: cron every 3 hours 0 */3 * * * Example 2: crontab every 30 minutes between hours // from 08h to 17h (until 17:30) */30 8-17 * * * // from 08h to 17h, at number '5' (until 17:35) 5,30 8-17 * * * Example 3: cron every two hours 0 */2 * * *

How To Make A Sleep Function In C Code Example

Example 1: sleep in c programming //sleep function provided by <unistd.h> # include <stdio.h> # include <stdlib.h> # include <unistd.h> int main ( ) { printf ( "Sleeping for 5 seconds \n" ) ; sleep ( 5 ) ; printf ( "Wake up \n" ) ; } Example 2: how to sleep in c # include <stdio.h> # include <stdlib.h> # include <unistd.h> int main ( ) { printf ( "Sleeping for 5 seconds \n" ) ; sleep ( 5 ) ; printf ( "Sleep is now over \n" ) ; } Example 3: use sleep in c in windows # include <Windows.h> int main ( ) { Sleep ( 500 ) ; }

Css Multiple Classes Same Style Code Example

Example 1: css multiple classes same rule . bucket1 , . bucket2 , . bucket3 { } . bucket4 , . bucket5 , . bucket6 { } Example 2: css multiple classes //HTML Code < div class = 'firstClass secondClass' > < / div > //CSS Code . firstClass . secondClass { } Example 3: css change multiple classes . objectOne , . objectTwo { /* We will now both be changed */ margin : 0 auto ; } Example 4: css assign multiple classes to one element To specify multiple classes , separate the class names with a space , e . g . < span class = "classA classB" > . This allows you to combine several CSS classes for one HTML element . Example 5: css multiple classes < div class = "a-class another-class" > < / div >

Font Awsome Circle Info Icon Code Example

Example: font awsome circle info icon fa - info - circle

Create Div Element In Javascript Code Example

Example 1: js create element var newDiv = document.createElement("div"); document.body.appendChild(newDiv); Example 2: js create div document.body.onload = addElement; function addElement () { // create a new div element const newDiv = document.createElement("div"); // and give it some content const newContent = document.createTextNode("Hi there and greetings!"); // add the text node to the newly created div newDiv.appendChild(newContent); // add the newly created element and its content into the DOM const currentDiv = document.getElementById("div1"); document.body.insertBefore(newDiv, currentDiv); } Example 3: javascript create div in div Your code works well you just mistyped this line of code: document.getElementbyId('lc').appendChild(element); change it with this: (The "B" should be capitalized.) document.getElementById('lc').appendChild(element); HERE IS MY EXAMPLE: < html > < head &g

How To Center Text Inside A Square Div Css Code Example

Example 1: css center text /* To center text, you need to use text-align. */ .centerText { text-align : center ; /* This puts the text into the center of the screen. */ } /* There are also other things that you can use in text-align: left, right, and justify. Left and right make the test align to the right or left of the screen, while justify makes the text align both sides by spreading out spaces between some words and squishing others. */ Example 2: center element in div /* html */ <h1>Centering with CSS</h1> <h3>Text-Align Method</h3> <div class= "blue-square-container" > <div class= "blue-square" ></div> </div> <h3>Margin Auto Method</h3> <div class= "yellow-square" ></div> <h3>Absolute Positioning Method</h3> <div class= "green-square" ></div> /* css */ h1 , h3 { text-align : center ; } .blue-square-container { text-align : cen

Add Inventory Icon Font Awesome Code Example

Example: add icon font awesome < i class = " fa fa-plus " aria-hidden = " true " > </ i >

Hack Typing Code Example

Example 1: code typer Don't be so lazy ! Example 2: hacker typer give password tik tok uhhh . miaa123

Apple - Can I Export My Signature From Preview On One Mac And Import It On Another?

Image
Answer : This was covered by Aussie Bloke's blog when Lion arrived. Here are the steps to get both the file where the signature is stored as well as the associated keychain entry to a second Mac. On the source Mac: Open the ~/Library/Containers/com.apple.Preview/Data/Library/Preferences folder. In Finder , click the Go menu and hold option to show the Library folder. Alternatively, press ⇧⌘G whilst Finder is active and enter the path above to directly navigate. On OS X Mavericks 10.9 and earlier , copy the com.apple.Preview.signatures.plist file. On OS X Yosemite 10.10 and later , copy the com.apple.PreviewLegacySignaturesConversion.plist file. Launch Keychain Access Ensure the login keychain is selected and choose the Passwords category. On OS X Mavericks 10.9 and earlier , right-click the Preview Signature Privacy password and select Copy Password to Clipboard . This is the password used to encrypt the signature images. On OS X Yosemite 10.10 and l

C# Regex For Guid

Answer : This one is quite simple and does not require a delegate as you say. resultString = Regex.Replace(subjectString, @"(?im)^[{(]?[0-9A-F]{8}[-]?(?:[0-9A-F]{4}[-]?){3}[0-9A-F]{12}[)}]?$", "'$0'"); This matches the following styles, which are all equivalent and acceptable formats for a GUID. ca761232ed4211cebacd00aa0057b223 CA761232-ED42-11CE-BACD-00AA0057B223 {CA761232-ED42-11CE-BACD-00AA0057B223} (CA761232-ED42-11CE-BACD-00AA0057B223) Update 1 @NonStatic makes the point in the comments that the above regex will match false positives which have a wrong closing delimiter. This can be avoided by regex conditionals which are broadly supported. Conditionals are supported by the JGsoft engine, Perl, PCRE, Python, and the .NET framework. Ruby supports them starting with version 2.0. Languages such as Delphi, PHP, and R that have regex features based on PCRE also support conditionals. (source http://www.regular-expressions.info/c

Access Control Request Headers, Is Added To Header In AJAX Request With JQuery

Answer : Here is an example how to set a request header in a jQuery Ajax call: $.ajax({ type: "POST", beforeSend: function(request) { request.setRequestHeader("Authority", authorizationToken); }, url: "entities", data: "json=" + escape(JSON.stringify(createRequestObject)), processData: false, success: function(msg) { $("#results").append("The result =" + StringifyPretty(msg)); } }); This code below works for me. I always use only single quotes, and it works fine. I suggest you should use only single quotes or only double quotes, but not mixed up. $.ajax({ url: 'YourRestEndPoint', headers: { 'Authorization':'Basic xxxxxxxxxxxxx', 'X-CSRF-TOKEN':'xxxxxxxxxxxxxxxxxxxx', 'Content-Type':'application/json' }, method: 'POST', dataType: 'json', data: YourData, success: function(da

Conda Install Matplotlib Code Example

Example 1: install matplotlib conda conda install - c conda - forge matplotlib Example 2: python pip install matplotlib pip install matplotlib Example 3: conda install matplotlib conda install matplotlib

Angular Ngx-translate Usage In Typescript

Answer : To translate something in your typescript file, do the following constructor(private translate: TranslateService) {} then use like this wherever you need to translate this.translate.instant('my.i18n.key') From the doc on github: get(key: string|Array, interpolateParams?: Object): Observable: Gets the translated value of a key (or an array of keys) or the key if the value was not found try in your controller/class: constructor(private translate: TranslateService) { let foo:string = this.translate.get('myKey'); } To translate in Typscript file ,do follow code Import in header import { TranslateService } from '@ngx-translate/core'; In constructor declare as public translate: TranslateService Suppose the JSON file looks like this { "menu":{ "Home": "Accueil" } } Declare the below code in constructor. Note: Key stands for your main key value that used in language.json

C# Bytre Array To String Code Example

Example: string from byte array c# var str = System . Text . Encoding . Default . GetString ( result ) ;