Feeds:
Posts
Comments

BitLocker To Go

The Feature “Turn On Bitlocker To Go” is available in Windows 7 Ultimate and Enterprise, Windows 8.1 Professional and above, and Windows 10 Professional above

Reference

http://www.techrepublic.com/blog/windows-and-office/secure-your-usb-drives-with-bitlocker-to-go-for-windows-7/

Const NUM_FARE_TYPE = 4
Dim SrcSheet(1 To 4) As String

Sub Initialize

SrcSheet(1) = “AduSR”
SrcSheet(2) = “ConSR”
SrcSheet(3) = “AduSR_1C”
SrcSheet(4) = “ConSR_1C”

End Sub
Sub Copy1a1b()

‘ Copy1a1b Macro

Const NUM_SET = 2
Const SET1_SRC = 10
Const SET2_SRC = 51

Const SET1_DEST_ADUSR = 9
Const SET2_DEST_ADUSR = 77
Const SET1_NUM_STAT = 17
Const SET2_NUM_STAT = 6

Dim i, j, k, m As Integer
Dim SetSrc(1 To NUM_SET), SetDest(1 To NUM_SET), SetNumStat(1 To NUM_SET) As Integer

SetSrc(1) = SET1_SRC
SetSrc(2) = SET2_SRC

SetDest(1) = SET1_DEST_ADUSR
SetDest(2) = SET2_DEST_ADUSR

SetNumStat(1) = SET1_NUM_STAT
SetNumStat(2) = SET2_NUM_STAT

Initialize

‘ SHEET “1a. ISL + TKL: BEGIN
Windows(“2016 Worksheets.xlsx”).Activate
Sheets(“1a.ISL+TKL >”).Select

‘ To ISL: BEGIN
For k = 1 To NUM_FARE_TYPE
Windows(“2016_ (Test).xlsx”).Activate
Sheets(SrcSheet(k)).Select

For m = 1 To NUM_SET
j = SetDest(m) + k – 1
For i = 1 To SetNumStat(m)
Windows(“2016_(Test).xlsx”).Activate
Range(“G” & (SetSrc(m) + i – 1) & “:W” & (SetSrc(m) + i – 1)).Select
Selection.Copy
Windows(“2016 Worksheets.xlsx”).Activate
Range(“H” & j).Select
ActiveSheet.Paste
j = j + 4
Next i
Next m

Next k
‘ To ISL: END

‘ To TWL: BEGIN
For k = 1 To NUM_FARE_TYPE
Windows(“2016_(Test).xlsx”).Activate
Sheets(SrcSheet(k)).Select

For m = 1 To NUM_SET
j = SetDest(m) + k – 1
For i = 1 To SetNumStat(m)
Windows(“2016_(Test).xlsx”).Activate
Range(“X” & (SetSrc(m) + i – 1) & “:AK” & (SetSrc(m) + i – 1)).Select
Selection.Copy
Windows(“2016 Worksheets.xlsx”).Activate
Range(“Y” & j).Select
ActiveSheet.Paste
j = j + 4
Next i
Next m

Next k
‘ To TWL: END

==========================================================================
End Sub

 

useful software tool

  1. Capture screen: Greenshot
  2. File Transfer: FileZilla
  3. MTTTY: Multi-threaded Terminal Sample (Win32)
  4. usbview.exe
  5. mysql-connector-odbc-5.3.4-win32.msi
  6. PuTTY putty.exe
  7. teraterm
  8. winscp
  9. HxD Hex Editor
  10. Q-Dir_portable (Q-Dir.exe)
  11. ruby185-21.exe
  12. TrueCrypt
  13. unix2dos.exe
  14. Window Mobile Device Centre (for HHC)
  15. VMware-player-6.0.4-2249910.exe
  16. WinMerge
  17. VirtualBox
  18. Notepad++
  19. tinytask
  20. audacity

find . -name “*” -exec dos2unix {} \;

Example 1

$input_path = ‘D:\sandbox\mult-line-search’
$regex = “Block 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00”

$files = Get-ChildItem $input_path -Include *.txt, *.log -Exclude $exclude_file -Recurse
for ($i=0; $i -lt $files.Count; $i++) {
$fileContent = Get-Content $files[$i].FullName
#$Sel = Select-String -InputObject $fileContent -Pattern “Block 80 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00”
$Sel = Select-String -InputObject $fileContent -Pattern $regex -NotMatch

If ($Sel -ne $null) #match the expression, when not equal to null
{
$filename = $files[$i].FullName
#write-host “Found in $filename `n$Sel`n”
write-host “Not Found in $filename`n”
}
}

Example 2

# reference: https://technet.microsoft.com/en-us/library/ff730968.aspx
# By default, Select-String does case-insensitive matching

$input_path = ‘D:\sandbox\mult-line-search’
$output_file = ‘D:\sandbox\mult-line-search\extracted.txt’
$exclude_file = ‘extracted.txt’
#$regex = ‘\bBlock 80+\x0D\x0A+00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00\b’ # not working
#$regex = “Block 80\x0D\x0A” # not working
$regex = “Block 80”
$regex = ‘\b[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}\b’ # search email address
#Get-ChildItem -Path D:\sandbox\mult-line-search -Include *.txt, *.log -Recurse | Select-String -Pattern “Block 80” -context 2, 3 > $output_file
Get-ChildItem -Path $input_path -Include *.txt, *.log -Exclude $exclude_file -Recurse | Select-String -Pattern $regex -context 1, 3 > $output_file

Binary search in array
void* bsearch (const void* key, const void* base,
size_t num, size_t size,
int (*compar)(const void*,const void*));

Reference
http://www.cplusplus.com/reference/cstdlib/bsearch/
————————————————————–
// C Example: Binary Search
#include /* printf */
#include /* bsearch, NULL */

typedef struct {
unsigned char index;
int data[12];
}data_type;

typedef struct {
int tot_num;
data_type * pData[10];
}test_struct;

test_struct testdata;

int comparedata (const void * a, const void * b)
{
//data_type **pA = (data_type**) a;
unsigned char key = *(unsigned char *)a;
data_type *pb = *(data_type**) b;
unsigned char data = pb->index;
printf(“pB %d\n”,pb);

printf(“A:%d,B=%d\n”,key,data);
return ((key – data));
}

int main ()
{
int i;
data_type** pItem;
unsigned char key = 23;
data_type** plist[256];
testdata.tot_num = 10;
for(i=0;iindex = 1;
testdata.pData[1]->index = 3;
testdata.pData[2]->index = 6;
testdata.pData[3]->index = 7;
testdata.pData[4]->index = 9;
testdata.pData[5]->index = 19;
testdata.pData[6]->index = 20;
testdata.pData[7]->index = 23;
testdata.pData[8]->index = 27;
testdata.pData[9]->index = 33;

for(i=0;i<testdata.tot_num;i++)
{
plist[i] = &testdata.pData[i];
printf ("plist address %d\n",plist[i]);
printf ("plist data %d\n",*(plist[i]));
printf ("plist data %d\n",**(plist[i]));
}
printf("size=%d\n",sizeof (data_type**));
pItem = (data_type**) bsearch (&key, plist[0], testdata.tot_num, sizeof(data_type**), comparedata);

if (pItem!=NULL)
printf ("%d is in the array, index by %d.\n",*pItem,pItem);
else
printf ("%d is not in the array.\n",key);
#endif
for(i=0;i<testdata.tot_num;i++)
free(testdata.pData[i]);
return 0;
}

The following program helps to print prime number up to input value.

int main ()
{
int n,i=1,j,c;
scanf(“%d”,&n);
while(i<=n) {
c = 0;
for (j=1;j<=i;j++) {
if (i%j==0) c++; // i=1,j=1,0;
}
if (c==2)
printf("%d",i);
i++;
}
}

==========================================================
Console output looks like:
23
23571113171923

Follow

Get every new post delivered to your Inbox.