Home | Blog | Software | Reviews and Features | Forum | Help | Donate | About us
topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • December 06, 2016, 12:03:02 PM
  • Proudly celebrating 10 years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Last post Author Topic: Source Code / Code Snippet Manager  (Read 22105 times)

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #25 on: June 19, 2009, 09:00:33 AM »
One of the first things I notice is a lack of the ability to set your internet proxy.  Without that, I can't use it to access snipplr.  Do you have any intention of adding that ability?

mtelligent

  • Participant
  • Joined in 2009
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #26 on: June 19, 2009, 09:40:57 AM »
Good Point. I actually hadn't thought about setting up a proxy. I'll look into it tonight and see if it's something I can easily add support for.


wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #27 on: June 19, 2009, 10:04:37 AM »
I see you're using .NET.  Not sure if it's C#, or what libraries you're using to connect, but if you're using the out of the box support and are using C#, here's an example of setting a proxy...

Code: C# [Select]
  1. var result = new StringBuilder();
  2.             try
  3.             {
  4.               var transferProxy = new WebProxy("http://proxy:80/", true);
  5.               transferProxy.Credentials = new NetworkCredential("userId", "password", "Domain");
  6.               var transferRequest = WebRequest.Create("http://www.snipplr.com");
  7.               transferRequest.Proxy = transferProxy;
  8.               HttpWebResponse transferResponse = (HttpWebResponse)transferRequest.GetResponse();
  9.               System.IO.Stream outputStream = transferResponse.GetResponseStream();
  10.               System.Text.Encoding outputEncoding = System.Text.Encoding.GetEncoding("utf-8");
  11.               System.IO.StreamReader outputReader = new System.IO.StreamReader(outputStream, outputEncoding);
  12.               char[] chars = new Char[256];
  13.               int readCount = outputReader.Read(chars, 0, 256);
  14.               int totalRead = readCount;
  15.               while(readCount > 0)
  16.               {
  17.                 string str = new String(chars, 0, 256);
  18.                 result.Append(str);
  19.                 readCount = outputReader.Read(chars, 0, 256);
  20.               }
  21.               transferResponse.Close();
  22.               outputStream.Close();
  23.               outputReader.Close();
  24.             }
  25.             catch(Exception ex)
  26.             {
  27.               string str = ex.Message;
  28.             }

Caveat- I pulled this from some other code and scrubbed some of the identifying lines, so there may be extraneous lines in there or it may not compile offhand, but the code is correct.  Let me know if you have any questions, but it's pretty straightforward, and from what you've already done with snip-it, I'm sure it shouldn't be an issue.  :Thmbsup:

UPDATE: Made sure it still compiled and fixed an embarrassing oversight.
« Last Edit: June 19, 2009, 10:10:50 AM by wraith808 »

mtelligent

  • Participant
  • Joined in 2009
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #28 on: June 19, 2009, 10:10:50 AM »
Snip-It Pro is written in C#.

The snipplr API is XML RPC so I am using the xmlrpc.net libraries at http://www.xml-rpc.net.

I can manually set the Proxy object like you described in your code snippet, or can just set it to the WebRequest.DefaultWebProxy which should (in theory) take the default proxy settings from Internet Explorer.

Would someone want to specify custom proxy settings for this one app, or just have it read the IE Settings?

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #29 on: June 19, 2009, 10:27:12 AM »
I always allow a choice personally.  There might be a reason not to use the default proxy, so I just put a radio button to allow (a) default proxies or (b) custom proxy.  This also takes care of the case where IE won't play right, which I've had a problem with before.

FSL

  • Honorary Member
  • Joined in 2006
  • **
  • Posts: 5
  • FreeSoftLand
    • View Profile
    • FreeSoftLand Site
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #30 on: June 20, 2009, 08:47:08 AM »
I actually tried that one but it did not have drag and drop support. To me without that feature I do not feel any need for using another application really.
Many thanks for your suggestion.  :)
I have added a full drag and drop support in the current release (for both: files and text blocks from other IDEs or editors).

Best regards,
FSL

tinjaw

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,927
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #31 on: June 20, 2009, 09:40:35 AM »
I have added a full drag and drop support in the current release (for both: files and text blocks from other IDEs or editors).

Yeah! I am off to download my registered version (with super special extra privileges  8) ).

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #32 on: June 20, 2009, 12:30:10 PM »
I Implemented the feature last night and just published it this morning.

CTRL, ALT, "S" will toggle the visibility of the snippet toolbar now.

By the way, There is another way to get snippets out of Snip-It Pro. You can publish them to Snipplr.com. Sign up for an account and enter your app ID into Snip-It Pro to enable this feature. Besides Snip-It Pro, there are plugins for Textmate and other programs that will allow you to get your snippets from Snipplr, so you won't be tied to Snip-It Pro. Snipplr is a pretty cool code snippet community, and every snippet you favorite, is viewable in Snip-It Pro.
thanks for the addition
I will try it tonight

Just a side note, you know though ctrl+alt or similar combinations are generally could be used by many other applications. I generally think that offering "win" key combinations are better suited for global operations like toggling.

I have never tried Snipplr.com. I will also check it out today

mtelligent

  • Participant
  • Joined in 2009
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #33 on: June 21, 2009, 08:05:22 AM »
Good Point kartal. I changed the key to "CTRL" "Windows Key" "S". Still needed to use "CTRL" because the "Windows Key" "S" toggles caps lock if you have one of those intelli keyboards MSFT sells.

Wraith808, the updated version also supports configuring proxy settings for connecting to Snipplr. Let me know if you have any issues with it.

You can download the latest version from:
http://www.snipitpro.com/tryItFree.html

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #34 on: June 21, 2009, 09:46:56 AM »
Thanks!  I'll check it out when I get to work... it looks really good- both the app, and snipplr!

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #35 on: June 22, 2009, 09:32:47 AM »
No joy on the Proxy settings, unfortunately.  I attempted to let it get default settings, then after that didn't work, I specified them manually, and never was able to get past the proxy.

Using WinXP Professional SP2.  Let me know if you need me to check anything else.

mtelligent

  • Participant
  • Joined in 2009
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #36 on: June 22, 2009, 11:37:01 AM »
I'll look into things later tonight.

Did you specify a username/password/domain?

I might have to add code to pass the current credentials to the proxy, because right now, nothing is passed if you don't.

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #37 on: June 22, 2009, 11:58:52 AM »
I specified username and password, but not domain.  I also specified a port on the proxy.

mtelligent

  • Participant
  • Joined in 2009
  • *
  • Posts: 11
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #38 on: June 29, 2009, 08:23:07 AM »
Just an Update: I can reproduce, but still no fix.

I used to CCProxy to test having a proxy server.

The code worked fine, if I set CCProxy not to require authentication, but if I did, it wouldn't work. (Tried just username/password)

I tried changing from using NetworkCredential to the CredentialCache object, but still no dice.

Here's the code if anyone has any suggestions otherwise I'll keep plugging away at it:

Quote
if (config.UseCustomProxySettings)
                {
                    System.Net.WebProxy proxy = new System.Net.WebProxy(config.ProxyServerAddress);
                    if (config.UseProxyCredentials)
                    {
                         proxy.Credentials =  new NetworkCredential(config.ProxyUserName, config.ProxyPassword, config.ProxyDomain));
                    }
                    else
                    {
                        proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
                    }
                    SnipplrProxy.Proxy = proxy;                   
                }

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #39 on: June 29, 2009, 01:37:05 PM »
Try this snippet and see if it works for you... It does for me in my code.

Code: C# [Select]
  1. var result = new StringBuilder();
  2.             try
  3.             {
  4.                 var transferProxy = new WebProxy("http://<proxyaddress>:<proxyport>/", true);
  5.                 transferProxy.Credentials = new NetworkCredential("<username>", "<password>", "<domain>");
  6.                 var transferRequest = WebRequest.Create("http://www.snipplr.com");
  7.                 transferRequest.Proxy = transferProxy;
  8.                 HttpWebResponse transferResponse = (HttpWebResponse)transferRequest.GetResponse();
  9.                 System.IO.Stream outputStream = transferResponse.GetResponseStream();
  10.                 System.Text.Encoding outputEncoding = System.Text.Encoding.GetEncoding("utf-8");
  11.                 System.IO.StreamReader outputReader = new System.IO.StreamReader(outputStream, outputEncoding);
  12.                 char[] chars = new Char[256];
  13.                 int readCount = outputReader.Read(chars, 0, 256);
  14.                 int totalRead = readCount;
  15.                 while(readCount > 0)
  16.                 {
  17.                     string str = new String(chars, 0, 256);
  18.                     result.Append(str);
  19.                     readCount = outputReader.Read(chars, 0, 256);
  20.                 }
  21.                 transferResponse.Close();
  22.                 outputStream.Close();
  23.                 outputReader.Close();
  24.             }
  25.             catch(Exception ex)
  26.             {
  27.                 string str = ex.Message;
  28.             }
  29.             StreamWriter fileOut = new StreamWriter("testProxy.txt");
  30.             fileOut.WriteLine(result.ToString());
  31.             fileOut.Close();

wraith808

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 8,406
  • "In my dreams, I always do it right."
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #40 on: June 29, 2009, 02:04:00 PM »
I did a bit more investigation, and was able to get it to work with custom proxy servers.  I did need to enter the domain; I just used my Active Directory Domain root, and it started working.  The default proxy servers still does not work.  I'm doing a bit of looking around- it's a pretty slick app so far!   :Thmbsup:

kartal

  • Supporting Member
  • Joined in 2008
  • **
  • Posts: 1,529
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #41 on: March 28, 2010, 12:12:33 AM »
.
Why don't try my DTT (Developer's Tips & Tricks)?  It's free...  :)

Free download from: DTT page

Best regards,
FSL

Hey this works under Linux under Wine as well :) And it seems like there is drag and drop now

robinsiebler

  • Charter Member
  • Joined in 2005
  • ***
  • Posts: 83
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #42 on: April 27, 2010, 07:23:21 PM »
Here is one that is free, simple and portable - CodeBank
Happiness is laced with shards of pain

mouser

  • First Author
  • Administrator
  • Joined in 2005
  • *****
  • Posts: 36,406
    • View Profile
    • Mouser's Software Zone on DonationCoder.com
    • Read more about this member.
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #43 on: April 28, 2010, 03:50:24 PM »
The CodeBank author (Nikola Dachev) looks like he has created a few nice programs: http://www.zeraha.org/

iphigenie

  • Supporting Member
  • Joined in 2006
  • **
  • Posts: 1,169
    • View Profile
    • Donate to Member
Re: Source Code / Code Snippet Manager
« Reply #44 on: April 29, 2010, 10:07:34 AM »
I need to try the programs in this thread

Back in the 90s I registered a neat program called webgal - it was a snippet manager organised by context, for web development. It could even contain media, so your frequently used graphics tricks could be stored with image. I tried reinstalling but i cant get the registration to work and spidersoft no longer does webgal...

Anyway, recently bought clipcache to see if i can use it for that, but will try these tools here too