Tutorial by Examples: ce

if [[ -r $filename ]]; then echo "$filename is a readable file" fi if [[ -w $filename ]]; then echo "$filename is a writable file" fi if [[ -x $filename ]]; then echo "$filename is an executable file" fi These tests take permissions and ownership into a...
slice = append(slice, "hello", "world")
We can illustrate this problem with the following pseudo-code function foo() { global $bob; $bob->doSomething(); } Your first question here is an obvious one Where did $bob come from? Are you confused? Good. You've just learned why globals are confusing and considered a bad p...
NSArray *myColors = @[@"Red", @"Green", @"Blue", @"Yellow"]; // Preceding is the preferred equivalent to [NSArray arrayWithObjects:...] Getting a single item The objectAtIndex: method provides a single object. The first object in an NSArray is index 0. Si...
Subpatterns can be referenced with their relative group number: (?-1) will recurse into the previous group (?+1) will recurse into the next group Also usable with the \g<N> syntax.
Generators can be used to represent infinite sequences: def integers_starting_from(n): while True: yield n n += 1 natural_numbers = integers_starting_from(1) Infinite sequence of numbers as above can also be generated with the help of itertools.count. The above code cou...
As you may (or not) know, you can reference a capture group with: $1 1 being the group number. In the same way, you can reference a named capture group with: ${name} \{name} g\{name} Let's take the preceding example and replace the matches with The hero of the story is a ${subject}. T...
A reference cycle (or retain cycle) is so named because it indicates a cycle in the object graph: Each arrow indicates one object retaining another (a strong reference). Unless the cycle is broken, the memory for these objects will never be freed. A retain cycle is created when two instances of ...
To instantiate Foldable you need to provide a definition for at least foldMap or foldr. data Tree a = Leaf | Node (Tree a) a (Tree a) instance Foldable Tree where foldMap f Leaf = mempty foldMap f (Node l x r) = foldMap f l `mappend` f x `mappend` foldMap f r fo...
Implementations of traverse usually look like an implementation of fmap lifted into an Applicative context. data Tree a = Leaf | Node (Tree a) a (Tree a) instance Traversable Tree where traverse f Leaf = pure Leaf traverse f (Node l x r) = Node <$> traverse f l <*...
The standard (section 23.3.7) specifies that a specialization of vector<bool> is provided, which optimizes space by packing the bool values, so that each takes up only one bit. Since bits aren't addressable in C++, this means that several requirements on vector are not placed on vector<bool...
C11 C11 introduced support for multiple threads of execution, which affords the possibility of data races. A program contains a data race if an object in it is accessed1 by two different threads, where at least one of the accesses is non-atomic, at least one modifies the object, and program seman...
Mark your UIView subclass as an accessible element so that it is visible to VoiceOver. myView.isAccessibilityElement = YES; Ensure that the view speaks a meaningful label, value, and hint. Apple provides more details on how to choose good descriptions in the Accessibility Programming Guide.
The accessibility frame is used by VoiceOver for hit testing touches, drawing the VoiceOver cursor, and calculating where in the focused element to simulate a tap when the user double-taps the screen. Note that the frame is in screen coordinates! myElement.accessibilityFrame = frameInScreenCoordina...
Announcements are useful for alerting users to events that don’t require any interaction, such as “screen locked” or “finished loading.” Use a more specific announcement to notify users of screen changes or more minor layout changes. UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotifi...
VoiceOver can navigate many apps on iOS because most UIKit classes implement UIAccessibilityProtocol. Features that don’t represent onscreen elements using UIView, including apps that leverage Core Graphics or Metal to perform drawing, must describe these elements for accessibility. As of iOS 8.0, t...
It is possible to force the type parameters of a generic class to implement a protocol, for example, Equatable class MyGenericClass<Type: Equatable>{ var value: Type init(value: Type){ self.value = value } func getValue() -> Type{ return self....
There are two Dockerfile directives to specify what command to run by default in built images. If you only specify CMD then docker will run that command using the default ENTRYPOINT, which is /bin/sh -c. You can override either or both the entrypoint and/or the command when you start up the built im...
The getAll() method retrieves all values from the preferences. We can use it, for instance, to log the current content of the SharedPreferences: private static final String PREFS_FILE = "MyPrefs"; public static void logSharedPreferences(final Context context) { SharedPreferences s...
/// <summary> /// This interface can do Foo /// </summary> public interface ICanDoFoo { // ... } /// <summary> /// This Bar class implements ICanDoFoo interface /// </summary> public class Bar : ICanDoFoo { // ... } Result Interface summary Clas...

Page 11 of 134