Tutorial by Examples

Installation Installation of Log4j2 is as simple as putting log4j2 jar in application classpath. Though you might want to customize logs output through additional config file Configuration maven To add log4j to project in maven, add it's dependency: In pom.xml add following dependency: <dep...
Castle Windsor is available via NuGet Use the "Manage NuGet Packages" and search for "castle windsor" To download for Visual Studio 2015 To download for previous versions Use Package Manager Console to execute: Install-Package Castle.Windsor Now you can us...
An F() object represents the value of a model field or annotated column. It makes it possible to refer to model field values and perform database operations using them without actually having to pull them out of the database into Python memory. - F() expressions It is appropriate to use F() obj...
Supposing you have setup a django project, and the settings file is in an app named main, this is how you initialize your code import os, sys # Setup environ sys.path.append(os.getcwd()) os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings") # Setup django imp...
Magento has a powerful set of methods to filter collections. Since there are two types of Objects that can be contained in collections, we must first determine which type of data we are working with before we can filter it. Magento implements a EAV data model for entities such as products and catego...
When we query our data, we often need more than one filter to get the exact data set we are looking for. In SQL, we handle this with AND and OR clauses. We can achieve the same thing with collections. To add an AND clause to your query, just simply add another method call. This will append the seco...
This uses the SwiftyDropbox library to upload a file from a NSFileHandle to the Dropbox account using upload sessions, handling every error case: import UIKit import SwiftyDropbox class ViewController: UIViewController { // filled in later in doUpload: var fileHandle : NSFileHandle?...
var express = require("express"), bodyParser = require("body-parser"), server = express(); //body parser for parsing request body server.use(bodyParser.json()); server.use(bodyParser.urlencoded({ extended: true })); //temperary store for `item` in memory var it...
Sample JSON: { "id": "12345", "type": "android" } Define your request: public class GetDeviceRequest { @SerializedName("deviceId") private String mDeviceId; public GetDeviceRequest(String deviceId) { this....
import curses import traceback try: # -- Initialize -- stdscr = curses.initscr() # initialize curses screen curses.noecho() # turn off auto echoing of keypress on to screen curses.cbreak() # enter break mode where pressing Enter key ...
Use the double negation syntax to check for truthiness of values. All values correspond to a boolean, irrespective of their type. irb(main):001:0> !!1234 => true irb(main):002:0> !!"Hello, world!" (irb):2: warning: string literal in condition => true irb(main):003:0> !...
You do not need to use double negation in if-else statements. if 'hello' puts 'hey!' else puts 'bye!' end The above code prints 'hey!' on the screen.
JSON (JavaScript Object Notation) is a lightweight data interchange format. Many web applications use it to send and receive data. In Ruby you can simply work with JSON. At first you have to require 'json', then you can parse a JSON string via the JSON.parse() command. require 'json' j = '{&q...
You can use JSON together with Ruby symbols. With the option symbolize_names for the parser, the keys in the resulting hash will be symbols instead of strings. json = '{ "a": 1, "b": 2 }' puts JSON.parse(json, symbolize_names: true) >> {:a=>1, :b=>2}
If you can say “YAGNI” (You ain’t gonna need it) about a feature, you better not implement it. There can be a lot of development time saved through focussing onto simplicity. Implementing such features anyway can lead to problems: Problems Overengineering If a product is more complicated than it...
Lets you compose several functions f₀ f₁ … fₙ. It returns a function that will successively apply fₙ to its arguments, then fₙ₋₁ to the result of fₙ and so on. Function are applied from right to left, like for mathematical function composition: (f ∘ g ∘ h)(x) = f(g(h(x))). > ((compose sqrt +) 16...
Returns a partially applied function. > ((curry + 10) 20) 30 curryr can be used when the arguments need to be inserted at the end. In other words, (curryr list 1 2) will produce a function expecting some new-arguments .... When called, that new function will in turn call (list new-arguments ...
Your app can't access your reminders and your calendar without permission. Instead, it must show an alert to user, requesting him/her to grant access to events for the app. To get started, import the EventKit framework: Swift import EventKit Objective-C #import <EventKit/EventKit.h> ...
Accessing the array of calendars To access the array of EKCalendars, we use the calendarsForEntityType method: Swift let calendarsArray = eventStore.calendarsForEntityType(EKEntityType.Event) as! [EKCalendar] Iterating through calendars Just use a simple for loop: Swift for calendar in cale...

Page 813 of 1336