Re: how can I load html files and not .dt or diet files in vibe.d

2024-02-01 Thread Aravinda VK via Digitalmars-d-learn

On Thursday, 1 February 2024 at 03:20:31 UTC, dunkelheit wrote:


!!! 5
html
body
h1 hello diet
-iframe("hola.html")


please help me :')


Try

```
html
body
h1 hello diet
iframe(src="hola.html")
```


Re: Emacs d-mode indentation, 2 spaces to 4?

2017-10-05 Thread Aravinda VK via Digitalmars-d-learn

On Thursday, 5 October 2017 at 04:57:09 UTC, John Gabriele wrote:
I'm using Emacs 25.2.2 with d-mode-20161022.717 on Debian 
Testing, and by default this mode indents by 2 spaces. Is there 
an easy way to configure it to use 4 spaces instead?


Add below snippet to your .emacs file

(add-hook 'd-mode-hook
  (lambda ()
(setq c-basic-offset 4)
(setq tab-width 4)))


Re: Folder Size

2017-08-21 Thread Aravinda VK via Digitalmars-d-learn

On Saturday, 19 August 2017 at 14:19:39 UTC, Vino.B wrote:

Hi All,

  I have written a small program to find the size of folder's , 
but the output is not as expected, hence request your help and 
advice on any techniques to reduce the run time of the program.


Requirement:
The script has to scan several file system

("C:\\Temp\\TEAM","C:\\Temp\\PROD_TEAM", "C:\\Temp\\BACKUP")

Display only the sub folder level 1 name whose name should not 
contain *DND* and size


dirEntries(i, SpanMode.shallow).filter!(a => a.isDir && 
!globMatch(a.baseName, "*DND*"))


Eg: C:\Temp\TEAM\USER_BACKUP , C:\Temp\PROD_TEAM\PROD_BACKUP , 
C:\Temp\BACKUP\SUPPORT_BACKUP


Need the folder name and size of each folder under
 C:\Temp\TEAM\USER_BACKUP , C:\Temp\PROD_TEAM\PROD_BACKUP , 
C:\Temp\BACKUP\SUPPORT_BACKUP


Program

import std.file: dirEntries, isFile, SpanMode;
import std.stdio: writeln;
import std.algorithm: filter;
import std.array: array;
import std.path;

auto AgedDirlst = [ "C:\\Temp\\TEAM\\USER_BACKUP" , 
"C:\\Temp\\PROD_TEAM\\PROD_BACKUP" , 
"C:\\Temp\\BACKUP\\SUPPORT_BACKUP" ];


void main ()
{
foreach (string i; AgedDirlst[0 .. $])
 {
	  auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a => 
a.isDir && !globMatch(a.baseName, "*DND*")).array;

  foreach (d; dFiles)
{
  auto SdFiles = dirEntries(d, SpanMode.depth).array;
  foreach (f; SdFiles)
  writeln(f.dirName, "\t", f.size);

}
 }
writeln("*");
}

Output:

C:\Temp\TEAM\USER_BACKUP\DIR1   41129
C:\Temp\TEAM\USER_BACKUP\DIR1\dir3  68
C:\Temp\TEAM\USER_BACKUP\DIR1   0

C:\Temp\TEAM\USER_BACKUP\DIR2\dir4  3410
C:\Temp\TEAM\USER_BACKUP\DIR2\dir4  2277663
C:\Temp\TEAM\USER_BACKUP\DIR2   0
C:\Temp\TEAM\USER_BACKUP\DIR2   1156

C:\Temp\PROD_TEAM\PROD_BACKUP\dir1  41129
C:\Temp\PROD_TEAM\PROD_BACKUP\dir1\dir3 68
C:\Temp\PROD_TEAM\PROD_BACKUP\dir1  0
C:\Temp\PROD_TEAM\PROD_BACKUP\dir1\DND1 36590125
C:\Temp\PROD_TEAM\PROD_BACKUP\dir1  0

C:\Temp\PROD_TEAM\PROD_BACKUP\dir2\dir4 3410
C:\Temp\PROD_TEAM\PROD_BACKUP\dir2  0
C:\Temp\PROD_TEAM\PROD_BACKUP\dir2  1156

C:\Temp\BACKUP\SUPPORT_BACKUP\dir1\DND1 36590125
C:\Temp\BACKUP\SUPPORT_BACKUP\dir1  0
C:\Temp\BACKUP\SUPPORT_BACKUP\dir2\DND2 1156
---
Required Output
---
C:\Temp\TEAM\USER_BACKUP\DIR1   41197  
(41129+68)
C:\Temp\TEAM\USER_BACKUP\DIR2   2282229 
(3410+2277663+1156)
C:\Temp\PROD_TEAM\PROD_BACKUP\dir1  36631322 
(41129+68+36590125)

C:\Temp\PROD_TEAM\PROD_BACKUP\dir2  4566 (3410+1156)
C:\Temp\BACKUP\SUPPORT_BACKUP\dir1  36590125
C:\Temp\BACKUP\SUPPORT_BACKUP\dir2  1156

From,
Vino.B


Keep a variable to add the sizes of subdirs

auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a => 
a.isDir && !globMatch(a.baseName, "*DND*")).array;

ulong subdirTotal = 0;
foreach (d; dFiles)
{
subdirTotal = 0;
auto SdFiles = dirEntries(d, SpanMode.depth).array;
foreach(f; SdFiles) {
subdirTotal += f.size;
}
writeln(d, "\t", subdirTotal);
}

--
Aravinda
http://aravindavk.in