Tutorial by Examples: di

Current date and time can be found with getCurrentTime: import Data.Time print =<< getCurrentTime -- 2016-08-02 12:05:08.937169 UTC Alternatively, just the date is returned by fromGregorian: fromGregorian 1984 11 17 -- yields a Day
Given a Day, we can perform simple arithmetic and comparisons, such as adding: import Data.Time addDays 1 (fromGregorian 2000 1 1) -- 2000-01-02 addDays 1 (fromGregorian 2000 12 31) -- 2001-01-01 Subtract: addDays (-1) (fromGregorian 2000 1 1) -- 1999-12-31 addDays (-1) (fromGregorian...
function footag_func( $atts ) { return "foo = {$atts['foo']}"; } add_shortcode( 'footag', 'footag_func' ); In plugins we can add shortcodes using the add_shortcode function. The shortcode can be used in any Wordpress page or post just by enclosing it in square brackets. [footag...
DisplayName sets display name for a property, event or public void method having zero (0) arguments. public class Employee { [DisplayName(@"Employee first name")] public string FirstName { get; set; } } Simple usage example in XAML application <Window x:Class="WpfA...
EditableAttribute sets whether users should be able to change the value of the class property. public class Employee { [Editable(false)] public string FirstName { get; set; } } Simple usage example in XAML application <Window x:Class="WpfApplication.MainWindow" ...
For complete control over a new Chart and Series object (especially for a dynamic Series name), you must resort to modifying the SERIES formula directly. The process to set up the Range objects is straightforward and the main hurdle is simply the string building for the SERIES formula. The SERIES ...
Code snippet: import java.util.Set; public class ThreadStatus { public static void main(String args[]) throws Exception { for (int i = 0; i < 5; i++){ Thread t = new Thread(new MyThread()); t.setName("MyThread:" + i); t.start(); ...
x = np.random.random([100,100]) x.tofile('/path/to/dir/saved_binary.npy') y = fromfile('/path/to/dir/saved_binary.npy') z = y.reshape(100,100) all(x==z) # Output: # True
The function np.loadtxt can be used to read csv-like files: # File: # # Col_1 Col_2 # 1, 1 # 2, 4 # 3, 9 np.loadtxt('/path/to/dir/csvlike.txt', delimiter=',', comments='#') # Output: # array([[ 1., 1.], # [ 2., 4.], # [ 3., 9.]]) The same file could be read ...
# example data DT = data.table(iris) To modify factor levels by reference, use setattr: setattr(DT$Species, "levels", c("set", "ver", "vir") # or DT[, setattr(Species, "levels", c("set", "ver", "vir"))] The sec...
Use rewind to restart the enumerator. ℕ = Enumerator.new do |yielder| x = 0 loop do yielder << x x += 1 end end ℕ.next # => 0 ℕ.next # => 1 ℕ.next # => 2 ℕ.rewind ℕ.next # => 0
$ mkdir backup_download_directory && cd !#:1 mkdir backup_download_directory && cd backup_download_directory This will substitute the Nth argument of the current command. In the example !#:1 is replaced with the first argument, i.e. backup_download_directory.
ActionMailer also allows attaching files. attachments['filename.jpg'] = File.read('/path/to/filename.jpg') By default, attachments will be encoded with Base64. To change this, you can add a hash to the attachments method. attachments['filename.jpg'] = { mime_type: 'application/gzip', enco...
Using Ubuntu you have different ways to read a text file, all similar but useful in different context. cat This is the simplest way to read a text file; it simply output the file content inside the terminal. Be careful: if the file is huge, it could take some time to complete the printing process!...
public static string CreateBLOBContainer(string containerName) { try { string result = string.Empty; CloudMediaContext mediaContext; mediaContext = new CloudMediaContext(mediaServicesAccountName, mediaServicesAccou...
With a clustered index the leaf pages contain the actual table rows. Therefore, there can be only one clustered index. CREATE TABLE Employees ( ID CHAR(900), FirstName NVARCHAR(3000), LastName NVARCHAR(3000), StartYear CHAR(900) ) GO CREATE CLUSTERED INDEX IX_Clustered O...
Non-clustered indexes have a structure separate from the data rows. A non-clustered index contains the non-clustered index key values and each key value entry has a pointer to the data row that contains the key value. There can be maximum 999 non-clustered index on SQL Server 2008/ 2012. Link for r...
If you want to Download image as Bitmap using Picasso following code will help you: Picasso.with(mContext) .load(ImageUrl) .into(new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { // Todo: Do some...
You can use the plus (+) operator to concatenate strings: 'Dart ' + 'is ' + 'fun!'; // 'Dart is fun!' You can also use adjacent string literals for concatenation: 'Dart ' 'is ' 'fun!'; // 'Dart is fun!' You can use ${} to interpolate the value of Dart expressions within strings. The curly...
Programmatically generating a String is best accomplished with a StringBuffer. A StringBuffer doesn't generate a new String object until toString() is called. var sb = new StringBuffer(); sb.write("Use a StringBuffer"); sb.writeAll(["for ", "efficient ", "stri...

Page 86 of 164