Friday, April 28, 2017

Elegantno merenje vremena izvrsenja PHP procedura

http://php.net/manual/en/function.microtime.php


ou can use microtime and calculate the difference:
$time_pre = microtime(true);
exec(...);
$time_post = microtime(true);
$exec_time = $time_post - $time_pre;


http://stackoverflow.com/questions/8310487/start-and-stop-a-timer-php

https://www.swebdizajn.com/blog/korisni-alati/alati-za-proveru-sajtova.php

Koja je brzina tvog servera ? PHP

Koja je brzina tvog servera ?

<?phpif (isset($_GET['source']))
{
    
highlight_file($_SERVER['SCRIPT_FILENAME']);
    exit;
}
$maxNumKB 4096;$defNumKB 512;
if (!isset(
$_GET['numKB']) || intval($_GET['numKB']) > $maxNumKB)
{
    
header("Location: http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?numKB=$defNumKB");
    exit;
}
$numKB intval($_GET['numKB']);?><!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <title>Jan! &raquo; PHP &raquo; speed test</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <style type="text/css">
    <!--
    html
    {
        font-family: sans-serif;
        color: #000;
        background: #fff;
    }
    *
    {
        font-size: medium;
    }
    #wait
    {
        border-bottom: thin dotted black;
    }
    #wait abbr
    {
        border: none;
    }
    #done
    {
        font-weight: bold;
    }
    #benchmark
    {
        padding: 1em;
        border: 1px solid black;
        background: #ffe;
        color: #000;
    }
    //-->
    </style>
</head>
<body>
<div id="benchmark">
<p>
    <strong>This not a script to benchmark or determine the execution speed
    of PHP scripts.</strong> If you're looking for one, check out the PEAR
    <a href="http://pear.php.net/package/Benchmark">Benchmark package</a>.
</p>
<p>
    This script sends <?php echo $numKB?> <abbr title="kilobyte">KB</abbr>
    of HTML comments to your client. Parsing that HTML may add to the total
    transfer time, so don't take this as your raw download speed.
</p>
</div>
<h1>Please wait</h1>
<p>
    <a href="<?php echo "http://{$_SERVER['HTTP_HOST']}{$_SERVER['PHP_SELF']}?source=1"?>">(Show source)</a>
</p>
<p id="wait">
    Transferring <?php echo $numKB?> <abbr title="kilobyte">KB</abbr>
</p>
<!--
<?phpfunction getmicrotime()
{
    list(
$usec$sec) = explode(" "microtime());
    return ((float)
$usec + (float)$sec);
}
flush();$timeStart getmicrotime();$nlLength strlen("\n");
for (
$i 0$i $numKB$i++)
{
    echo 
str_pad(''1024 $nlLength'/*\\*') . "\n";
    
flush();
}
$timeEnd getmicrotime();$timeDiff round($timeEnd $timeStart3);?>-->
<p id="done">
    <?php
        
echo "Transferred {$numKB} <abbr title=\"kilobyte\">KB</abbr> in {$timeDiff} seconds, " .
             (
$timeDiff <= "more than {$numKB}round($numKB $timeDiff3)) .
             
' <abbr title="kilobytes per second">KB/s</abbr>';
    
?></p>
</body>
</html>

Thursday, April 27, 2017

SSL and JavaScript

LLMNR

REG ADD  “HKLM\Software\policies\Microsoft\Windows NT\DNSClient\
REG ADD ” HKLM\Software\policies\Microsoft\Windows NT\DNSClient” /v ” EnableMulticast” /t REG_DWORD /d “0” /f

gpedit.msc



To disable LLMNR on windows:
1. Click Start
2. Type gpedit.msc in the text box 
3. Navigate to Local Computer Policy -> Computer Configuration -> Administrative Templates -> Network -> DNS Client
4.  In the DNS Client Folder, double click on “Turn Off Multicast Name Resolution” and set it to “Enabled


The following registry key is set on computers when LLMNR is disabled:
HKLM\Software\Policies\Microsoft\Windows NT\DNSClient
"EnableMulticast" DWORD 0


http://www.computerstepbystep.com/turn-off-multicast-name-resolution.html




Tuesday, April 25, 2017

VBS tut

set shellobj = CreateObject("WScript.Shell")
shellobj.run "cmd"
wscript.sleep 100
shellobj.sendkeys "shutdown"
wscript.sleep 20
Shellobj.sendkeys " /s"
wscript.sleep 20
shellobj.sendkeys [ENTER]

------------------


x=msgbox("Would you like to open the Windows folder?" ,4, "Question:")

If x = vbNo Then Wscript.Quit(0)

If x = VbYes Then

Set WshShell = CreateObject("WScript.Shell")

X = WshShell.run("cmd /c explorer.exe ""C:\Windows""",0, true)

End If

------------------------

strMB = inputbox("Please enter your message here:")

Set WshShell = CreateObject("WScript.Shell")

WshShell.run "cmd /c @echo msgbox " & """" & strMB & """" & ",4096,""VBS2CMD2VBS:"">C:\Message.vbs",0, true

WshShell.run "C:\windows\system32\wscript.exe C:\Message.vbs",0, false

Wscript.Quit(0)


-----------------------------

strMB = inputbox("Please enter your message here:")

msgbox strMB, 4096, "Message"

------------------------


(A)

x=msgbox("Would you like to continue?" ,4, "Question:")

If x = vbNo Then MsgBox "You selected 'No'", 4096, "No:"

If x = VbYes Then MsgBox "You selected 'Yes'", 4096, "Yes:"

(B)

x=msgbox("Would you like to continue?" ,4, "Question:")

If x = vbNo Then

MsgBox "You selected 'No'", 4096, "No:"

Wscript.Quit(0)

End If

If x = VbYes Then

MsgBox "You selected 'Yes'", 4096, "Yes:"

Wscript.Quit(0)

End If

(C)

x=msgbox("Would you like to continue?" ,4, "Question:")

If x = vbNo Then

MsgBox "You selected 'No'", 4096, "No:"

Else

MsgBox "You selected 'Yes'", 4096, "Yes:"

End If

Wscript.Quit(0)


-------------------------


x=msgbox("Would you like to continue?" & VbCrLf & "If you select No, you will see NO" & VbCrLf & VbCrLf & "If you select Yes, you will see YES",4, "Question:")

If x = vbNo Then

MsgBox "NO", 4096, "No:"

Else

MsgBox "YES", 4096, "Yes:"

End If

--------------------------------------


Set WshShell = CreateObject("WScript.Shell")

x = WshShell.Popup("Would you like to continue?",5,"Title:",4)

If x = vbNo Then Wscript.Quit(0)

If x = VbYes Then

'Your script goes here

msgbox "you selected YES!", 4096, "Yes"

End If


--------------------------------------------



'************************************************
' File:    Input.vbs (WSH sample in VBScript) 
' Author:  (c) G. Born
'
' Retrieving user input in VBScript
'************************************************
Option Explicit

Dim Message, result
Dim Title, Text1, Text2

' Define dialog box variables.
Message = "Please enter a path"           
Title = "WSH sample user input - by G. Born"
Text1 = "User input canceled"
Text2 = "You entered:" & vbCrLf

' Ready to use the InputBox function
' InputBox(prompt, title, default, xpos, ypos)
' prompt:    The text shown in the dialog box
' title:     The title of the dialog box
' default:   Default value shown in the text box
' xpos/ypos: Upper left position of the dialog box 
' If a parameter is omitted, VBScript uses a default value.

result = InputBox(Message, Title, "C:\Windows", 100, 100)

' Evaluate the user input.
If result = "" Then    ' Canceled by the user
    WScript.Echo Text1
Else 
    WScript.Echo Text2 & result
End If

'*** End

'result = InputBox(prompt[, [title], [default], [xpos], [ypos]])
'The InputBox function has the following parameters:
'prompt A required parameter that defines the message shown in the dialog box. In Figure 8-1, this is the string Please Enter A Path.
'title An optional parameter that defines the title bar text for the dialog box.
'default An optional parameter that specifies the default value shown in the text box.
'xpos and ypos Optional parameters that define the position of the upper left corner of the dialog box.
'InputBox("Hello", "Test", , 100, 200)
'If result = "" Then    ' Test for Cancel.
'    WScript.Echo "Canceled"
'Else 
'    WScript.Echo "You entered: " & result
'End If
---------------------------------------

http://wsh2.uw.hu/ch08b.html

http://www.instructables.com/id/How-to-Make-a-message-box-using-VBScript/


---------------------


Set objFSO=CreateObject("Scripting.FileSystemObject")

' How to write file
outFile="c:\test\autorun.inf"
Set objFile = objFSO.CreateTextFile(outFile,True)
objFile.Write "test string" & vbCrLf
objFile.Close

'How to read a file
strFile = "c:\test\file"
Set objFile = objFS.OpenTextFile(strFile)
Do Until objFile.AtEndOfStream
    strLine= objFile.ReadLine
    Wscript.Echo strLine
Loop
objFile.Close

'to get file path without drive letter, assuming drive letters are c:, d:, etc
strFile="c:\test\file"
s = Split(strFile,":")
WScript.Echo s(1)

------------------------------

Option Explicit

Const fsoForReading = 1
Const fsoForWriting = 2

Function LoadStringFromFile(filename)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(filename, fsoForReading)
    LoadStringFromFile = f.ReadAll
    f.Close
End Function

Sub SaveStringToFile(filename, text)
    Dim fso, f
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set f = fso.OpenTextFile(filename, fsoForWriting)
    f.Write text
    f.Close
End Sub

SaveStringToFile "f.txt", "Hello World" & vbCrLf
MsgBox LoadStringFromFile("f.txt")

------------------------------------


'You can create a temp file, then rename it back to original file:

Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\file.txt"
strTemp = "c:\test\temp.txt"
Set objFile = objFS.GetFile(strFile)
Set objOutFile = objFS.CreateTextFile(strTemp,True)
Set ts = objFile.OpenAsTextStream(1,-2)
Do Until ts.AtEndOfStream
    strLine = ts.ReadLine
    ' do something with strLine 
    objOutFile.Write(strLine)
Loop
objOutFile.Close
ts.Close
objFS.DeleteFile(strFile)
objFS.MoveFile strTemp,strFile 


'Usage is almost the same using OpenTextFile:

Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\file.txt"
strTemp = "c:\test\temp.txt"
Set objFile = objFS.OpenTextFile(strFile)
Set objOutFile = objFS.CreateTextFile(strTemp,True)    
Do Until objFile.AtEndOfStream
    strLine = objFile.ReadLine
    ' do something with strLine 
    objOutFile.Write(strLine & "kndfffffff")
Loop
objOutFile.Close
objFile.Close
objFS.DeleteFile(strFile)
objFS.MoveFile strTemp,strFile 


------------------------------

http://stackoverflow.com/questions/1142678/read-and-write-into-a-file-using-vbscript

http://stackoverflow.com/questions/2198810/creating-and-writing-lines-to-a-file


--------------------------------------


The File System Object, generally used by VBScript developers to read and write text files, can read only ASCII or Unicode text files. You cannot use it to read or write UTF-8 encoded text files.

But, if you can use Microsoft ActiveX Data Objects (ADO), you can read UTF-8 encoded text files like this:

Dim objStream, strData
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.LoadFromFile("C:\Users\admin\Desktop\test.txt")
strData = objStream.ReadText()
If you want to write a UTF-8 encode text file, you can do so like this:

Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.WriteText "The data I want in utf-8"
objStream.SaveToFile "C:\Users\admin\Desktop\test.txt", 2


--------------------------------------


http://developer.rhino3d.com/guides/rhinoscript/read_write_utf8/


LSA network share from XP to 10

____________________________________________________
File: share-for-all-from-xp-to-10.reg
Author: v$
____________________________________________________


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa]
"everyoneincludesanonymous"=dword:00000001
"restrictanonymous"=dword:00000000


____________________________________________________
Mali a koristan reg fajl koji Vam omogućuje jednostavan Network Share-ing foldera koji se nalaze na Windows XP sa Windows 10 kompjuterima i obratno. 

VBS dovoljan za skoro sve

___________________
File: tuta.vbs
Author: v$
________________


Option Explicit
Dim result, objFSO, outFile, objFile 
result = InputBox("zapisi ovo:", "title", "default unos", 100, 100)
WScript.Echo result  

'Set objFSO = CreateObject("Scripting.FileSystemObject")

' How to write file
'outFile="c:\test\probator.txt"
'Set objFile = objFSO.CreateTextFile(outFile,True)
'objFile.Write "test string: " & result & vbCrLf
'objFile.Close


Dim objStream
Set objStream = CreateObject("ADODB.Stream")
objStream.CharSet = "utf-8"
objStream.Open
objStream.WriteText result
objStream.SaveToFile "c:\test\probator.txt", 2



WScript.Echo "totovo"

http://012lab.rs/uvod-u-programiranje-mikrokontrolera-arduino

https://www.qbittorrent.org/

Veoma kvalitetan i čist program :

https://www.qbittorrent.org/

Nema reklame i bloatware gluposti kao uTorrent (ranije je uTorrent bio ok, ali sada je bolje da ga izbegavate u velikom luku).

Process1.Execute LAZARUS

You can execute OS commands in Free Pascal / Lazarus by using TProcess component that exists in System component palatte.
TProcess also can open external applications from your Lazarus project.
Example:
1. Create new application, put Edit box, a buttonTProcess and a Memo in main form:
Image
2. Change UsePiples property to True in TProcess.Options.
3. Write this code in button’s OnClick:
1
2
3
4
5
6
procedure TForm1.Button1Click(Sender: TObject);
begin
  Process1.CommandLine:= Edit1.Text;
  Process1.Execute;
  Memo1.Lines.LoadFromStream(Process1.Output);
end;
4. Run the application and write any commands like (ls in Linux, dir in Windows) and click the button. You will get the result of text commands in the memo:
You can also run applications, like calculator, text editor, or any other application.