Tutorial by Examples: c

NodeJS executes the module only the first time you require it. Any further require functions will re-use the same Object, thus not executing the code in the module another time. Also Node caches the modules first time they are loaded using require. This reduces the number of file reads and helps to...
The following example shows how to merge two arrays into one associative array, where the key values will be the items of the first array, and the values will be from the second: $array_one = ['key1', 'key2', 'key3']; $array_two = ['value1', 'value2', 'value3']; $array_three = array_combine($ar...
In many environments, you have access to a global console object that contains some basic methods for communicating with standard output devices. Most commonly, this will be the browser's JavaScript console (see Chrome, Firefox, Safari, and Edge for more information). // At its simplest, you can 'l...
Hstore columns can be useful to store settings. They are available in PostgreSQL databases after you enabled the extension. class CreatePages < ActiveRecord::Migration[5.0] def change create_table :pages do |t| enable_extension 'hstore' unless extension_enabled?('hstore') t...
The ng-click directive attaches a click event to a DOM element. The ng-click directive allows you to specify custom behavior when an element of DOM is clicked. It is useful when you want to attach click events on buttons and handle them at your controller. This directive accepts an expression wit...
Get Focus Swift textField.becomeFirstResponder() Objective-C [textField becomeFirstResponder]; Resign Swift textField.resignFirstResponder() Objective-C [textField resignFirstResponder];
vagrant up By default the box will be provisioned.
vagrant up --no-provision
F# allow existing types to be extended with new static functions. type System.String with static member EqualsCaseInsensitive (a, b) = String.Equals(a, b, StringComparison.OrdinalIgnoreCase) This new function can be invoked like this: let x = String.EqualsCaseInsensitive("abc", &...
Modules can be used to add new functions to existing Modules and Types. namespace FSharp.Collections module List = let pair item1 item2 = [ item1; item2 ] The new function can then be called as if it was an original member of List. open FSharp.Collections module Testing = le...
[<Measure>] type m // meters [<Measure>] type cm // centimeters // Conversion factor let cmInM = 100<cm/m> let distanceInM = 1<m> let distanceInCM = distanceInM * cmInM // 100<cm> // Conversion function let cmToM (x : int<cm>) = x / 100<cm/m> l...
from struct import pack print(pack('I3c', 123, b'a', b'b', b'c')) # b'{\x00\x00\x00abc'
from struct import unpack print(unpack('I3c', b'{\x00\x00\x00abc')) # (123, b'a', b'b', b'c')
Download and install Xamarin Studio Community. Open Xamarin Studio. Click File → New → Solution. Click .NET → Console Project and choose C#. Click Next to proceed. Enter the Project Name and Browse... for a Location to Save and then click Create. The newly created project w...
HTTP requests are made through the WSClient class, which you can use as an injected parameter into your own classes. import javax.inject.Inject import play.api.libs.ws.WSClient import scala.concurrent.{ExecutionContext, Future} class MyClass @Inject() ( wsClient: WSClient )(implicit ...
Creating the JFrame Creating a window is easy. You just have to create a JFrame. JFrame frame = new JFrame(); Titling the Window You may wish to give your window a title. You can so do by passing a string when creating the JFrame, or by calling frame.setTitle(String title). JFrame frame = new...
A component is some sort of user interface element, such as a button or a text field. Creating a Component Creating components is near identical to creating a window. Instead of creating a JFrame however, you create that component. For example, to create a JButton, you do the following. JButton b...
Components have various parameters that can be set for them. They vary from component to component, so a good way to see what parameters can be set for components is to start typing componentName.set, and let your IDE's autocomplete (If you use an IDE) suggest methods. The default shortcut in many I...
DescriptionClassButtonJButtonCheckboxJCheckBoxDrop down menu / Combo boxJComboBoxLabelJLabelListJListMenu barJMenuBarMenu in a menu barJMenuItem in a menuJMenuItemPanelJPanelProgress barJProgressBarRadio buttonJRadioButtonScroll barJScrollBarSliderJSliderSpinner / Number pickerJSpinnerTableJTableTre...
Having a button there is all well and good, but what's the point if clicking it does nothing? ActionListeners are used to tell your button, or other component to do something when it is activated. Adding ActionListeners is done as such. buttonA.addActionListener(new ActionListener() { @Overri...

Page 236 of 826