Tutorial by Examples: co

StyledDocuments generally do not implement clone, and so have to copy them in a different way if that is necessary. try { //Initialization DefaultStyledDocument sourceDoc = new DefaultStyledDocument(); DefaultStyledDocument destDoc = new DefaultStyledDocument(); ...
Usually, you have to use git add or git rm to add changes to the index before you can git commit them. Pass the -a or --all option to automatically add every change (to tracked files) to the index, including removals: git commit -a If you would like to also add a commit message you would do: g...
Here's a standalone random number generator that doesn't rely on rand() or similar library functions. Why would you want such a thing? Maybe you don't trust your platform's builtin random number generator, or maybe you want a reproducible source of randomness independent of any particular library ...
Assuming a single source file named main.cpp, the command to compile and link an non-optimized executable is as follows (Compiling without optimization is useful for initial development and debugging, although -Og is officially recommended for newer GCC versions). g++ -o app -Wall main.cpp -O0 T...
A simple two-column layout consists of two fixed-width, floated elements. Note that the sidebar and content area are not the same height in this example. This is one of the tricky parts with multi-column layouts using floats, and requires workarounds to make multiple columns appear to be the same he...
curl -X POST https://api.dropboxapi.com/2/users/get_current_account \ --header "Authorization: Bearer <ACCESS_TOKEN>" <ACCESS_TOKEN> should be replaced with your access token.
#include <stdio.h> #include <curl/curl.h> int main (int argc, char *argv[]) { CURL *curl; CURLcode res; /* In windows, this will init the winsock stuff */ curl_global_init(CURL_GLOBAL_ALL); /* get a curl handle */ curl = curl_ea...
This uses the Dropbox Python SDK to get the user's account information from the Dropbox API. import dropbox dbx = dropbox.Dropbox("<ACCESS_TOKEN>") dbx.users_get_current_account() <ACCESS_TOKEN> should be replaced with the access token.
HTML: <div class="wrapper"> <div class="left-sidebar"> <h1>Left Sidebar</h1> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p> </div> <div class="content"> <h1>Content</h1&g...
JavaScript has two primary ways to represent binary data in the browser. ArrayBuffers/TypedArrays contain mutable (though still fixed-length) binary data which you can directly manipulate. Blobs contain immutable binary data which can only be accessed through the asynchronous File interface. Conver...
In the same module Inside a module named "MyModule", Xcode generates a header named MyModule-Swift.h which exposes public Swift classes to Objective-C. Import this header in order to use the Swift classes: // MySwiftClass.swift in MyApp import Foundation // The class must be `public`...
If MyFramework contains Objective-C classes in its public headers (and the umbrella header), then import MyFramework is all that's necessary to use them from Swift. Bridging headers A bridging header makes additional Objective-C and C declarations visible to Swift code. When adding project files, ...
// use Write trait that contains write() function use std::io::Write; fn main() { std::io::stdout().write(b"Hello, world!\n").unwrap(); } The std::io::Write trait is designed for objects which accept byte streams. In this case, a handle to standard output is acquired with ...
Concatenate strings with the + operator to produce a new string: let name = "John" let surname = "Appleseed" let fullName = name + " " + surname // fullName is "John Appleseed" Append to a mutable string using the += compound assignment operator, or usi...
You have up to 5 sources for git configuration: 6 files: %ALLUSERSPROFILE%\Git\Config (Windows only) (system) <git>/etc/gitconfig, with <git> being the git installation path. (on Windows, it is <git>\mingw64\etc\gitconfig) (system) $XDG_CONFIG_HOME/git/config (Linux/Mac on...
Check whether a string is empty: if str.isEmpty { // do something if the string is empty } // If the string is empty, replace it with a fallback: let result = str.isEmpty ? "fallback string" : str Check whether two strings are equal (in the sense of Unicode canonical equivale...
A Swift String is made of Unicode code points. It can be decomposed and encoded in several different ways. let str = "ที่👌①!" Decomposing Strings A string's characters are Unicode extended grapheme clusters: Array(str.characters) // ["ที่", "👌", "①", ...
Node.js can also be used to create command line utilities. The example below reads the first argument from the command line and prints a Hello message. To run this code on an Unix System: Create a new file and paste the code below. The filename is irrelevant. Make this file executable with chmo...
git reset <filePath>
This layout uses one floated column to create a two-column layout with no defined widths. In this example the left sidebar is "lazy," in that it only takes up as much space as it needs. Another way to say this is that the left sidebar is "shrink-wrapped." The right content column...

Page 8 of 248