Posts

Showing posts from March, 2014

Android Floating View (over Other Views)

Answer : A FrameLayout allows you to have a view overlapping another view. I'm not sure it makes sense to have them with only one child view, as you have in your example. Try having a FrameLayout at the highest level, with your "static" view as the first child element, and the floating menu as the second child. The developer documents have a good overview the layout types, it might help you get started.

Android Get Sha1 Fingerprint Programmatically Code Example

Example: android developer sha1 fingerprint keytool -list -v \ -alias androiddebugkey -keystore %USERPROFILE%\.android\debug.keystore

Asus Smart Gesture Getting CPU To 3GHz

Answer : You can add a DWORD value with Regedit to disable that behaviour: In HKEY_LOCAL_MACHINE\SOFTWARE\ASUS\ASUS Smart Gesture Add the DWORD AutoSetMaxPower , set it to 0 and reboot.

Black Gradient Background Css Code Example

Example: linear gradient css /* A gradient tilted 100 degrees, starting gray and finishing black */ .class { background : linear-gradient ( 100 deg , rgba ( 63 , 63 , 63 , 0.8 ) 0 % , rgba ( 255 , 255 , 255 , 0 ) 25 % ) ; } /* A gradient going from the bottom to top starting red and finishing orange */ .class { background : linear-gradient ( to top , #f32b60 , #ff8f1f ) ; }

Choose Specific Access Point In A Multiple Access Point WIFI Network Sharing SSID

Answer : You can do this in NetSetMan: http://www.netsetman.com/en/wifi The software is free for personal use. Main menu -> Tools > NSM WiFi Management Choose the AP you'd like to use and connect. If you open network sharing center, then click on the picture for your active wireless network it should come up with a window called "set network properties". At the bottom of the window is a button for "merge or delete network locations". After you are disconnected from the network, you can delete the bad AP from this list. It will not connect to that AP again. Well, I don't know of a free utility, but from what I've gleaned (no personal experience, so YMMV) WirelessMon (USD 24) allows a user to connect to a specific access point within a network containing multiple devices all within a single SSID.

CocoaPods Install Issue

Answer : I had the same issue before. I fixed it by putting the following lines in the terminal: cd ~/.cocoapods/repos rm -rf master pod setup You need reinstall cocoapods: so sudo gem uninstall cocoapods sudo gem install cocoapods pod setup I was facing the same issue. I resolved the issue by running the following commands on the same path: rm -rf ~/.cocoapods/repos/trunk/ pod install

Best Ide For Python Mac Os X Code Example

Example 1: ide for python #i presonally use pycharm but be open for other IDE's Example 2: best python ide PyCharm - https://www.jetbrains.com/pycharm/ # Only for python Visual Studio Code - https://code.visualstudio.com/ # Personally use and can work for tons of different languages (Highly Reccommend) IDLE # default ide comes with python, its pretty good comes with python documentation

Bootstrap Responsive Navbar Codepen Code Example

Example: responsive navbar bootstrap 4 < nav class = " navbar navbar-expand-lg navbar-light bg-light " > < a class = " navbar-brand " href = " # " > swipeit </ a > < button class = " navbar-toggler " type = " button " data-toggle = " collapse " data-target = " #navbarSupportedContent " aria-controls = " navbarSupportedContent " aria-expanded = " false " aria-label = " Toggle navigation " > < span class = " navbar-toggler-icon " > </ span > </ button > < div class = " collapse navbar-collapse " id = " navbarSupportedContent " > < ul class = " navbar-nav mr-auto " > < li class = " nav-item active " > < a class = " nav-link " href = " # " > Home < span class = " sr-only " > (curren

Android: Adb: Permission Denied

Answer : According to adb help : adb root - restarts the adbd daemon with root permissions Which indeed resolved the issue for me. Without rooting : If you can't root your phone, use the run-as <package> command to be able to access data of your application. Example: $ adb exec-out run-as com.yourcompany.app ls -R /data/data/com.yourcompany.app/ exec-out executes the command without starting a shell and mangling the output. The reason for "permission denied" is because your Android machine has not been correctly rooted. Did you see $ after you started adb shell ? If you correctly rooted your machine, you would have seen # instead. If you see the $ , try entering Super User mode by typing su . If Root is enabled, you will see the # - without asking for password.

20. Write A Python Program To Count The Number Of Lines In A Text File. Code Example

Example 1: Write a Python program to count the number of lines in a text file. def countlines ( fname , mode = 'r+' ) : count = 0 with open ( fname ) as f : for _ in f : count += 1 print ( 'total number of lines in file : ' , count ) countlines ( 'file1.txt' ) ########################## with open ( 'file1.txt' ) as f : print ( sum ( 1 for _ in f ) ) ########################## with open ( 'file1.txt' ) as f : for lno , line in enumerate ( f , 1 ) : pass print ( 'total lines:' , lno ) ########################### '''You can use len(f.readlines()), but this will create an additional list in memory, which won't even work on huge files that don't fit in memory. ''' Example 2: Write a Python program to count the number of lines in a text file. def countlines ( fname , mode = 'r+' ) : count = 0 with open ( fname ) as f : for

Android - MyLooper() Vs GetMainLooper()

Answer : You have it described in the docs: getMainLooper() Returns the application's main looper, which lives in the main thread of the application. myLooper() Return the Looper object associated with the current thread. Returns null if the calling thread is not associated with a Looper. As for whether getMainLooper() is of any use, I can assure you it really is. If you do some code on a background thread and want to execute code on the UI thread, e.g. update UI, use the following code: new Handler(Looper.getMainLooper()).post(new Runnable() { // execute code that must be run on UI thread }); Of course, there are other ways of achieving that. Another use is, if you want to check if the currently executed code is running on the UI thread, e.g. you want to throw / assert: boolean isUiThread = Looper.getMainLooper().getThread() == Thread.currentThread(); or boolean isUiThread = Looper.getMainLooper().isCurrentThread(); Looper.getMainLooper() is co

How To Find Array Length In Python Code Example

Example 1: python get array length # To get the length of a Python array , use 'len()' a = arr . array ( ‘d’ , [ 1.1 , 2.1 , 3.1 ] ) len ( a ) # Output : 3 Example 2: find array length in python a = arr . array ( 'd' , [ 1.1 , 2.1 , 3.1 ] ) len ( a )

Binary Semaphore Vs A ReentrantLock

Answer : there is no real reason ever to have a binary semaphore as everything that a binary semaphore can do can also be done by a ReentrantLock If all you need is reentrant mutual exclusion, then yes, there is no reason to use a binary semaphore over a ReentrantLock. If for any reason you need non-ownership-release semantics then obviously semaphore is your only choice. Also since reentrant locks also provide one lock per object, isn't it always a better idea to prefer a reentrant lock to a binary semaphore? It depends on the need. Like previously explained, if you need a simple mutex, then don't choose a semaphore. If more than one thread (but a limited number) can enter a critical section you can do this through either thread-confinement or a semaphore. I have checked a post here that talks about difference between a binary semaphore and a mutex but is there a thing like a mutex in Java? ReentrantLock and synchronized are examples of mu

Bootstrap Combining Rows (rowspan)

Answer : Divs stack vertically by default, so there is no need for special handling of "rows" within a column. div { height:50px; } .short-div { height:25px; } <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> <div class="container"> <h1>Responsive Bootstrap</h1> <div class="row"> <div class="col-lg-5 col-md-5 col-sm-5 col-xs-5" style="background-color:red;">Span 5</div> <div class="col-lg-3 col-md-3 col-sm-3 col-xs-3" style="background-color:blue">Span 3</div> <div class="col-lg-2 col-md-2 col-sm-3 col-xs-2" style="padding:0px"> <div class="short-div" style="background-color:green">Span 2</div> <div class="short-div" style="background-color:purple">Span 2</div>

Printing Double In C Code Example

Example: print double in c # include <stdio.h> int main ( ) { double d = 123.32445 ; //using %f format specifier printf ( "Value of d = %f\n" , d ) ; //using %lf format specifier printf ( "Value of d = %lf\n" , d ) ; return 0 ; }

Angular Material 2 - How To Lock Mat-toolbar And Mat-tabs To The Top

Answer : Did you mean a sticky toolbar? Just add a class to the toolbar and make it sticky (using the position attribute set to sticky ): .app-toolbar { position: sticky; position: -webkit-sticky; /* For macOS/iOS Safari */ top: 0; /* Sets the sticky toolbar to be on top */ z-index: 1000; /* Ensure that your app's content doesn't overlap the toolbar */ } Note: There is no support for position: sticky on IE 11. For more info on browser support for position: sticky , view this caniuse page. You can probably achieve it by setting the style with ::ng-deep: ::ng-deep .mat-toolbar{ z-index: 998; position: fixed } ::ng-deep .mat-tab-group{ margin-top:55px !important; } ::ng-deep .mat-tab-header{ z-index: 999; width:100vw; position: fixed !important; background-color: red !important; } ::ng-deep .mat-tab-body-wrapper{ position: relative !important; margin-top:55px; } DEMO Even i was facing the same issue for my

Badge In Bootstrap 5 Code Example

Example 1: bootstrap badge <!-- Badge Example --> < h1 > Example heading < span class = " badge bg-secondary " > New </ span > </ h1 > < h2 > Example heading < span class = " badge bg-secondary " > New </ span > </ h2 > < h3 > Example heading < span class = " badge bg-secondary " > New </ span > </ h3 > < h4 > Example heading < span class = " badge bg-secondary " > New </ span > </ h4 > < h5 > Example heading < span class = " badge bg-secondary " > New </ span > </ h5 > < h6 > Example heading < span class = " badge bg-secondary " > New </ span > </ h6 > <!-- Background colors --> < span class = " badge bg-primary " > Primary </ span > < span class = " badge bg-secondary " > Secondary </ span > < span cla

Best Practice For Calling The NgbModal Open Method

Answer : As of today the open method of https://ng-bootstrap.github.io/#/components/modal has the following signature: open(content: string | TemplateRef<any>, options: NgbModalOptions) . As you can see from this signature you can open a modal providing content as: string TemplateRef The string -typed argument is not very interesting - in fact it was mostly added to aid debugging / unit-testing. By using it you can pass just ... well, a piece of text , without any markup not Angular directives. As such it is really a debug tool and not something that is useful in real-life scenarios. The TemplateRef argument is more interesting as it allows you to pass markup + directives to be displayed. You can get a hand on a TemplateRef by doing <template #refVar>...content goes here...</template> somewhere in your component template (a template of a component from which you plan to open a modal). As such the TemplateRef argument is powerful as it allows you to ha

Bootstrap Button Icon Size Code Example

Example: bootstrap block large buttons with icons < button type = " button " class = " btn btn-primary " > Blue </ button >

Android - Change DNS For Mobile Data Without Using An App

Answer : I did not find a way to reliably do it without an app. I often use OpenDNS Family Shield, but sometimes it blocks me to visit some particular hacking site and then I need to quickly and easily change the DNS servers. I used to use Set DNS but it stopped to work in Android 4.3 and further, so I created Override DNS, a new app which mimics Set DNS' behaviour, but it's updated to work even in Lollipop. It has some other nice feature like a PIN protection ad a Wi-Fi SSID filter, too. The only way I can see to do it without an app is something like an iptables rule to redirect any traffic going to udp/53 to some other ip. A similar procedure is shown in a XDA thread. I paste here the iptables rules for completeness (I did not tested them) $IPTABLES -t nat -D OUTPUT -p tcp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true $IPTABLES -t nat -D OUTPUT -p udp --dport 53 -j DNAT --to-destination 208.67.222.222:53 || true $IPTABLES -t nat -I OUTPUT -p t

Check For Camel Case In Python

Answer : You could check if a string has both upper and lowercase. def is_camel_case(s): return s != s.lower() and s != s.upper() and "_" not in s tests = [ "camel", "camelCase", "CamelCase", "CAMELCASE", "camelcase", "Camelcase", "Case", "camel_case", ] for test in tests: print(test, is_camel_case(test)) Output: camel False camelCase True CamelCase True CAMELCASE False camelcase False Camelcase True Case True camel_case False Convert your string to camel case using a library like inflection . If it doesn't change, it must've already been camel case. from inflection import camelize def is_camel_case(s): # return True for both 'CamelCase' and 'camelCase' return camelize(s) == s or camelize(s, False) == s

Bootstrap Small Text Highlight Code Example

Example 1: bootstrap text size h1. Bootstrap heading h2. Bootstrap heading h3. Bootstrap heading h4. Bootstrap heading h5. Bootstrap heading h6. Bootstrap heading Example 2: bootstrap blockquote Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante. Someone famous in Source Title

Best Way To Check That Element Is Not Present Using Selenium WebDriver With Java

Answer : Instead of doing findElement, do findElements and check the length of the returned elements is 0. This is how I'm doing using WebdriverJS and I expect the same will work in Java i usually couple of methods (in pair) for verification whether element is present or not: public boolean isElementPresent(By locatorKey) { try { driver.findElement(locatorKey); return true; } catch (org.openqa.selenium.NoSuchElementException e) { return false; } } public boolean isElementVisible(String cssLocator){ return driver.findElement(By.cssSelector(cssLocator)).isDisplayed(); } Note that sometimes selenium can find elements in DOM but they can be invisible, consequently selenium will not be able to interact with them. So in this case method checking for visibility helps. If you want to wait for the element until it appears the best solution i found is to use fluent wait: public WebElement fluentWait(final By locator){ Wait<WebDriver

Bootstrap Flexbox W3schools Code Example

Example: css flex /* Flex */ .anyclass { display:flex; } /* row is the Default, if you want to change choose */ .anyclass { display:flex; flex-direction: row | row-reverse | column | column-reverse; } .anyclass { /* Alignment along the main axis */ justify-content: flex-start | flex-end | center | space-between | space-around | space-evenly | start | end | left | right ... + safe | unsafe; }