Tutorial by Examples: f

You'll often want to assign something to an object if it is None, indicating it has not been assigned. We'll use aDate. The simplest way to do this is to use the is None test. if aDate is None: aDate=datetime.date.today() (Note that it is more Pythonic to say is None instead of == None.) ...
Getting set up to use webdev takes some time, if you're doing anything more than tweaking a bit of text. Here are the initial setup steps: $ mkdir site $ cd site $ git clone [email protected]:dart-lang/site-webdev.git $ source ./scripts/env-set.sh $ ./scripts/install-dart-sdk.sh $ ./s...
It is very common for C functions to accept pointers to other functions as arguments. Most popular example is setting an action to be executed when a button is clicked in some GUI toolkit library. It is possible to pass Haskell functions as C callbacks. To call this C function: void event_callback...
Mutable global items (called static mut, highlighting the inherent contradiction involved in their use) are unsafe because it is difficult for the compiler to ensure they are used appropriately. However, the introduction of mutually exclusive locks around data allows memory-safe mutable globals. Th...
Run-time memory management with Rc can be very useful, but it can also be difficult to wrap one's head around, especially if your code is very complex and a single instance is referenced by tens or even hundreds of other types in many scopes. Writing a Drop trait that includes println!("Droppi...
Start with a properly configured gradle project. In your project-local (not top-level) build.gradle append extensions plugin declaration below your Kotlin plugin, on top-level indentation level. buildscript { ... } apply plugin: "com.android.application" ... apply plugin: &quo...
Android extensions also work with multiple Android Product Flavors. For example if we have flavors in build.gradle like so: android { productFlavors { paid { ... } free { ... } } } And for example, only the free flavor has ...
a simple yet very useful command: :g/ending/m$ moves lines containing ending to the end of the buffer. m means move $ means end of buffer, while 0 means beginning of buffer.
The C standard (C11, and C99 too) defines the following flags for printf(): FlagConversionsMeaning-allThe result of the conversion shall be left-justified within the field. The conversion is right-justified if this flag is not specified.+signed numericThe result of a signed conversion shall always ...
There's two ways to create a ByteBuffer, where one can be subdivided again. If you have an already existing byte[], you can "wrap" it into a ByteBuffer to simplify processing: byte[] reqBuffer = new byte[BUFFER_SIZE]; int readBytes = socketInputStream.read(reqBuffer); final ByteBuffer ...
Given a ByteBuffer instance one can write primitive-type data to it using relative and absolute put. The striking difference is that putting data using the relative method keeps track of the index the data is inserted at for you, while the absolute method always requires giving an index to put the d...
Below is an Employer entity class which is mapped to the table employer. As you can see I used fetch = FetchType.LAZY instead of fetch = FetchType.EAGER. The reason I am using LAZY is because Employer may have a lot of properties later on and every time I may not need to know all the fields of an Em...
Lets draw a square in the middle of our view and make it fall to the bottom and stop at the bottom edge collising with the screen bottom boundary. @IBOutlet var animationView: UIView! var squareView:UIView! var collision: UICollisionBehavior! var animator: UIDynamicAnimator! var gravity: UIGr...
To illustrate this, here is a function that has 3 different "wrong" behaviors parameter is completely stupid: we use a user-defined expression parameter has a typo: we use Oracle standard NO_DATA_FOUND error another, but not handled case Feel free to adapt it to your standards: DE...
class MyToolbarControl { public: MyToolbarControl(HWND hWndToolbar, HWND hWndNotifyParent = nullptr) : _Handle(hWndToolbar) { if (hWndNotifyParent == nullptr) { hWndNotifyParent = GetAncestor(hWndToolbar, GA_ROOTOWNER); } SetWindowSubclass( ...
Native string functions are mapped to single byte functions, they do not work well with Unicode. The extentions iconv and mbstring offer some support for Unicode, while the Intl-extention offers full support. Intl is a wrapper for the facto de standard ICU library, see http://site.icu-project.org fo...
Asks the delegate to open a resource specified by a URL, and provides a dictionary of launch options. Example of usage: func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool { return SomeManager.shared.handle( ...
Example of usage: /* Instance of your custom APNs/local notification manager */ private var pushManager: AppleNotificationManager! Registration: func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) { // Called...
To enable Pull to Refresh in a ListView in Xamarin, you first need to specify that it is PullToRefresh enabled and then specify the name of the command you want to invoke upon the ListView being pulled: <ListView x:Name="itemListView" IsPullToRefreshEnabled="True" RefreshComm...
For this example I have a controlled room with a single BLE device enable. Your class should extend CBCentralManagerDelegate. Implement the method: centralManagerDidUpdateState(_ central: CBCentralManager). Use global queue to not freeze the screen while searching for a device. Instantiate CBC...

Page 407 of 457