Posts

Showing posts from November, 2016

Change Baud Rate Serial Monitor Platformio Code Example

Example: platformio serial monitor baud rate In the file platformio.ini add: monitor_speed = 115200

Dfs Library In Python Code Example

Example: dfs python ############### # The Algorithm ( In English ) : # 1 ) Pick any node . # 2 ) If it is unvisited , mark it as visited and recur on all its # adjacent nodes . # 3 ) Repeat until all the nodes are visited , or the node to be # searched is found . # The graph below ( declared as a Python dictionary ) # is from the linked website and is used for the sake of # testing the algorithm . Obviously , you will have your own # graph to iterate through . graph = { 'A' : [ 'B' , 'C' ] , 'B' : [ 'D' , 'E' ] , 'C' : [ 'F' ] , 'D' : [ ] , 'E' : [ 'F' ] , 'F' : [ ] } visited = set ( ) # Set to keep track of visited nodes . ################## # The Algorithm ( In Code ) def dfs ( visited , graph , node ) : if node not in visited : print ( node ) visited . add (

AngularJS Paging With $location.path But No NgView Reload

Answer : Instead of updating the path, just update query param with a page number. set your route to ignore query param changes: .... $routeProvider.when('/foo', {..., reloadOnSearch: false}) .... and in your app update $location with: ... $location.search('page', pageNumber); ... From this blog post: by default all location changes go through the routing process, which updates the angular view. There’s a simple way to short-circuit this, however. Angular watches for a location change (whether it’s accomplished through typing in the location bar, clicking a link or setting the location through $location.path() ). When it senses this change, it broadcasts an event, $locationChangeSuccess , and begins the routing process. What we do is capture the event and reset the route to what it was previously. function MyCtrl($route, $scope) { var lastRoute = $route.current; $scope.$on('$locationChangeSuccess', function(event)

Bootstrap Text Color Classes 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 4 text color < p class = " text-primary " > Text with primary color </ p > < p class = " text-secondary " > Text with secondary color </ p >

C11 In GCC?

Answer : The standard C11 header for threading is <threads.h> , not <thread.h> . See section 7.26 of the N1570 draft. Most of the C standard library, including stdio for example, is not included in the gcc distribution. Instead, gcc depends on whatever runtime library is provided by the operating system. That generally includes both the headers (like <threads.h> ) and the actual code that implements the library. For most Linux systems (or GNU/Linux if you prefer), the library is GNU's glibc; for other systems it will be something else. So the real question is probably when glibc, or whichever C library you're using, will support C11's threading features. glibc adds support for C11 threads in version 2.28. Ubuntu 18.04.1 LTS system currently still uses glibc 2.27. Again, this applies only to implementations using GNU libc, not to all gcc-based implementations. Mentioned by WorldSEnder in a comment. UPDATE: Ubuntu 18.10 (not an LTS (Long Term Su

Check If A String Is A Valid Date Using DateTime.TryParse

Answer : If you want your dates to conform a particular format or formats then use DateTime.TryParseExact otherwise that is the default behaviour of DateTime.TryParse DateTime.TryParse This method tries to ignore unrecognized data , if possible, and fills in missing month, day, and year information with the current date. If s contains only a date and no time, this method assumes the time is 12:00 midnight. If s includes a date component with a two-digit year, it is converted to a year in the current culture's current calendar based on the value of the Calendar.TwoDigitYearMax property. Any leading, inner, or trailing white space character in s is ignored. If you want to confirm against multiple formats then look at DateTime.TryParseExact Method (String, String[], IFormatProvider, DateTimeStyles, DateTime) overload. Example from the same link: string[] formats= {"M/d/yyyy h:mm:ss tt", "M/d/yyyy h:mm tt", "MM

Can Rocket Boots Be Found In Chests?

Answer : No, the Rocket Boots cannot be found in any chests, nor do they drop from anything including shadow orbs, any enemies or bosses. They can only be acquired by purchasing them from the Goblin Tinkerer for 5 gold. Rocket Boots are not dropped by any mob on the game or found in any chests, they are sold by the goblin tinkerer NPC who is usually found in the underground jungle after the goblin invasion has been defeated at least once.

48 Degrees Fahrenheit To Celsius Code Example

Example 1: fahrenheit to celsius formula cels = ( fahr - 32.0 ) * 5.0 / 9.0 ; //Fahr to cels fahr = ( cels * 9.0 / 5.0 ) + 32.0 ; //Cels to fahr Example 2: convert fahrenheit to celsius import java . util . Scanner ; public class Main { public static void main ( String args [ ] ) { Scanner sc = new Scanner ( System . in ) ; int far = sc . nextInt ( ) ; int cel = ( far - 32 ) * 5 / 9 ; System . out . printf ( "%d Fahrenheit is %d Celsius" , far , cel ) ; } }

Cnpj Generator Online Code Example

Example: cnpj generator alguns ai: 87.736.276/0001-10 57.768.821/0001-90 84.577.905/0001-19 57.556.282/0001-25 12.872.344/0001-70

Benefits Of Encapsulation In Java Code Example

Example 1: what is encapsulation java Encapsulation in Java is a mechanism to wrap up variables and methods together as a single unit. It is the process of hiding information details and protecting data and behavior of the object. It is one of the four important OOP concepts. The encapsulate class is easy to test, so it is also better for unit testing. Example 2: encapsulation in java programs // java program on encapsulation class EncapsulationExample { private int ID; private String stuName; private int stuAge; // getter and setter methods public int getStudentID() { return ID; } public String getStudentName() { return stuName; } public int getStudentAge() { return stuAge; } public void setStudentAge(int number) { stuAge = number; } public void setStudentName(String number) { stuName = number; } public void setStudentID(int number) { ID = number; } } public class ExampleForEn

1046, 'No Database Selected' Code Example

Example: mariadb error 1046 (3d000) no database selected USE database_name ;

Capturing Mobile Phone Traffic On Wireshark

Answer : Here are some suggestions: For Android phones, any network : Root your phone, then install tcpdump on it. This app is a tcpdump wrapper that will install tcpdump and enable you to start captures using a GUI. Tip: You will need to make sure you supply the right interface name for the capture and this varies from one device to another, eg -i eth0 or -i tiwlan0 - or use -i any to log all interfaces For Android 4.0+ phones : Android PCAP from Kismet uses the USB OTG interface to support packet capture without requiring root. I haven't tried this app, and there are some restrictions on the type of devices supported (see their page) For Android phones : tPacketCapture uses the Android VPN service to intercept packets and capture them. I have used this app successfully, but it also seems to affect the performance with large traffic volumes (eg video streaming) For IOS 5+ devices, any network : iOS 5 added a remote virtual interface (RVI) facility that lets you use M

Client On Node.js: Uncaught ReferenceError: Require Is Not Defined

Answer : This is because require() does not exist in the browser/client-side JavaScript. Now you're going to have to make some choices about your client-side JavaScript script management. You have three options: Use the <script> tag. Use a CommonJS implementation. It has synchronous dependencies like Node.js Use an asynchronous module definition (AMD) implementation. CommonJS client side-implementations include (most of them require a build step before you deploy): Browserify - You can use most Node.js modules in the browser. This is my personal favorite. Webpack - Does everything (bundles JavaScript code, CSS, etc.). It was made popular by the surge of React, but it is notorious for its difficult learning curve. Rollup - a new contender. It leverages ES6 modules and includes tree-shaking abilities (removes unused code). You can read more about my comparison of Browserify vs (deprecated) Component. AMD implementations include: RequireJS - Very popular

Bootstrap 5 Alpha 1 Code Example

Example: bootstarp 5 < link rel = " stylesheet " href = " https://stackpath.bootstrapcdn.com/bootstrap/5.0.0-alpha2/css/bootstrap.min.css " integrity = " sha384-DhY6onE6f3zzKbjUPRc2hOzGAdEf4/Dz+WJwBvEYL/lkkIsI3ihufq9hk9K4lVoK " crossorigin = " anonymous " >

Bit.ly/sheepbot Code Example

Example: bit.ly/sheepbot Black Sheep Is the best Discord Bot To Ever Exist It's in 1000+ servers You can read more here - http://bit.ly/botsheep

Angular *ngfor Index Code Example

Example 1: ngfor index < ul > < li *ngFor = " let item of items; let i = index " [attr.data-index] = " i " > {{item}} </ li > </ ul > Example 2: ngfor get index < ul > < li *ngFor = " let item of items; let i = index " [attr.data-index] = " i " > {{item}} </ li > </ ul > Example 3: ngfor index /* ngFor with index in angular is used here for generating 'li' element till the studentDetails array length. And also make a note if you are using angular 1 then you have to replace 'let' with '#', but its ok if you are using angular 2 or above. */ < ul > < li *ngFor = " let student of studentDetails; index as i; " [attr.data-index] = " i " > {{student}} </ li > </ ul > /* I hope it will help you. Namaste */