Tutorial by Examples: c

Sometimes it happens that a file was being tracked by git, but in a later point in time was added to .gitignore, in order to stop tracking it. It's a very common scenario to forget to clean up such files before its addition to .gitignore. In this case, the old file will still be hanging around in th...
To create a patch, there are two steps. Make your changes and commit them. Run git format-patch <commit-reference> to convert all commits since the commit <commit-reference> (not including it) into patch files. For example, if patches should be generated from the latest two commit...
We can use git apply some.patch to have the changes from the .patch file applied to your current working directory. They will be unstaged and need to be committed. To apply a patch as a commit (with its commit message), use git am some.patch To apply all patch files to the tree: git am *.patch...
To list local branches that contain a specific commit or tag git branch --contains <commit> To list local and remote branches that contain a specific commit or tag git branch -a --contains <commit>
impl<K, V> Serialize for MyMap<K, V> where K: Serialize, V: Serialize { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer { let mut state = serializer.serialize_map(Some(self.len()))?; ...
// A Visitor is a type that holds methods that a Deserializer can drive // depending on what is contained in the input data. // // In the case of a map we need generic type parameters K and V to be // able to set the output type correctly, but don't require any state. // This is an example of a...
In build.sbt, make sure you include (here for Mysql and PostGreSQL): "mysql" % "mysql-connector-java" % "5.1.20", "org.postgresql" % "postgresql" % "9.3-1100-jdbc4", "com.typesafe.slick" %% "slick" % "3.1.1&...
First, you have to request authorization of location services let locationManager = CLLocationManager() locationManager.delegate = self locationManager.requestWhenInUseAuthorization() // OR locationManager.requestAlwaysAuthorization() Then you can get all iBeacons' information inside didRange...
Git shortlog is used to summarize the git log outputs and group the commits by author. By default, all commit messages are shown but argument --summary or -s skips the messages and gives a list of authors with their total number of commits. --numbered or -n changes the ordering from alphabetical (...
git log --pretty=format:"%ai" | awk '{print " : "$1}' | sort -r | uniq -c
git log --pretty=oneline |wc -l
for k in `git branch -a | sed s/^..//`; do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" $k --`\\t"$k";done | sort
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \ while read filename; do file "$filename"; done | \ grep -E ': .*text' | sed -E -e 's/: .*//' | \ while read filename; do git blame --line-porcelain "$filename"; done | \ sed -n 's/^author //p' | \ sort | uniq -c | sort -rn
class Example { void method(boolean error) { if (error) { Log.error("Error occurred!"); System.out.println("Error!"); } else { // Use braces since the other block uses braces. System.out.println("No error"); ...
To validate arguments to methods called on a mock, use the ArgumentCaptor class. This will allow you to extract the arguments into your test method and perform assertions on them. This example tests a method which updates the name of a user with a given ID. The method loads the user, updates the na...
NSURL *url = [NSURL URLWithString:@"http://www.example.com/images/apple-tree.jpg"]; NSString *fileName = [url lastPathComponent]; // fileName = "apple-tree.jpg"
Shortcode is a small piece of code that can be added into the WordPress editor and will output something different once the page is published or previewed. Frequently, shortcodes are added to the theme functions.php file, but that's not a good practice as shortcodes are expected to keep working aft...
A function that is declared constexpr is implicitly inline and calls to such a function potentially yield constant expressions. For example, the following function, if called with constant expression arguments, yields a constant expression too: C++11 constexpr int Sum(int a, int b) { return ...
.git/hooks/pre-commit #!/bin/sh if [ -s pom.xml ]; then echo "Running mvn verify" mvn clean verify if [ $? -ne 0 ]; then echo "Maven build failed" exit 1 fi fi
Prior to C++17, when writing a template non-type parameter, you had to specify its type first. So a common pattern became writing something like: template <class T, T N> struct integral_constant { using type = T; static constexpr T value = N; }; using five = integral_constant&l...

Page 389 of 826