Tutorial by Examples

Gson gson = new Gson(); //Create a Gson object MyType target = new MyType(); //This is the object you want to convert to JSON String json = gson.toJson(target); // serializes target to Json MyType target2 = gson.fromJson(json, MyType.class); // deserializes json into target2
Sometimes auto may behave not quite as was expected by a programmer. It type deduces the expression, even when type deduction is not the right thing to do. As an example, when proxy objects are used in the code: std::vector<bool> flags{true, true, false}; auto flag = flags[0]; flags.push_...
A _ character in a LIKE clause pattern matches a single character. Query SELECT username FROM users WHERE users LIKE 'admin_'; Result +----------+ | username | +----------+ | admin1 | | admin2 | | admin- | | adminA | +----------+
While using decorator syntax (with the @) is convenient, it also a bit concealing. You can use properties directly, without decorators. The following Python 3.x example shows this: class A: p = 1234 def getX (self): return self._x def setX (self, value): self._x =...
Multi-Editing allows the user to edit text at several locations simultaneously. Multi-Editing is disabled by default: it can be enabled (resp. disabled) in Preferences > Editing by checking (resp. unchecking) the related checkbox. To use Multi-Editing, the user can Ctrl Click on the differe...
Column Editing enables the user to edit text on several lines as a vertical square zone. This feature is enabled by default. There are 3 ways to select a zone to edit: Maintain Alt+Shift and use Up/Down/Left/Right to select the zone to edit with direction keys Maintain Alt+Shift and click on t...
The fact that the garbage collection will clean up does not mean that you should wait for the garbage collection cycle to clean up. In particular you should not wait for garbage collection to close file handles, database connections and open network connections. for example: In the following code...
Any String can be evaluated at runtime. class Example def self.foo :foo end end eval "Example.foo" #=> :foo
Ruby keeps track of local variables and self variable via an object called binding. We can get binding of a scope with calling Kernel#binding and evaluate string inside a binding via Binding#eval. b = proc do local_variable = :local binding end.call b.eval "local_variable" #=&gt...
The instance_eval method is available on all objects. It evaluates code in the context of the receiver: object = Object.new object.instance_eval do @variable = :value end object.instance_variable_get :@variable # => :value instance_eval sets self to object for the duration of the co...
Many languages feature a with statement that allows programmers to omit the receiver of method calls. with can be easily emulated in Ruby using instance_eval: def with(object, &block) object.instance_eval &block end The with method can be used to seamlessly execute methods on object...
It is possible to compress an HTTP response message body more than once. The encoding names should then be separated by a comma in the order in which they were applied. For example, if a message has been compressed via deflate and then gzip, the header should look like: Content-Encoding: deflate, g...
The client first sends a request with an Accept-Encoding header that indicates it supports gzip: GET / HTTP/1.1\r\n Host: www.google.com\r\n Accept-Encoding: gzip, deflate\r\n \r\n The server may then send a response with a compressed response body and a Content-Encoding header that specifies...
R has a set of built in higher order functions: Map, Reduce, Filter, Find, Position, Negate. Map applies a given function to a list of values: words <- list("this", "is", "an", "example") Map(toupper, words) Reduce successively applies a binary functi...
If the file already exists, it will be overwritten! String fileName = "file.zip"; // name of the file String urlToGetFrom = "http://www.mywebsite.com/"; // URL to get it from String pathToSaveTo = "C:\\Users\\user\\"; // where to put it ...
The objects created within a Tiled Map (.tmx), can be simply loaded as bodies into a Box2D world using the Libgdx MapObject class as following: public void buildBuildingsBodies(TiledMap tiledMap, World world, String layer){ MapObjects objects = tiledMap.getLayers().get(layer).getObjects(); ...
Query SELECT st.name, st.percentage, CASE WHEN st.percentage >= 35 THEN 'Pass' ELSE 'Fail' END AS `Remark` FROM student AS st ; Result +--------------------------------+ | name | percentage | Remark | +--------------------------------+ | Isha | 67 | Pas...
class Tutorial extends Game { public ScreenNumberOne screenNumberOne; public void create(){ screenNumberOne = new ScreenNumberOne(this); this.setScreen(screenNumberOne); } public void render() { super.render(); } } That is the basic...
There are a couple of builtin viewports, that each do different things. Here is a list of the names, and their descriptions: Viewport NameDescriptionStretchViewportWill stretch the screen. No black bars, but aspect ratio might be off.FitViewportWill maximize it's size based on the aspect ratio. Cou...
You can make your very own custom viewport. It may have black bars, and it may or may not keep it's aspect ratio, depending on how you program it. A custom viewport would look something like this: public class Tutorial extends Viewport. You would need to override update(width, height), but that's it...

Page 693 of 1336