C++11
char *str = "hello world";
str[0] = 'H';
"hello world" is a string literal, so modifying it gives undefined behaviour.
The initialisation of str in the above example was formally deprecated (scheduled for removal from a future version of the standard) in C++03. A num...
pd.read_excel('path_to_file.xls', sheetname='Sheet1')
There are many parsing options for read_excel (similar to the options in read_csv.
pd.read_excel('path_to_file.xls',
sheetname='Sheet1', header=[0, 1, 2],
skiprows=3, index_col=0) # etc.
package {
import flash.display.Sprite;
import flash.events.Event;
public class Viewport extends Sprite {
/** Constructor */
public function Viewport() {
super();
// Listen for added to stage event
addEventListener(Event.ADDED_TO_STAGE, addedToStageHandle...
Output some information about a known remote: origin
git remote show origin
Print just the remote's URL:
git config --get remote.origin.url
With 2.7+, it is also possible to do, which is arguably better than the above one that uses the config command.
git remote get-url origin
chrome.runtime.getManifest() returns the extension's manifest in a form of a parsed object.
This method works both on content scripts and all extension pages, it requires no permissions,
Example, obtaining the extension's version string:
var version = chrome.runtime.getManifest().version;
/**
* @param year Full year as int (ex: 2000).
* @param month Month as int, zero-based (ex: 0=January, 11=December).
*/
function daysInMonth(year:int, month:int):int {
return (new Date(year, ++month, 0)).date;
}
yii migrate/mark 150101_185401 # using timestamp to specify the migration
yii migrate/mark "2015-01-01 18:54:01" # using a string that can be parsed by strtotime()
yii migrate/mark m150101_185401_create_news_table # using full name
yii migrate/mark 13...
First, download the compiler and components.
Next, add Swift to your path. On macOS, the default location for the downloadable toolchain is /Library/Developer/Toolchains. Run the following command in Terminal:
export PATH=/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin:"${PATH}...
Imagine you have the following HTML:
<div>
<label>Name:</label>
John Smith
</div>
And you need to locate the text "John Smith" after the label element.
In this case, you can locate the label element by text and then use .next_sibling property:
from ...
BeautifulSoup has a limited support for CSS selectors, but covers most commonly used ones. Use select() method to find multiple elements and select_one() to find a single element.
Basic example:
from bs4 import BeautifulSoup
data = """
<ul>
<li class="item&quo...
When running from the CLI, PHP exhibits some different behaviours than when run from a web server. These differences should be kept in mind, especially in the case where the same script might be run from both environments.
No directory change When running a script from a web server, the current w...
void doSomething(String... strings) {
for (String s : strings) {
System.out.println(s);
}
}
The three periods after the final parameter's type indicate that the final argument may be passed as an array or as a sequence of arguments. Varargs can be used only in the final argume...
Access ModifierVisibilityInheritancePrivateClass onlyCan't be inheritedNo modifier / PackageIn packageAvailable if subclass in packageProtectedIn packageAvailable in subclassPublicEverywhereAvailable in subclass
There was once a private protected (both keywords at once) modifier that could be appli...
Here is how to make a Heads Up Notification for capable devices, and use a Ticker for older devices.
// Tapping the Notification will open up MainActivity
Intent i = new Intent(this, MainActivity.class);
// an action to use later
// defined as an app constant:
// public static final String ME...
Consider the character class [aeiou]. This character class can be used in a regular expression to match a set of similarly spelled words.
b[aeiou]t matches:
bat
bet
bit
bot
but
It does not match:
bout
btt
bt
Character classes on their own match one and only one character at a time...
beacon = CLBeaconRegion(proximityUUID: <#NSUUID#>, major: <#CLBeaconMajorValue#>, identifier: <#String#>) // listening to all beacons with given UUID and major value
beacon = CLBeaconRegion(proximityUUID: <##NSUUID#>, major: <##CLBeaconMajorValue#>, minor: <##C...
In case your project needs to be based on a specific Symfony version, use the optional second argument of the new command:
# use the most recent version in any Symfony branch
$ symfony new my_project_name 2.8
$ symfony new my_project_name 3.1
# use a specific Symfony version
$ symfony new my_...