Tutorial by Examples: ear

Not everyone agrees on what the most semantically correct method for resource creation is. Thus, your API could accept POST or PUT requests, or either. The server should respond with 201 Created if the resource was successfully created. Pick the most appropriate error code if it was not. For examp...
Another common use of HTTP APIs is to delete an existing resource. This should usually be done using DELETE requests. If the deletion was successful, the server should return 200 OK; an appropriate error code if it was not. If our employee Charlie Smith has left the company and we now want to dele...
'Declare an array of bytes, assign multi-byte character codes, and convert to a string Dim multiByteChars(9) As Byte multiByteChars(0) = 87 multiByteChars(1) = 0 multiByteChars(2) = 111 multiByteChars(3) = 0 multiByteChars(4) = 114 multiByteChars(5) = 0 multiByteChars(6) = 108 multiByteChar...
add filter method in RecyclerView.Adapter: public void filter(String text) { if(text.isEmpty()){ items.clear(); items.addAll(itemsCopy); } else{ ArrayList<PhoneBookItem> result = new ArrayList<>(); text = text.toLower...
We can easily separate distribution specific tasks and variables into different dedicated .yml files. Ansible helps us to automatically identify the target hosts distribution via {{ ansible_distribution }} and {{ ansible_distribution_version }}, so we just have to name the distribution dedicated .y...
Command line arguments passed to awk are stored in the internal array ARGV of ARGC elements. The first element of the array is the program name. For example: awk 'BEGIN { for (i = 0; i < ARGC; ++i) { printf "ARGV[%d]=\"%s\"\n", i, ARGV[i] } }' arg1 arg2 arg3 ...
The difference in months between two dates can be found using the MONTHS_BETWEEN( date1, date2 ): SELECT MONTHS_BETWEEN( DATE '2016-03-10', DATE '2015-03-10' ) AS difference FROM DUAL; Outputs: DIFFERENCE ---------- 12 If the difference includes part months then it will return the ...
Strings can be assigned directly to byte arrays and visa-versa. Remember that Strings are stored in a Multi-Byte Character Set (see Remarks below) so only every other index of the resulting array will be the portion of the character that falls within the ASCII range. Dim bytes() As Byte Dim exampl...
Subroutine arguments in Perl are passed by reference, unless they are in the signature. This means that the members of the @_ array inside the sub are just aliases to the actual arguments. In the following example, $text in the main program is left modified after the subroutine call because $_[0] in...
Often in R you'll want to know things about an object or variable you're working with. This can be useful when reading someone else's code or even your own, especially when using packages that are new to you. Suppose we create a variable a: a <- matrix(1:9, 3, 3) What data type is this? Yo...
Hierarchy - LinearLayout(horizontal) - ImageView - LinearLayout(vertical) - TextView - TextView Code LinearLayout rootView = new LinearLayout(context); rootView.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)); rootView.s...
The year, month or day components of a DATE data type can be found using the EXTRACT( [ YEAR | MONTH | DAY ] FROM datevalue ) SELECT EXTRACT (YEAR FROM DATE '2016-07-25') AS YEAR, EXTRACT (MONTH FROM DATE '2016-07-25') AS MONTH, EXTRACT (DAY FROM DATE '2016-07-25') AS DAY FROM D...
Rebasing when pulling If you are pulling in fresh commits from the remote repository and you have local changes on the current branch then git will automatically merge the remote version and your version. If you would like to reduce the number of merges on your branch you can tell git to rebase you...
var regExp = new RegExp(r"(\w+)"); var str = "Parse my string"; Iterable<Match> matches = regExp.allMatches(str); It's a good idea to use "raw strings" (prefix with r) when writing regular expressions so you can use unescaped backslashes in your expression. ...
#!/bin/bash echo $(( 1 + 2 )) Output: 3 # Using variables #!/bin/bash var1=4 var2=5 ((output=$var1 * $var2)) printf "%d\n" "$output" Output: 20
#!/bin/bash expr 1 + 2 Output: 3
Press controlr and type a pattern. For example, if you recently executed man 5 crontab, you can find it quickly by starting to type "crontab". The prompt will change like this: (reverse-i-search)`cr': man 5 crontab The `cr' there is the string I typed so far. This is an incremental s...
genRandom creates a stream of random numbers that has a one in four chance of terminating each time it's called. def genRandom: Stream[String] = { val random = scala.util.Random.nextFloat() println(s"Random value is: $random") if (random < 0.25) { Stream.empty[String] ...
db.posts.find().forEach(function(doc){ if(doc.arrayOfObjects){ // the false, true at the end refers to $upsert, and $multi, respectively db.accounts.update({_id: doc._id}, {$unset: {'arrayOfObjects': "" }}, false, true); } });
5 Input type search is used for textual search. It will add magnifier symbol next to space for text on most browsers <input type="search" name="googlesearch">

Page 8 of 21