Tutorial by Examples: st

import javax.ws.rs.FormParam; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.Response; @Path("hello") public class HelloWorldResource { @POST @Path("/receiveParams") public Response receiveHello(@FormParam("name") String ...
One might argue that there are greater resource hogs in Unity than the humble string, but it is one of the easier aspects to fix early on. String operations build garbage Most string operations build tiny amounts of garbage, but if those operations are called several times over the course of a s...
fastlane is an open source build automation tool for Android and iOS for developers. It reduce your build generation time. It is a command line tool that uses Ruby, so you need Ruby on your computer. Most Macs already have Ruby installed by default. Install fastlane Open a terminal. Run sudo ge...
public function drawDisplayObjectUsingBounds(source:DisplayObject):BitmapData { var bitmapData:BitmapData;//declare a BitmapData var bounds:Rectangle = source.getBounds(source);//get the source object actual size //round bounds to integer pixel values (to aviod 1px str...
Const baseString As String = "Hello World" Dim charLength As Long charLength = Len(baseString) 'charlength = 11
Const baseString As String = "Hello World" Dim byteLength As Long byteLength = LenB(baseString) 'byteLength = 22
When checking if a string is zero-length, it is better practice, and more efficient, to inspect the length of the string rather than comparing the string to an empty string. Const myString As String = vbNullString 'Prefer this method when checking if myString is a zero-length string If Len(mySt...
The following example demonstrates a simple HTTP GET request. http.get() returns an Observable which has the method subscribe. This one appends the returned data to the posts array. var posts = [] getPosts(http: Http):void { this.http.get(`https://jsonplaceholder.typicode.com/posts`) ...
It may be a good idea to encapsulate the HTTP handling logic in its own class. The following class exposes a method for getting Posts. It calls the http.get() method and calls .map on the returned Observable to convert the Response object to a Post object. import {Injectable} from "@angular/co...
One common scenario is to wait for a number of requests to finish before continuing. This can be accomplished using the forkJoin method. In the following example, forkJoin is used to call two methods that return Observables. The callback specified in the .subscribe method will be called when both O...
Const string1 As String = "foo" Const string2 As String = "bar" Const string3 As String = "fizz" Dim concatenatedString As String 'Concatenate two strings concatenatedString = string1 & string2 'concatenatedString = "foobar" 'Concatenate three s...
'Declare and assign a string array Dim widgetNames(2) As String widgetNames(0) = "foo" widgetNames(1) = "bar" widgetNames(2) = "fizz" 'Concatenate with Join and separate each element with a 3-character string concatenatedString = VBA.Strings.Join(widgetNames, &q...
Python uses internal caching for a range of integers to reduce unnecessary overhead from their repeated creation. In effect, this can lead to confusing behavior when comparing integer identities: >>> -8 is (-7 - 1) False >>> -3 is (-2 - 1) True and, using another example: ...
Dim lineOfHyphens As String 'Assign a string with 80 repeated hyphens lineOfHyphens = String$(80, "-")
Dim stringOfSpaces As String 'Assign a string with 255 repeated spaces using Space$ stringOfSpaces = Space$(255) 'Assign a string with 255 repeated spaces using String$ stringOfSpaces = String$(255, " ")
The purpose of this example is to show how we can realize the Strategy pattern using Java 8 functional interfaces. We will start with a simple use case codes in classic Java, and then recode it in the Java 8 way. The example problem we using is a family of algorithms (strategies) that describe dif...
# lib/mix/tasks/mytask.ex defmodule Mix.Tasks.MyTask do use Mix.Task @shortdoc "A simple mix task" def run(_) do IO.puts "YO!" end end Compile and run: $ mix compile $ mix my_task "YO!"
Use defdelegate to define functions that delegate to functions of the same name defined in another module: defmodule Math do defdelegate pi, to: :math end iex> Math.pi 3.141592653589793
First, install socket.io module in node.js application. npm install socket.io --save Basic HTTP Setup The following example attaches socket.io to a plain node.js HTTP server listening on port 3000. var server = require('http').createServer(); var io = require('socket.io')(server); io.on(...
// Uses Windows authentication. Replace the Trusted_Connection parameter with // User Id=...;Password=...; to use SQL Server authentication instead. You may // want to find the appropriate connection string for your server. string connectionString = @"Server=myServer\myInstance;Database=myDa...

Page 130 of 369