Posts

Showing posts from April, 2013

Anaconda - Graphviz - Can't Import After Installation

Answer : The graphviz conda package is no Python package. It simply puts the graphviz files into your virtual env's Library/ directory. Look e.g. for dot.exe in the Library/bin/ directory. To install the `graphviz` **Python package**, you can use `pip`: `conda install pip` and `pip install graphviz`. Always prefer conda packages if they are available over pip packages. Search for the package you need (`conda search pkgxy`) and then install it (`conda install pkgxy`). If it is not available, you can always build your own conda packages or you can try anaconda.org for user-built packages. Update : There exists now a python-graphviz package at Anaconda.org which contains the Python interface for the graphviz tool. Simply install it with conda install python-graphviz . (Thanks to wedran and g-kaklam for posting this solution and to endolith for notifying me). On conda: First install conda install graphviz Then the python-library for graphviz python-graphviz

Check If String Contains String Php Code Example

Example 1: php check if string contains word $myString = 'Hello Bob how are you?' ; if ( strpos ( $myString , 'Bob' ) !== false ) { echo "My string contains Bob" ; } Example 2: php find if string contains if ( strpos ( $string , 'substring' ) !== false ) { // do stuff } Example 3: php find if substring is in string $result = strpos ( "haystack" , "needle" ) ; if ( $result != false ) { // text found } Example 4: php string contains $mystring = 'abc' ; $findme = 'a' ; $pos = strpos ( $mystring , $findme ) ; Example 5: php check if string contains // returns true if $needle is a substring of $haystack function contains ( $haystack , $needle ) { return strpos ( $haystack , $needle ) !== false ; } Example 6: php check if string contains word $myString = 'Hello Bob how are you?' ; if ( strpos ( $myString , 'Bob' ) !== false )

Bootstrap 4 Checkbox Validation Code Example

Example 1: bootstrap forms < form > < div class = "form-group" > < label for = "exampleInputEmail1" > Email address < / label > < input type = "email" class = "form-control" id = "exampleInputEmail1" aria - describedby = "emailHelp" placeholder = "Enter email" > < small id = "emailHelp" class = "form-text text-muted" > We 'll never share your email with anyone else . < / small > < / div > < div class = "form-group" > < label for = "exampleInputPassword1" > Password < / label > < input type = "password" class = "form-control" id = "exampleInputPassword1" placeholder = "Password" > < / div > < div class = "form-check" > < input type = "checkbox" class = "form-check-in

Can't Delete File From External Storage In Android Programmatically

Answer : Using ContentResolver to delete media files is wrong and provides many problems for the user. You can not delete a file on the sd-card simply by deleting its information from the ContentResolver on Android versions greater than Jelly Bean(4.3) . It works only on Android versions prior to KitKat(4.4) . That's why the Android team provided DocumentProvider. Why contentResolver.delete(...) is wrong? 1. Fills up the sd-card When you try to delete a media file on the sd-card by the ContentResolver on Android versions greater than 4.3, the actual media file will remain untouched because the contentResolver.delete(...) approach only removes the information (name, date, path ...) of the media and you will end up having unregistered media files on your sd-card which ContentResolver has no idea about their existence anymore and that's why you couldn't see them in your gallery and you think they've been deleted with this approach while they're stil

Brew: Command Not Found Code Example

Example 1: mac brew: command not found ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Example 2: install brew on mac /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Example 3: how to install homebrew on mac mkdir homebrew && curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

Color Of Circularprogressindicator Flutter Code Example

Example 1: circularrprogress indicator change color CircularProgressIndicator( valueColor: new AlwaysStoppedAnimation < Color > (Colors.blue), ), Example 2: how to change color of circular progress indicator in flutter valueColor: new AlwaysStoppedAnimation < Color > (Colors.blue),

Can C++ Raise An Error When Std Array Initialization Is Too Small?

Answer : You can use std::make_array or something like it to cause the types to differ std::array<int, 6> = std::make_array(4,3,2); gives this error in gcc: <source>:30:53: error: conversion from 'array<[...],3>' to non-scalar type 'array<[...],6>' requested You can create your own layer of abstraction that complains when you don't pass the exact same number of arguments for initialization. template <std::size_t N, class ...Args> auto createArray(Args&&... values) { static_assert(sizeof...(values) == N); using First = std::tuple_element_t<0, std::tuple<Args...>>; return std::array<First, N>{values...}; } To be invoked as auto ok = createArray<6>(4, 3, 2, 1, 0, -1); auto notOk = createArray<6>(4, 3, 2}; Instead of writing your own createArray method you can use the https://en.cppreference.com/w/cpp/experimental/make_array if your compiler supports it. #include &l

Bootstrap Timepicker Code Example

Example 1: bootstrap datepicker < div class = "container" > < div class = "row" > < div class = 'col-sm-6' > < div class = "form-group" > < div class = 'input-group date' id = 'datetimepicker1' > < input type = 'text' class = "form-control" / > < span class = "input-group-addon" > < span class = "glyphicon glyphicon-calendar" > < / span > < / span > < / div > < / div > < / div > < script type = "text/javascript" > $ ( function ( ) { $ ( '#datetimepicker1' ) . datetimepicker ( ) ; } ) ; < / script > < / div > < / div > Example 2: datepicker bootstrap $ ( '.datepicker' ) . datepicker

Bootstrap Navbar Start With Hamburger Menu Examples

Example 1: bootstrap hamburger menu < script src = " https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js " > </ script > < script src = " https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/js/bootstrap.min.js " > </ script > < link rel = " stylesheet " href = " https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css " > < nav class = " navbar navbar-inverse navbar-static-top " role = " navigation " > < div class = " container " > < div class = " navbar-header " > < button type = " button " class = " navbar-toggle collapsed " data-toggle = " collapse " data-target = " #bs-example-navbar-collapse-1 " > < span class = " sr-only " > Toggle navigation </ span > < s

Gcd Of N Numbers In C Code Example

Example 1: gcd of two numbers in c # include <stdio.h> int main ( ) { int n1 , n2 , i , gcd ; printf ( "Enter two integers: " ) ; scanf ( "%d %d" , & n1 , & n2 ) ; for ( i = 1 ; i <= n1 && i <= n2 ; ++ i ) { // Checks if i is factor of both integers if ( n1 % i == 0 && n2 % i == 0 ) gcd = i ; } printf ( "G.C.D of %d and %d is %d" , n1 , n2 , gcd ) ; return 0 ; } Example 2: gcd of two numbers in c # include <stdio.h> int main ( ) { int n1 , n2 ; printf ( "Enter two positive integers: " ) ; scanf ( "%d %d" , & n1 , & n2 ) ; while ( n1 != n2 ) { if ( n1 > n2 ) n1 -= n2 ; else n2 -= n1 ; } printf ( "GCD = %d" , n1 ) ; return 0 ; }

Clear Cache Composer Code Example

Example 1: clear composer cache composer clearcache //Then autoload composer composer dump-autoload Example 2: composer remove cache composer clearcache #You can also use composer clear-cache #which is an alias for clearcache. Example 3: composer clear cache $ composer clearcache

Bootstrap Textarea Responsive Width Code Example

Example: bootstrap textarea width <textarea class= "form-control" style= "min-width: 100%" ></textarea>

Can I Unlock The Crystal Cruiser With Type C Of The Rock Cruiser?

Answer : I can confirm that the Rock Cruiser Type C can bypass the first two steps of this quest chain, finally having done it in game. You must find the beacon event in the Rock Homeworlds sector without the aid of a quest marker, but the event can still be generated irrelevant of the stasis pod quests, and your beginning crystal crew member will give you the blue choice option once the event is found. Long-ranged scanners help a lot with this, as the event should only be present at a beacon with no ship detected, as well as no store, no distress call, and no hazard. Once you enter the hidden sector, you do get a quest marker for the crystal ship location, which is quite nice. I guess I should have read the updated wiki page that I linked in my question before posting. Alternatively, the Rock Cruiser type C in the Advanced Edition starts with a single Crystal aboard the ship, allowing you to skip the first two events normally required in order to allow access to the blue opti

BootJar + MavenJar. Artifact Wasn't Produced By This Build

Answer : As stated by gradle documentation here: Starting from Gradle 6.2, Gradle performs a sanity check before uploading, to make sure you don’t upload stale files (files produced by another build). This introduces a problem with Spring Boot applications which are uploaded using the components.java component More explanation is available in the link above. They propose the following workaround that I personally tried and worked for me : configure the outgoing configurations configurations { [apiElements, runtimeElements].each { it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) } it.outgoing.artifact(bootJar) } } here after the configuration from my build.gradle: .... apply plugin: 'maven-publish' ... configurations { [apiElements, runtimeElements].each { it.outgoing.artifacts.removeIf { it.buildDependencies.getDependencies(null).contains(jar) } it.outgoing.a

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools

Answer : As the warning message states, the SDK location should not contain whitespace. Your SDK is at C:\Users\Giacomo B\AppData\Local\Android\sdk . There is a whitespace character in Giacomo B . The easiest solution is to move the SDK somewhere else, where there is no space or other whitespace character in the path, such as C:\Android\sdk . You can point both Android Studio installations to the new location. There is another way: Open up CMD ( as Administrator ) Type: mklink /J C:\Program-Files "C:\Program Files" ( Or in my case mklink /J C:\Program-Files-(x86) "C:\Program Files (x86)" ) Hit enter Magic happens! ( Check your C drive ) Now you can point to C:\Program-Files ( C:\Program-Files-(x86) ). just change the path: "c:\program files\android\sdk" to "c:\progra~1\android\sdk" or "c:\program files (x86)\android\sdk" to "c:\progra~2\android\sdk" note that the paths should not contain spaces.

CocoaPods - Use Specific Pod Version

Answer : In your Podfile: pod 'AFNetworking', '1.2.0' Check 'Get started' at http://cocoapods.org Once this is done, you can then issue a pod update in the terminal for the change to take place. Of course, this needs to be done from your project's top level folder. If the update does not occur, edit your Podfile.lock file and change the AFNetworking version # to something less than what it is and issue a pod update in the terminal again. This tells CocoaPods that you have a different version installed and that it must update. Here, below mentions all possible ways to install pod with use cases. To install the latest pod version , omit the version number after pod name. pod 'Alamofire' To install specific pod version, specify pod version after pod name. pod 'Alamofire', '5.0.0' Besides no version, or a specific one, it is also possible to use logical operators: '> 0.1' Any version highe

Can't Login After Suspend On Ubuntu 17.10

Answer : CrashPlan Solution The problem for me was CrashPlan keeping too many files open while I was away. After rebooting, I looked in /etc/log/syslog and found "No space left on device" errors around the time of my login failure. If you use CrashPlan and find similar messages, then this might work for you too. Messages like: Dec 11 13:01:43 myDesktop systemd[1]: anacron.service: Failed to add inotify watch descriptor for control group /system.slice/anacron.service: No space left on device Dec 11 13:36:15 myDesktop gdm-password]: AccountsService: Failed to monitor logind session changes: No space left on device Dec 11 13:36:40 myDesktop systemd[1]: apt-daily.service: Failed to add inotify watch descriptor for control group /system.slice/apt-daily.service: No space left on device The instructions on the CrashPlan site worked for me (please read before trying on your system): https://support.code42.com/CrashPlan/4/Troubleshooting/Linux_real-time_file_watching_errors

Why & Is Typed After Vector In C++ Code Example

Example: declare vectors c++ vector < int > vec ; //Creates an empty (size 0) vector vector < int > vec ( 4 ) ; //Creates a vector with 4 elements. /*Each element is initialised to zero. If this were a vector of strings, each string would be empty. */ vector < int > vec ( 4 , 42 ) ; /*Creates a vector with 4 elements. Each element is initialised to 42. */ vector < int > vec ( 4 , 42 ) ; vector < int > vec2 ( vec ) ; /*The second line creates a new vector, copying each element from the vec into vec2. */