working on it ...


Explore Public Snippets

Sort by

Found 339 snippets

    public by NightHowl  53  0  3  0

    Batch ESC (ANSI escape sequence)

    This snippet is useful for escape characters. It can be used to, for example, color your screen/certain words/letters. An example: ----------------- echo %ESC%[93mHello![0m ----------------- The above will print out 'Hello!' in a yellowish color and then RESET the color, meaning any words after Hello! won't be yellow. For more information on
    for /f "delims=" %%E in (
        'forfiles /p "%~dp0." /m "%~nx0" /c "cmd /c echo(0x1B"'
    ) do (
        set "ESC=%%E"

    public by TheFreeman193  531  0  5  0

    Elevate batch script

    Checks for elevation with fsutil, if not found will elevate the current script and terminate the original instance.
    fsutil dirty query %SYSTEMDRIVE% >nul
    if ERRORLEVEL 1 (start /min "" powershell -Command "Start-Process -FilePath '%~f0' -Verb runas" & exit /b)

    public by DinhoPutz  395  1  5  1

    Compactar Arquivos para Backup com Winrar

    REM Compactar arquivos para fazer backup. 
    REM Obs, é recomendável que os caminhos dos arquivos não contenham espaço. 
    REM Sobre a linha de comando 
    REM "RAR.exe a": o comando "a" adiciona arquivos no arquivo compacto que esta sendo criado.
    REM "-m5": nível de compressão, que vai de 0 à 5, sendo 5 o nível máximo de compressão.
    REM "-r": Para adicionar pastas e subpastas. 
    REM "-ag": É a marca de tempo, recomendável se for criar backups diário. 
    REM ">>": Gera o arquivo de log e a medida que o backup for sendo executado vai adicionandos novas linhas ao mesmo.
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo1.rar D:\Pasta1\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo2.rar D:\Pasta2\ >> Saida.txt
    C:\progra~2\WinRAR\Rar.exe a -m5 -r -ag_yyyy-MM-dd E:\Arquivo3.rar C:\Pasta3\ >> Saida.txt						

    public by RexPhillips  331  2  4  0


    Powershell snippet to rename files in a directory in a batch mode.
    dir | rename-item -NewName {$ -replace "DEV","PROD"}

    public by maholtz  1598  1  4  0

    Windows Batch - for loop

    REM use %%x in Batch file, %x on console
    REM for /l %%x in (START, STEP, END) do (
    for /l %%x in (101, 1, 199) do (
      REM %%x - a longer variable is not allowed?
    	echo Number %%x

    public by cghersi  2660  0  5  0

    Transform a JKS keystore in a PEM certificate

    This set of commands transform the certificate from a JKS to a PEM format. It requires JDK keytool and openssl.
    keytool -keystore client.ts -exportcert -alias mobile | openssl x509 -inform der -text
    #psw of keystore: changeit
    keytool -importkeystore -srckeystore client.ts -destkeystore client.p12 -srcstoretype jks -deststoretype pkcs12
    #psw of destination keystore: changeit
    openssl pkcs12 -in client.p12 -out client.pem
    #import psw: changeit

    public by cghersi  2672  0  4  0

    Start Eclipse with a non-default JVM

    Eclipse starts with a JMV that is usually the one in the PATH. E.g. the version retrieved thru java --version
    C:\eclipse\eclipse.exe -vm "C:\Program Files\Java\jdk1.6.0_45\bin\javaw.exe"           

    public by cghersi  2880  2  7  1

    Enable HTTPS on Tomcat

    How to make the apps running on Tomcat able to publish over https
    // 1. Export certificate request with keytool
    // 1.1 Generate the keytool command with the form at this URL:
    // 1.2 The result will be a pair of file mydomain.jks and mydomain.csr
    // 2. Ask the certificate to the cert authority
    // 2.1 The result will be a pair of file mydomain.pem and mydomain.p7b
    // 3. Import mydomain.pem into mydomain.jks (assuming your alias is "server")
    keytool -import -v -trustcacerts -alias server -file mydomain.pem -keystore iot_bissell_com.jks -storepass <secret_psw>
    // 4. Edit conf/server.xml in the deployment of Tomcat, add this line 
    // (under the element <Service name="Catalina">):
    <Connector SSLEnabled="true" 
     clientAuth="false" keyAlias="server" 
     keystorePass="<secret_psw>" maxThreads="150" port="8080" 
     protocol="HTTP/1.1" scheme="https" secure="true" sslProtocol="TLS"/>            

    public by maholtz  2762  1  6  0

    while loop batch

    # In einer Zeile, zählt hoch und wartet dazwischen 10 Sekunden
    # Kann als Basis genommen werden um auf die Schnelle Befehle
    # mit Pause in der Shell zu wiederholen
    a=0; while [ "$a" -lt 100 ]; do echo -n "$a"; sleep 10;  a=`expr $a + 1`; done;

    public by cghersi  2035  1  6  2

    Sign a DLL with a strong name

    In some cases a DLL with strong name is required. If you need a third party library but this is not signed, the only way to avoid this problem is to deassembly and reassembly the DLL. Note: this can cause problems in licensing, so be sure that you are not infringing any license agreement!
    rem from a Developer Command Prompt, 
    rem go in the bin folder of your project, where is the dependent library (not signed).
    rem Assume your project depends on Foo, third party library not signed.
    rem 1) Optional, if Foo depends on Foo2, sign all the other dependencies like Foo2:
    ildasm /all / Foo2.dll
    ilasm /dll /key=Key.snk 
    rem 2) disassembly
    ildasm /all / Foo.dll
    rem 3) Optional, if Foo depends on Foo2, add the new public token to
    rem 3.1) Retrieve the public token (e.g. the result of this step will be publictoken=(6B 75 A8 06 B8 60 95 CD )
    sn -Tp Foo2.dll
    rem 3.2) Edit file, changing
    rem .assembly extern /*23000005*/ Foo2
    rem {
    rem  .ver 2:1:12:0
    rem }
    rem  to
    rem .assembly extern /*23000005*/ Foo2
    rem {
    rem  .publickeytoken = (6B 75 A8 06 B8 60 95 CD )                     
    rem  .ver 2:1:12:0
    rem }
    rem 4) riassembly
    ilasm /dll /key=Key.snk 
    • Public Snippets
    • Channels Snippets