Never been to TextSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

« Newer Snippets
Older Snippets »
9 total  XML / RSS feed 

[SAMBA] exclude file/directory from shared folder

// i have shared a directory and in this directory is one
// which i dont want to share! how can i exclude this?

[myshare]
  path = /var/test
  veto files = /var/test/private


// where /var/test/private can be a file or directory.

Disconnect Windows 2000 RDP session from command line

I use SSH to gain access to my Windows 2000 command line, so that will be reflected in the below steps.


Step #1: Connect to the server if you are not sitting at it
ssh username@win2000server -i privatekey

Step #2: Find out which sessions are currently active
query session

 SESSIONNAME       USERNAME                 ID  STATE   TYPE        DEVICE
>console                                     0  Conn    wdcon
 rdp-tcp                                 65536  Listen  rdpwd
 rdp-tcp#7         fakeuser                  1  Active  rdpwd

Step #3: We want to kill the connection with an ID of 1 (we can tell by the username and that it is active)
tsdiscon 1 /v

Disconnecting sessionID 1 from sessionname RDP-Tcp#7

That's it :) Easy eh?

Quick Links in Texter

Some examples of spiffy shortcuts for hyperlinks using Texter:

// hotstring = replacement text

aref  = <a href="%c">%|   // a quick html link with clipboard contents, and placing the cursor between the opening/closing tags)

bbref = [url=%c]%|[/url]      // same thing for bbcode

tref = "%|":%#8221;           // same thing for textile



TxtSnippets doesn't seem to know how to format that but you get the idea.

view saved passwords to shares, in windows


view saved passwords in windows
rundll32.exe keymgr.dll, KRShowKeyMgr

Configure proxy in Windows command shell (cmd.exe)

For use with gems, cpan, etc. Inside cmd.exe, type

set HTTP_proxy=http://my.proxy.server:8000

Windows' command prompt : How to DEFINITELY change default codepage

Want to use WinLatin1 (1252) instead of DOSLatin1 (850, default when cmd.exe is started) ?

You want to apply the new codepage to :
- the current opened command prompt
C:\> chcp 1252

- all the opened command prompt in the future
Start->Run->regedit
Go to [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Nls\CodePage]
And change the "OEMCP" value to "1252"

You need to restart your computer to see the changes.

So you'll be able to display extended characters (such as accents and so on)

==

Don't know how to check the command prompt's codepage ?
C:\> chcp


==

Want to see the result in practice ?
Edit a codepage.txt file and type "à la bonne heure, ça marche ! (peut être)", then open a command prompt and check this out :
C:\> type codepage.txt

kill remote application

'probably 2k and xp only

'not my own code. Borrowed from
'http://groups.google.com/group/microsoft.public.scripting.vbscript/browse_thread/thread/f197a145c8c9f1e6

Option Explicit

Dim sComputer, sProcess, oShell
Const WindowStyle = 0
Const WaitOnReturn = True

sComputer = "XXXXXXX" ' remote machine
sProcess = "XXXXX.exe" ' app on remote machine
Set oShell= CreateObject("WScript.Shell")
oShell.Run "TaskKill /s " & strComputer & " /im " & strProcess & " /f", WindowStyle, WaitOnReturn
Set oShell = Nothing

Borked LoadImageFromURL Method For Compact Framework

      public static Image LoadImageFromURL(string URL) 
      { 
         HttpWebRequest request = (HttpWebRequest) HttpWebRequest.Create(URL); 
         HttpWebResponse response = null; 
         BinaryReader br = null; 
         MemoryStream stream = null; 
         request.Timeout = 10000;   // 10 Seconds 
         try 
         { 
            int tmp = ServicePointManager.DefaultConnectionLimit; 
            response = (HttpWebResponse) request.GetResponse();  // i lock up on the second method call 
       
            br = new BinaryReader((response.GetResponseStream())); 
    
            byte[] buffer = new byte[256]; 
            stream = new MemoryStream(); 
    
            int length =0; 
    
            do 
            { 
               length = br.Read(buffer,0,256); 
               stream.Write(buffer,0,length); 
            } 
            while (length >0); 

            request.Abort(); 
            request = null; 
            response.Close(); 
            response = null; 
            return (Image)new Bitmap(stream); 
             
         } 
         catch(Exception e) 
         { 
            MessageBox.Show(e.Message.ToString()); 
            return null; 
         } 
         finally 
         { 
            if (response != null) 
            { 
               response.Close(); 
               response = null; 
            } 
         } 
      } 

   }

Directory/File list in Windows

Run, CMD, blah blah blah...

For a pretty tree, do
tree /f /a > tree.txt


For an ugly (but thorough) inline list of directories and files, sorted by directory name and then date of creation, do
dir /s /a  /o:-d /t:c > file_list.txt


If you don't want subdirectories listed under directories, do
dir /s /a:-d /o:-d /t:c > file_list.txt
« Newer Snippets
Older Snippets »
9 total  XML / RSS feed