Posts

Showing posts from March, 2008
Answer : Resolving the operation not permitted error: sudo chmod u+x my_script.sh You created the file via: sudo vi my_script.sh # editing This means, the owner and group of the file is root. You are not allowed to change files of it by default. You need to change permission (chmod does it) or change the owner: sudo chown you:yourgroup my_script.sh This should do it. Save the trouble, without creating the file via sudo. You've created file my_script.sh with the root user as the owner (because you used sudo ), which is why you're not permitted to change the permissions as yourself . Thus, use sudo chmod u+x my_script.sh , but note that that will make the file only executable for the root user. To make the file executable by everyone, use sudo chmod a+x my_script.sh .

Blob Code Download Much Slower Than MS Azure Storage Explorer

Answer : You should specify which version of MS Azure Storage explorer your're using. If you're using some newer versions of 1.9.0 / 1.8.1 / 1.8.0 etc.(please find more details in this link), then Azure Storage Explorer is integrated with azcopy which is using simple commands designed for optimal performance. So you can have a good-performance for downloading / uploading etc. When using code for downloading / uploading blobs, you can take use of this Microsoft Azure Storage Data Movement Library. This library is based on the core data movement framework that powers AzCopy, which also provides you high-performance uploading, downloading. I eventually tried 2 solutions proposed by @Ivan and @mjwills: DownloadToFileParallelAsync resulted in 10min 12secs Microsoft Azure Storage Data Movement Library resulted in 9min 35secs Both solutions much faster than the original DownloadToFileAsync. DownloadToFileParallelAsync is only available in later versions of the library

Bootstrap 3 Colors Code Example

Example 1: bootstrap text color <p class= "text-primary" >.text-primary</p> <p class= "text-secondary" >.text-secondary</p> <p class= "text-success" >.text-success</p> <p class= "text-danger" >.text-danger</p> <p class= "text-warning" >.text-warning</p> <p class= "text-info" >.text-info</p> <p class= "text-light bg-dark" >.text-light</p> <p class= "text-dark" >.text-dark</p> <p class= "text-muted" >.text-muted</p> <p class= "text-white bg-dark" >.text- white </p> Example 2: bootstrap background color <div class= "p-3 mb-2 bg-primary text-white" >.bg-primary</div> <div class= "p-3 mb-2 bg-secondary text-white" >.bg-secondary</div> <div class= "p-3 mb-2 bg-success text-white" >.bg-success</div> <di

Accessing JPEG EXIF Rotation Data In JavaScript On The Client Side

Image
Answer : If you only want the orientation tag and nothing else and don't like to include another huge javascript library I wrote a little code that extracts the orientation tag as fast as possible (It uses DataView and readAsArrayBuffer which are available in IE10+, but you can write your own data reader for older browsers): function getOrientation(file, callback) { var reader = new FileReader(); reader.onload = function(e) { var view = new DataView(e.target.result); if (view.getUint16(0, false) != 0xFFD8) { return callback(-2); } var length = view.byteLength, offset = 2; while (offset < length) { if (view.getUint16(offset+2, false) <= 8) return callback(-1); var marker = view.getUint16(offset, false); offset += 2; if (marker == 0xFFE1) { if (view.getUint32(offset += 2, false) != 0x45786966) {

Cannot Resolve Class Android.support.design.widget.CoordinatorLayout Code Example

Example: Cannot resolve class android.support.design.widget.CoordinatorLayout Replace <android.support.design.widget.coordinatorlayout with <androidx.coordinatorlayout.widget.CoordinatorLayout

Accessing External Storage In Android API 29

Answer : On Android 10 Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory() will return storage paths but paths are not readable or writable. For Android 10 you can continue to use paths provided by Environment.getExternalStorageDirectory() and Environment.getExternalStoragePublicDirectory() if you add android:requestLegacyExternalStorage="true" to application tag in manifest file. At runtime your app can call Environment.isExternalStorageLegacy() to check if the request has been done. Another (not known) possibility (only for Android 10) is to add <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> to manifest file. The user has to go to the advanced settings of the app and enable from Advanced settings Install unknown apps | Allow from this source . The nice thing with this is that the user can switch the access rights. You can make it easier for the user if you implement an int

Bootstrap Rounded Button Code Example

Example 1: round button css .btn { display:block; height: 300px; width: 300px; border-radius: 50%; border: 1px solid red; } Example 2: bootstrap soft corner < div class = " container border rounded " > </ div > Example 3: button radius bootstrap 4 < span class = " border " > </ span > < span class = " border-top " > </ span > < span class = " border-right " > </ span > < span class = " border-bottom " > </ span > < span class = " border-left " > </ span >

Badges Bootstrap 3 Code Example

Example 1: bootstrap 4 badge <span class= "badge badge-primary" >Primary</span> <span class= "badge badge-secondary" >Secondary</span> <span class= "badge badge-success" >Success</span> <span class= "badge badge-danger" >Danger</span> <span class= "badge badge-warning" >Warning</span> <span class= "badge badge-info" >Info</span> <span class= "badge badge-light" >Light</span> <span class= "badge badge-dark" >Dark</span> Example 2: bootstrap Badges Badges scale to match the size of the immediate parent element by using relative font sizing and em units. <h1>Example heading <span class= "badge badge-secondary" >New</span></h1> <h2>Example heading <span class= "badge badge-secondary" >New</span></h2> <h3>Example heading <span class= &

Print Array Elements Without Loop C++ Code Example

Example: print the elements of the array without using the [] notation in c++ # include <iostream> using namespace std ; int main ( ) { int arr [ ] = { 2 , 4 , 8 } ; int size = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; for ( int i = 0 ; i < size ; i ++ ) { cout << * ( arr + i ) << " " ; // prints.. 2 4 8. } }

After Before Css Sample Code Example

Example 1: css before after The ::before and ::after pseudo-elements in CSS allows you to insert content onto a page without it needing to be in the HTML. While the end result is not actually in the DOM, it appears on the page as if it is, and would essentially be like this: div::before { content: "before"; } div::after { content: "after"; } < div > before <!-- Rest of stuff inside the div --> after </ div > The only reasons to use one over the other are: You want the generated content to come before the element content, positionally. The ::after content is also “after” in source-order, so it will position on top of ::before if stacked on top of each other naturally. Example 2: how use befor after for image /* for child */ .custom_img:after { content: ""; background-color: #2359cf; height: 400px; width: 70%; top: -15px; right: -6px; position: absolute; z-index: 999; }

Can An Interface Extend Multiple Interfaces In Java?

Answer : Yes, you can do it. An interface can extend multiple interfaces, as shown here: interface Maininterface extends inter1, inter2, inter3 { // methods } A single class can also implement multiple interfaces. What if two interfaces have a method defining the same name and signature? There is a tricky point: interface A { void test(); } interface B { void test(); } class C implements A, B { @Override public void test() { } } Then single implementation works for both :). Read my complete post here: http://codeinventions.blogspot.com/2014/07/can-interface-extend-multiple.html An interface can extend multiple interfaces . A class can implement multiple interfaces . However, a class can only extend a single class . Careful how you use the words extends and implements when talking about interface and class . Can an interface extend multiple interfaces in java? Answer is: Yes. According to JLS An interface ma

Column Contains A String Pyspark Dataframe Code Example

Example 1: pyspark filter column contains df.filter("location like '%google.com%'") Example 2: pyspark filter column contains df.filter(df.location.contains('google.com'))

C# Unity What Does GetComponent Code Example

Example 1: how to get component in unity c# GetComponent < Rigidbody > ( ) ; //used to find component on character (rigid body can be changed) GameObject . FindGameObjectWithTag ( "player" ) ; //finds any game object in the scene with this tag Example 2: getcomponent c# //First script public class Enemy : MonoBehaviour { public int health = 10 ; public void saySomething ( ) { Debug . Log ( "Hi, i am an enemy." ) ; } } //Second script //There is one thing though, //if the script is located on another gameobject, //which will be most likely, you have to somehow //find that gameobject first. There are many ways of //doing it, via raycast, collision, //trigger, find by tag, find by gameobject etc. //But i will use the simplest way to understand, //that is declaring public GameObject in player script, //which contains Enemy, and later you just drag and drop the //gameobject in the inspector. public class Player : M

Colour Picker Chrome Extension Code Example

Example: chrome color picker To open the Eye Dropper simply: 1. Open DevTools F12. 2. Go to Elements tab. 3. Under Styles side bar click on any color preview box.

Browser Reset Css Code Code Example

Example 1: css browser reset stylesheet /* http://meyerweb.com/eric/tools/css/reset/ v2.0 | 20110126 License: none (public domain) */ html , body , div , span , applet , object , iframe , h1 , h2 , h3 , h4 , h5 , h6 , p , blockquote , pre , a , abbr , acronym , address , big , cite , code , del , dfn , em , img , ins , kbd , q , s , samp , small , strike , strong , sub , sup , tt , var , b , u , i , center , dl , dt , dd , ol , ul , li , fieldset , form , label , legend , table , caption , tbody , tfoot , thead , tr , th , td , article , aside , canvas , details , embed , figure , figcaption , footer , header , hgroup , menu , nav , output , ruby , section , summary , time , mark , audio , video { margin : 0 ; padding : 0 ; border : 0 ; font-size : 100 % ; font : inherit ; vertical-align : baseline ; } /* HTML5 display-role reset for older browsers */ article , as

Base64 Decode Encode Php Code Example

Example: base64 decode in php base64_decode ( 'base64' ) ;

What Is The Time Complexity Of Insertion Sort In Best And Worst Case 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

Brew Install Aws Cli Code Example

Example 1: brew update aws cli brew install awscli Example 2: aws cli install # AWS CLI V2 # Installing on linux # depends on glibc, groff, and less curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" unzip awscliv2.zip sudo ./aws/install Example 3: aws terminal in mac curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip" unzip awscli-bundle.zip sudo ./awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws

Write A Bool Function C Code Example

Example: boolean function c # include <stdbool.h>

Add "ON DELETE CASCADE" To Existing Column In Laravel

Answer : Drop foreign key first. Thanks to Razor for this tip $table->dropForeign('answers_user_id_foreign'); $table->foreign('user_id') ->references('id')->on('users') ->onDelete('cascade'); $table->foreign('user_id') ->references('id')->on('users') ->onDelete('cascade'); In my case, i'll need to put the col name in an array else that will be an error. Schema::table('transactions', function (Blueprint $table) { $table->dropForeign(['transactions_order_id_foreign']); $table->foreign('order_id') ->references('id')->on('orders') ->onDelete('cascade') ->change(); }); mysql 5.7 ver

Std::string Find String Code Example

Example: std string find character c++ // string::find # include <iostream> // std::cout # include <string> // std::string int main ( ) { std :: string str ( "There are two needles in this haystack with needles." ) ; std :: string str2 ( "needle" ) ; // different member versions of find in the same order as above: std :: size_t found = str . find ( str2 ) ; if ( found != std :: string :: npos ) std :: cout << "first 'needle' found at: " << found << '\n' ; found = str . find ( "needles are small" , found + 1 , 6 ) ; if ( found != std :: string :: npos ) std :: cout << "second 'needle' found at: " << found << '\n' ; found = str . find ( "haystack" ) ; if ( found != std :: string :: npos ) std :: cout << "'haystack' also found at: " <&l

Click An Exact Match Text In Cypress

Answer : Regular Expressions will work nicely here. .contains() allows for regex So you can do a regex that matches the whole string only (use ^ and $ ). That way anything with extra characters won't match (like New Navigation Label). So for example, you could do: cy.get(`[data-test="dropdown"]`) .find('.item') .contains(/^Navigation Label$/) .click(); Regex is a little tricky when you are building an expression with a variable (ex. your option variable). In this case, you'll build a regular expression like so: cy.get(`[data-test="dropdown"]`) .find('.item') .contains(new RegExp("^" + option + "$", "g")) .click(); So to get an exact match with .contains() : cy.contains(new RegExp(yourString, "g")) You can use below code snippet to click on an element which has exact text. This will work like charm, let me know if you face any issue. You have to handle lik

Best Way To Represent A Readline Loop In Scala?

Answer : How about this? val lines = Iterator.continually(reader.readLine()).takeWhile(_ != null).mkString Well, in Scala you can actually say: val lines = scala.io.Source.fromFile("file.txt").mkString But this is just a library sugar. See Read entire file in Scala? for other possiblities. What you are actually asking is how to apply functional paradigm to this problem. Here is a hint: Source.fromFile("file.txt").getLines().foreach {println} Do you get the idea behind this? foreach line in the file execute println function. BTW don't worry, getLines() returns an iterator, not the whole file. Now something more serious: lines filter {_.startsWith("ab")} map {_.toUpperCase} foreach {println} See the idea? Take lines (it can be an array, list, set, iterator, whatever that can be filtered and which contains an items having startsWith method) and filter taking only the items starting with "ab" . Now take every item and map

AWS Amplify/CLI Vs AWS Mobile Hub

Answer : Use the Amplify CLI going forward, it's more flexible architecture that allows a comprehensive feature set. See the information in this post: Existing Mobile Hub projects continue to work without requiring any app changes. If you’re using the AWS Mobile CLI for existing projects, you can also continue to use that older CLI. However, going forward, new features will be added to the AWS Amplify CLI toolchain which does not use Mobile Hub. If you’re building a new mobile or web app, or adding cloud capabilities to brownfield apps, use the new AWS Amplify CLI. The new Amplify CLI will allow you to take advantage of all the new features outlined in this blog, as well as the rich CloudFormation functionality to unlock more workflows and future tooling. Section: Existing tooling , https://aws.amazon.com/blogs/mobile/announcing-the-aws-amplify-cli-toolchain/

Circa Symbol In Latex Code Example

Example: less equal latex // <= $\leq$ // >= $\geq$