Posts

Showing posts from February, 2003

Bootstrap 3 Align Right Code Example

Example 1: bootstrap align right To aligning div in bootstrap you can use bootstrap classes like 1. float-left 2. float-right 3. float-none < div class = " float-left " > Float left on all viewport sizes </ div > < br > < div class = " float-right " > Float right on all viewport sizes </ div > < br > < div class = " float-none " > Don't float on all viewport sizes </ div > Example 2: bootstrap align right button < div class = " float-sm-left " > Float left on viewports sized SM (small) or wider </ div > < br > < div class = " float-md-left " > Float left on viewports sized MD (medium) or wider </ div > < br > < div class = " float-lg-left " > Float left on viewports sized LG (large) or wider </ div > < br > < div class = " float-xl-left " > Float left on viewports sized XL (extra-large) o

Better Way To Detect If A String Contains Multiple Words

Answer : I'd create a regular expression from the words: Pattern pattern = Pattern.compile("(?=.*adsf)(?=.*qwer)"); if (pattern.matcher(input).find()) { execute(); } For more details, see this answer: https://stackoverflow.com/a/470602/660143 Editors note: Despite being heavily upvoted and accepted, this does not function the same as the code in the question. execute is called on the first match, like a logical OR. You could use an array: String[] matches = new String[] {"adsf", "qwer"}; bool found = false; for (String s : matches) { if (input.contains(s)) { execute(); break; } } This is efficient as the one posted by you but more maintainable. Looking for a more efficient solution sounds like a micro optimization that should be ignored until proven to be effectively a bottleneck of your code, in any case with a huge string set the solution could be a trie. In Java 8 you could do public static boolean containsWords(S

Client Denied By Server Configuration

Answer : In my case, I modified directory tag. From <Directory "D:/Devel/matysart/matysart_dev1"> Allow from all Order Deny,Allow </Directory> To <Directory "D:/Devel/matysart/matysart_dev1"> Require local </Directory> And it seriously worked. It's seems changed with Apache 2.4.2. For me the following worked which is copied from example in /etc/apache2/apache2.conf : <Directory /srv/www/default> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory> Require all granted option is the solution for the first problem example in wiki.apache.org page dedicated for this issue for Apache version 2.4+. More details about Require option can be found on official apache page for mod_authz module and on this page too. Namely: Require all granted -> Access is allowed unconditionally. The error "client denied by server configuration" generally means that s

Binary To Decimal Python Code Example

Example 1: binary to decimal in python int ( binaryString , 2 ) Example 2: how to convert decimal to binary python a = 5 #this prints the value of "a" in binary print ( bin ( a ) ) Example 3: python binary string to int >> > int ( '11111111' , 2 ) 255 Example 4: convert binary string to base 10 value in python def getBaseTen ( binaryVal ) : count = 0 #reverse the string binaryVal = binaryVal [ : : - 1 ] #go through the list and get the value of all 1's for i in range ( 0 , len ( binaryVal ) ) : if ( binaryVal [ i ] == "1" ) : count += 2 ** i return count Example 5: binary to decimal python format ( decimal , "b" )

How To Increase Line Spacing In Flutter Text Code Example

Example: havong space between lines of richtext in flutter Text ( "Hello World" , style: TextStyle ( height: 1.2 // the height between text, default is 1.0 letterSpacing: 1.0 // the white space between letter, default is 0.0 )) ;

Bootstrap 3 Breakpoints Code Example

Example 1: bootstrap media query breakpoints // Extra small devices (portrait phones, less than 576px) @ media ( max - width : 575.98 px ) { ... } // Small devices (landscape phones, 576px and up) @ media ( min - width : 576 px ) and ( max - width : 767.98 px ) { ... } // Medium devices (tablets, 768px and up) @ media ( min - width : 768 px ) and ( max - width : 991.98 px ) { ... } // Large devices (desktops, 992px and up) @ media ( min - width : 992 px ) and ( max - width : 1199.98 px ) { ... } // Extra large devices (large desktops, 1200px and up) @ media ( min - width : 1200 px ) { ... } Example 2: bootstrap media queries /* Answer to: "bootstrap media queries" */ /* Since Bootstrap is developed to be mobile first, the use a handful of media queries to create sensible breakpoints for their layouts and interfaces. These breakpoints are mostly based on minimum viewport widths and allow scaling up elements as the

56cm To Inches Code Example

Example: cm to inches const cm = 1 ; console . log ( ` cm: ${ cm } = in: ${ cmToIn ( cm ) } ` ) ; function cmToIn ( cm ) { var in = cm / 2.54 ; return in ; }

Arduino Millis() In Stm32

Answer : SysTick is an ARM core peripheral provided for this purpose. Adapt this to your needs: Firstly, initialise it // Initialise SysTick to tick at 1ms by initialising it with SystemCoreClock (Hz)/1000 volatile uint32_t counter = 0; SysTick_Config(SystemCoreClock / 1000); Provide an interrupt handler. Your compiler may need interrupt handlers to be decorated with additional attributes. SysTick_Handler(void) { counter++; } Here's your millis() function, couldn't be simpler: uint32_t millis() { return counter; } Some caveats to be aware of. SysTick is a 24 bit counter. It will wrap on overflow. Be aware of that when you're comparing values or implementing a delay method. SysTick is derived from the processor core clock. If you mess with the core clock, for example slowing it down to save power then the SysTick frequency must be manually adjusted as well. You could use HAL_GetTick(): this function gets current SysTick counter value (increment

Bootstrap 4 Vertical Row Code Example

Example 1: bootstrap 4 center div < div class = "d-flex justify-content-start" > . . . < / div > < div class = "d-flex justify-content-end" > . . . < / div > < div class = "d-flex justify-content-center" > . . . < / div > < div class = "d-flex justify-content-between" > . . . < / div > < div class = "d-flex justify-content-around" > . . . < / div > Example 2: bootstrap column vertical align < span class = "align-baseline" > baseline < / span > < span class = "align-top" > top < / span > < span class = "align-middle" > middle < / span > < span class = "align-bottom" > bottom < / span > < span class = "align-text-top" > text - top < / span > < span class = "align-text-bottom" > text - bottom < / span >

Celery: Daemonic Processes Are Not Allowed To Have Children

Answer : billiard and multiprocessing are different libraries - billiard is the Celery project's own fork of multiprocessing . You will need to import billiard and use it instead of multiprocessing However the better answer is probably that you should refactor your code so that you spawn more Celery tasks instead of using two different ways of distributing your work. You can do this using Celery canvas from celery import group @app.task def sleepawhile(t): print("Sleeping %i seconds..." % t) time.sleep(t) return t def work(num_procs): return group(sleepawhile.s(randint(1, 5)) for x in range(num_procs)]) def test(self): my_group = group(work(randint(1, 5)) for x in range(5)) result = my_group.apply_async() result.get() I've attempted to make a working version of your code that uses canvas primitives instead of multiprocessing. However since your example was quite artificial it's not easy to come up with something th

Android - Can Thief Unlock Stolen Phone That Was Locked By Android Device Manager?

Answer : The answer is almost certainly yes. Someone could probably get past it in one way or another. (They could probably just use odin on a samsung device for example. Though I have never done something like that myself.) If you have sensitive data on there then a remote wipe might be the best thing. Did you report it stolen with your carrier? They could report the ESN / IMEI as stolen so at the very least the thief probably wouldn't be able to sell it. Of course I do not know your exact situation. If you know for sure it was stolen and not lost could the police recover it from the thief? Either way best of luck to you. It would depend on the phone, but as firesoul453 said in his answer, almost certainly yes. Locking the phone is intended to protect the data - In other words: the thief cannot get your data off of the phone. Due to the nature of the android system though, it's usually very easy to wipe out the data on the phone. Usually this can be done via r

Calculate Distance Between Two Latitude-longitude Points? (Haversine Formula)

Answer : This link might be helpful to you, as it details the use of the Haversine formula to calculate the distance. Excerpt: This script [in Javascript] calculates great-circle distances between the two points – that is, the shortest distance over the earth’s surface – using the ‘Haversine’ formula. function getDistanceFromLatLonInKm(lat1,lon1,lat2,lon2) { var R = 6371; // Radius of the earth in km var dLat = deg2rad(lat2-lat1); // deg2rad below var dLon = deg2rad(lon2-lon1); var a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2rad(lat1)) * Math.cos(deg2rad(lat2)) * Math.sin(dLon/2) * Math.sin(dLon/2) ; var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); var d = R * c; // Distance in km return d; } function deg2rad(deg) { return deg * (Math.PI/180) } I needed to calculate a lot of distances between the points for my project, so I went ahead and tried to optimize the code, I have found here. On average in different bro

Std::cout Example

Example 1: std cout c++ # include <iostream> using std :: cout ; int main ( ) { cout << "Hello world" ; return 0 ; } Example 2: std::cout and cout //c++ cout and std :: cout both are same , but the only difference is that if we use cout , namespace std must be used in the program or if you are not using std namespace then you should use std :: cout .

Can I Safely Use A PSU With An ATX 12v 4-pin For A Board That Has A EPS 12v 8-pin?

Image
Answer : Information: Page 16 of the manual to the motherboard says that the 8-pin connector is for supplying power to the CPU. Method 1: If you look at the pinout of the 8-pin socket and the 4-pin cable (figures 1 and 2 below respectively), you will notice that physically, it should be compatible. I found a page (figure 3) that indicates that it can be done, but strongly advises using a proper 8-pin cable. This makes sense because the connector is generally for providing the CPU with extra power (as opposed to any power), so while it may work, the system may suddenly shut down if CPU usage goes up to 100% (eg while doing a virus-scan, watching YouTube videos, etc.) Method 2: Another option I have found is some discussions (like this one) about using an adapter (figure 4) to connect the 4-pin cable to both halves of the 8-pin connector. In fact, there are plenty such adapters on eBay for as little as $1 (and free shipping). Newegg also has a couple. Of course the probl

AWS ECS Private And Public Services

Image
Answer : The combination of both AWS load balancer ( for public access) and Amazon ECS Service Discovery ( for internal communication) is the perfect choice for the web application. Built-in service discovery in ECS is another feature that makes it easy to develop a dynamic container environment without needing to manage as many resources outside of your application. ECS and Route 53 combine to provide highly available, fully managed, and secure service discovery Service discovery is a technique for getting traffic from one container to another using the containers direct IP address, instead of an intermediary like a load balancer. It is suitable for a variety of use cases: Private, internal service discovery Low latency communication between services Long lived bidirectional connections, such as gRPC. Yes, you can use AWS ECS service discovery having all services in a private subnet to enable communication between them. This makes it possible for an E

No Assembly Found Containing An OwinStartupAttribute. - No Assembly Found Containing A Startup Or [AssemblyName].Startup Class. Code Example

Example: No assembly found containing an OwinStartupAttribute. # Add this to your web config file < add key = ”owin:AutomaticAppStartup” value = ”false” / >

Android ADB Stop Application Command Like "force-stop" For Non Rooted Device

Image
Answer : The first way Needs root Use kill : adb shell ps => Will list all running processes on the device and their process ids adb shell kill <PID> => Instead of <PID> use process id of your application The second way In Eclipse open DDMS perspective. In Devices view you will find all running processes. Choose the process and click on Stop . The third way It will kill only background process of an application. adb shell am kill [options] <PACKAGE> => Kill all processes associated with (the app's package name). This command kills only processes that are safe to kill and that will not impact the user experience. Options are: --user | all | current: Specify user whose processes to kill; all users if not specified. The fourth way Needs root adb shell pm disable <PACKAGE> => Disable the given package or component (written as "package/class"). The fifth way Note that run-as is only supported for apps t

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 ; }

Bootstrap 4 Media Queries Code Example

Example 1: bootstrap 4 mobile media query // Extra small devices (portrait phones, less than 576px) @media (max-width: 575.98px) { ... } // Small devices (landscape phones, 576px and up) @media (min-width: 576px) and (max-width: 767.98px) { ... } // Medium devices (tablets, 768px and up) @media (min-width: 768px) and (max-width: 991.98px) { ... } // Large devices (desktops, 992px and up) @media (min-width: 992px) and (max-width: 1199.98px) { ... } // Extra large devices (large desktops, 1200px and up) @media (min-width: 1200px) { ... } Example 2: bootstrap media queries /* Large desktops and laptops */ @media (min-width: 1200px) { } /* Landscape tablets and medium desktops */ @media (min-width: 992px) and (max-width: 1199px) { } /* Portrait tablets and small desktops */ @media (min-width: 768px) and (max-width: 991px) { } /* Landscape phones and portrait tablets */ @media (max-width: 767px) { } /* Portrait phones and smaller */ @media (max-width: 480px) { } Example

Call Another Rest Api From My Server In Spring-Boot

Answer : This website has some nice examples for using spring's RestTemplate. Here is a code example of how it can work to get a simple object: private static void getEmployees() { final String uri = "http://localhost:8080/springrestexample/employees.xml"; RestTemplate restTemplate = new RestTemplate(); String result = restTemplate.getForObject(uri, String.class); System.out.println(result); } Instead of String you are trying to get custom POJO object details as output by calling another API/URI , try the this solution. I hope it will be clear and helpful for how to use RestTemplate also, In Spring Boot , first we need to create Bean for RestTemplate under the @Configuration annotated class. You can even write a separate class and annotate with @Configuration like below. @Configuration public class RestTemplateConfig { @Bean public RestTemplate restTemplate(RestTemplateBuilder builder) { return builder.build(); } } The

Beacon Range Minecraft Code Example

Example 1: beacon radius minecraft Minecraft Beacon Range: Level 1 = 20 Blocks (Needs 9 blocks) - Bonus: Speed/Haste Level 2 = 30 Blocks (Needs 34 blocks) - Bonus: Jump Boost/Resistance Level 3 = 40 Blocks (Needs 83 blocks) - Bonus: Strength Level 4 = 50 Blocks (Needs 164 Blocks) - Bonus: Regeneration II/ Other Boost II You're welcome ^^ Example 2: blocks for beacon to make a full powered beacon you need 164 blocks of any type of goodie Example 3: full beacon size who ever typed the answer in grepper answer is a legend