Tutorial by Examples: c

With Git, you can (almost) always turn the clock back Don't be afraid to experiment with commands that rewrite history*. Git doesn't delete your commits for 90 days by default, and during that time you can easily recover them from the reflog: $ git reset @~3 # go back 3 commits $ git reflog c4...
The charset attribute specifies the character encoding for the HTML document and needs to be a valid character encoding (examples include windows-1252, ISO-8859-2, Shift_JIS, and UTF-8). UTF-8 (Unicode) is the most widely used and should be used for any new project. 5 <meta charset="UTF-8...
To refresh the page every five seconds, add this meta element in the head element: <meta http-equiv="refresh" content="5"> CAUTION! While this is a valid command, it is recommended that you do not use it because of its negative effects on user experience. Refreshing the...
git diff 1234abc..6789def # old new E.g.: Show the changes made in the last 3 commits: git diff @~3..@ # HEAD -3 HEAD Note: the two dots (..) is optional, but adds clarity. This will show the textual difference between the commits, regardless of where they are in the tree.
This error appears while trying to update or delete records without including the WHERE clause that uses the KEY column. To execute the delete or update anyway - type: SET SQL_SAFE_UPDATES = 0; To enable the safe mode again - type: SET SQL_SAFE_UPDATES = 1;
Firstly, make sure that the agent being used has the following attributes in the Manifest.mf: Can-Redefine-Classes: true Can-Retransform-Classes: true Starting a java agent will let the agent access the class Instrumentation. With Instrumentation you can call addTransformer(ClassFileTransformer...
The Premain class will contain the method "premain(String agentArgs Instrumentation inst)" Here is an example: import java.lang.instrument.Instrumentation; public class PremainExample { public static void premain(String agentArgs, Instrumentation inst) { System.out.print...
fn main() { let english = "Hello, World!"; println!("{}", &english[0..5]); // Prints "Hello" println!("{}", &english[7..]); // Prints "World!" } Note that we need to use the & operator here. It takes a reference and ...
A very useful feature of Swift 2.2 is having the ability of extending protocols. It works pretty much like abstract classes when regarding a functionality you want to be available in all the classes that implements some protocol (without having to inherit from a base common class). protocol FooPro...
// This example creates a macro `set!` that functions similarly to the built-in // macro vec! use std::collections::HashSet; macro_rules! set { ( $( $x:expr ),* ) => { // Match zero or more comma delimited items { let mut temp_set = HashSet::new(); // Create a ...
Improper use of pointers are frequently a source of bugs that can include security bugs or program crashes, most often due to segmentation faults. Not checking for allocation failures Memory allocation is not guaranteed to succeed, and may instead return a NULL pointer. Using the returned value, w...
let list1 = [ 1; 2 ] let list2 = [ 1 .. 100 ] // Accessing an element printfn "%A" list1.[0] // Pattern matching let rec patternMatch aList = match aList with | [] -> printfn "This is an empty list" | head::tail -> printfn "This list consists o...
Create a .gitattributes file in the project root containing: * text=auto This will result in all text files (as identified by Git) being committed with LF, but checked out according to the host operating system default. This is equivalent to the recommended core.autocrlf defaults of: input o...
__construct() is the most common magic method in PHP, because it is used to set up a class when it is initialized. The opposite of the __construct() method is the __destruct() method. This method is called when there are no more references to an object that you created or when you force its deletion...
When contributors add to a project from different machines or operating systems, it may happen that they use different email addresses or names for this, which will fragment contributor lists and statistics. Running git shortlog -sn to get a list of contributors and the number of commits by them co...
Generally speaking, empty commits (or commits with state that is identical to the parent) is an error. However, when testing build hooks, CI systems, and other systems that trigger off a commit, it's handy to be able to easily create commits without having to edit/touch a dummy file. The --allow-e...
It's a very common extension that allows type classes with multiple type parameters. You can think of MPTC as a relation between types. {-# LANGUAGE MultiParamTypeClasses #-} class Convertable a b where convert :: a -> b instance Convertable Int Float where convert i = fromIntegr...
Regular instances require: All instance types must be of the form (T a1 ... an) where a1 ... an are *distinct type variables*, and each type variable appears at most once in the instance head. That means that, for example, while you can create an instance for [a] you can't create an instance f...
A syntactic extension that allows applying the tuple constructor (which is an operator) in a section way: (a,b) == (,) a b -- With TupleSections (a,b) == (,) a b == (a,) b == (,b) a N-tuples It also works for tuples with arity greater than two (,2,) 1 3 == (1,2,3) Mapping This can be u...
An extension that allows you to use Unicode characters in lieu of certain built-in operators and names. ASCIIUnicodeUse(s)::∷has type->→function types, lambdas, case branches, etc.=>⇒class constraintsforall∀explicit polymorphism<-←do notation*★the type (or kind) of types (e.g., Int :: ★)&g...

Page 96 of 826