Tutorial by Examples: au

String getText(String url) throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); //add headers to the connection, or check the status if desired.. // handle error response code it occurs int responseCode = conn.getResponseCod...
Needed imports: import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; This code will create a clip and play it continuously once started: Clip clip = AudioSystem.getClip(); clip.open(AudioSystem.getAudioInputStream(new URL(filename))); clip.start(); clip.loop(Clip.LOOP_CO...
Pagination p = new Pagination(10); Timeline fiveSecondsWonder = new Timeline(new KeyFrame(Duration.seconds(5), event -> { int pos = (p.getCurrentPageIndex()+1) % p.getPageCount(); p.setCurrentPageIndex(pos); })); fiveSecondsWonder.setCycleCount(Timeline.INDEFINITE); fiveSecondsWon...
This Activity code will provide basic functionality for including a Google Map using a SupportMapFragment. The Google Maps V2 API includes an all-new way to load maps. Activities now have to implement the OnMapReadyCallBack interface, which comes with a onMapReady() method override that is execute...
Annotation @XmlAccessorType determines whether fields/properties will be automatically serialized to XML. Note, that field and method annotations @XmlElement, @XmlAttribute or @XmlTransient take precedence over the default settings. public class XmlAccessTypeExample { @XmlAccessorType(XmlAccessT...
You can't pass an empty sequence into max or min: min([]) ValueError: min() arg is an empty sequence However, with Python 3, you can pass in the keyword argument default with a value that will be returned if the sequence is empty, instead of raising an exception: max([], default=42) ...
if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(geolocationSuccess, geolocationFailure); } else { console.log("Geolocation is not supported by this browser."); } // Function that will be called if the query succeeds var geolocationSuccess = function(pos) {...
In the following example - Database for an auto shop business, we have a list of departments, employees, customers and customer cars. We are using foreign keys to create relationships between the various tables. Live example: SQL fiddle Relationships between tables Each Department may have 0 ...
By default, attempting to lookup the value for a key which does not exist will return nil. You can optionally specify some other value to return (or an action to take) when the hash is accessed with a non-existent key. Although this is referred to as "the default value", it need not be a s...
When the commits on two branches don't conflict, Git can automatically merge them: ~/Stack Overflow(branch:master) » git merge another_branch Auto-merging file_a Merge made by the 'recursive' strategy. file_a | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
With a Frame When you know the exact dimensions you want to set for your label, you can initialize a UILabel with a CGRect frame. Swift let frame = CGRect(x: 0, y: 0, width: 200, height: 21) let label = UILabel(frame: frame) view.addSubview(label) Objective-C CGRect frame = CGRectMake(0, 0,...
Abbreviated from https://blogs.dropbox.com/developers/2013/07/using-oauth-2-0-with-the-core-api/: Step 1: Begin authorization Send the user to this web page, with your values filled in: https://www.dropbox.com/oauth2/authorize?client_id=<app key>&response_type=code&redirect_uri=<...
try { StyledDocument doc = new DefaultStyledDocument(); doc.insertString(0, "This is the beginning text", null); doc.insertString(doc.getLength(), "\nInserting new line at end of doc", null); MutableAttributeSet attrs = new SimpleAttributeSet(); StyleCons...
StyledDocuments generally do not implement clone, and so have to copy them in a different way if that is necessary. try { //Initialization DefaultStyledDocument sourceDoc = new DefaultStyledDocument(); DefaultStyledDocument destDoc = new DefaultStyledDocument(); ...
// autoload.php spl_autoload_register(function ($class) { require_once "$class.php"; }); // Animal.php class Animal { public function eats($food) { echo "Yum, $food!"; } } // zoo.php require 'autoload.php'; $animal = new Animal; $animal->e...
// autoload.php spl_autoload_register(function ($class) { require_once "$class.php"; }); // Animal.php class Animal { public function eats($food) { echo "Yum, $food!"; } } // Ruminant.php class Ruminant extends Animal { public function eat...
Using the AdvancedRTFEditorKit library you can serialize a DefaultStyledDocument to an RTF string. try { DefaultStyledDocument writeDoc = new DefaultStyledDocument(); writeDoc.insertString(0, "Test string", null); AdvancedRTFEditorKit kit = new AdvancedRTFEditorKit(); ...
This is how to send an SMS text message from a US number using Twilio's Node.js SDK. First you need to install the Node.js client using: npm install twilio Then, you have to create an account on their website. Once you have an account, you'll need the account SID and auth token that you can fi...
Consider the below list comprehension: >>> def f(x): ... import time ... time.sleep(.1) # Simulate expensive function ... return x**2 >>> [f(x) for x in range(1000) if f(x) > 10] [16, 25, 36, ...] This results in two calls to f(x) for 1,000 values of...
UPDATE Customers SET Email = "[email protected]" WHERE id = 1; This will fail if an unique index is set on the Email column of Customers. However, alternate behavior can be defined for this case: UPDATE Customers SET Email = "[email protected]" WHERE id = 1 ON DUP...

Page 2 of 37