Tutorial by Examples: change

Case classes provide a copy method that creates a new object that shares the same fields as the old one, with certain changes. We can use this feature to create a new object from a previous one that has some of the same characteristics. This simple case class to demonstrates this feature: case cla...
To change PS1, you just have to change the value of PS1 shell variable. The value can be set in ~/.bashrc or /etc/bashrc file, depending on the distro. PS1 can be changed to any plain text like: PS1="hello " Besides the plain text, a number of backslash-escaped special characters are s...
# application.rb config.time_zone = 'Eastern Time (US & Canada)' config.active_record.default_timezone = :local
If you want to detect when your user starts or finishes an activity such as walking, running, or any other activity of the DetectedActivityFence class, you can create a fence for the activity that you want to detect, and get notified when your user starts/finishes this activity. By using a Broadcast...
By default, Eloquent models expect for the primary key to be named 'id'. If that is not your case, you can change the name of your primary key by specifying the $primaryKey property. class Citizen extends Model { protected $primaryKey = 'socialSecurityNo'; // ... } Now, any Eloqu...
There are a few changes where instant won't do its trick and a full build and reinstall fo your app will happen just like it used to happen before Instant Run was born. Change the app manifest Change resources referenced by the app manifest Change an Android widget UI element (requires a Clean ...
// Shows the author and commit per line of specified file git blame test.c // Shows the author email and commit per line of specified git blame -e test.c file // Limits the selection of lines by specified range git blame -L 1,10 test.c
// Get the current colors of the gradient. let oldColors = self.gradientLayer.colors // Define the new colors for the gradient. let newColors = [UIColor.red.cgColor, UIColor.yellow.cgColor] // Set the new colors of the gradient. self.gradientLayer.colors = newColors // Initia...
db.posts.find().forEach(function(doc){ if(doc.foo === 'bar'){ db.posts.update({_id: doc._id}, {$set:{'foo':'squee'}}, false, true); } });
public class ChangePasswordActivity extends BaseAppCompatActivity implements ReAuthenticateDialogFragment.OnReauthenticateSuccessListener { @BindView(R.id.et_change_password) EditText mEditText; private FirebaseUser mFirebaseUser; @OnClick(R.id.btn_change_password) void on...
Objective-C UIColor *color = [UIColor redColor]; NSString *textToFind = @"redword"; NSMutableAttributedString *attrsString = [[NSMutableAttributedString alloc] initWithAttributedString:yourLabel.attributedText]; // search for word occurrence NSRange range = [yourLabel.text rangeO...
Strict mode also prevents you from deleting undeletable properties. "use strict"; delete Object.prototype; // throws a TypeError The above statement would simply be ignored if you don't use strict mode, however now you know why it does not execute as expected. It also prevents you fr...
The common error using ssh is to see the error like @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone c...
Given a file file.txt with the following content: line 1 line 2 line 3 You can add a new line using below command sed '/line 2/{x;p;x;}' file.txt The above command will output line 1 line 2 line 3 Explanation: x command is eXchange. sed has a buffer that you can use to store some ...
To change the current bash run these commands export SHELL=/bin/bash exec /bin/bash to change the bash that opens on startup edit .profile and add those lines
class Message DEFAULT_MESSAGE = "Hello, world" def speak(message = nil) if message puts message else puts DEFAULT_MESSAGE end end end The constant DEFAULT_MESSAGE can be changed with the following code: Message::DEFAULT_MESSAGE = "Hullo, wo...
Reflection is useful when it is properly used for right purpose. By using reflection, you can access private variables and re-initialize final variables. Below is the code snippet, which is not recommended. import java.lang.reflect.*; public class ReflectionDemo{ public static void main(St...
Sometimes you want to have a file held in Git but ignore subsequent changes. Tell Git to ignore changes to a file or directory using update-index: git update-index --assume-unchanged my-file.txt The above command instructs Git to assume my-file.txt hasn't been changed, and not to check or repor...
We can change the style of the placeholder by setting attributedPlaceholder (a NSAttributedString). var placeholderAttributes = [String: AnyObject]() placeholderAttributes[NSForegroundColorAttributeName] = color placeholderAttributes[NSFontAttributeName] = font if let placeholder = textField.p...

Page 4 of 10