blog.darkstar.work - a simple url encoder/decoder

 a simple url encoder/decoder
 http://blog.darkstar.work

Labels

Wirtschaft (150) Pressefreiheit (125) Österreich (120) IT (95) code (60) Staatsschulden (37) EZB (27) Pensionssystem (16)
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen
Posts mit dem Label code werden angezeigt. Alle Posts anzeigen

2016-03-30

aws CodeDeploy CodePipeline - 2 Amazon's deployment services


CodeDeploy

Warning: If you use Amazon's CodeDeploy Service outside of the US, e.g. in Ireland, you can't combine that CodeDeployment AWS Service Instance with AWS CodePipeline later, cause Amazon's Code Pipeline is only availible inside the US for now:
https://console.aws.amazon.com/codepipeline/home?region=eu-west-1#

The following sample shows you, how to use CodeDeploy in Ireland. Be free to change the region to Oregon or Virginia, if you want combine it with CodePipeline later.

https://eu-west-1.console.aws.amazon.com/codedeploy/home?region=eu-west-1#/first-run/


Create new Key-Pair in Ireland:
https://eu-west-1.console.aws.amazon.com/ec2/v2/home?region=eu-west-1#KeyPairs:sort=keyName


I choosed a sample Linux Apache Web Application Deployment

This will take a while. don't panic!


For insiders: This wizards runs really only a CloudFormation
https://eu-west-1.console.aws.amazon.com/cloudformation/home?region=eu-west-1#/stacks?filter=active


We choose here the pre default Sample from S3 please, you will see later, how we change to GitHub





We see here Deployment Configuration


OK, yet we finished the default wizard and are under Deployments
https://eu-west-1.console.aws.amazon.com/codedeploy/home?region=eu-west-1#/deployments

We create now a new Deployment for GitHub repository (instead default S3)
https://eu-west-1.console.aws.amazon.com/codedeploy/home?region=eu-west-1#/deployments/new

OK. I have used my GitHub PlayGround here
https://github.com/heinrichelsigan/AWSCodeDeploy
Feel free to create your own and play!

OK, we create now the new Deployment from GitHub

After creating the new Deployment, we are back at Deployments page in Ireland:
https://eu-west-1.console.aws.amazon.com/codedeploy/home?region=eu-west-1#/deployments




We can look now at e2c instances menu, to see our fresh deployed instances:
https://eu-west-1.console.aws.amazon.com/ec2/v2/home?region=eu-west-1#Instances:sort=instanceId


CodePipeline

As I mentioned at the beginning Amazon's CodePipeline service is at the moment only availible inside the US at two locations:


We create here our Virginia CodePipeLine Demo Sample 
 CodePipeLine Demo Wizard let you choose directly different pre defined source repositories:

I took my GitHub PlayGround


You can choose some pre defined build servers here, if you like to fetch uncompiled code from your repository and build it with a cloud build service.
Attention: Cloud Build is only very beta compared to a full professionell lan build server.
Warning: Take care, that you deliver your source code (maybe with TOP secret database or config keys or some very snakeoiled intelectual property claims on source maybe without clearly license agreement) for build through the net to a blackbox and got a magical yet another black box compiler compiled snakeoils linked build (you will never find out, what secret different snakeoils and serpentoils they mixed to in to build your code, maybe compiled to use highest CPU Power, so that your cloud provider could make business :) out of this blackbox!





Now your Pipeline appears in dashboard (don't type daeshboard, cause then police stands before your flat in the night :)
https://console.aws.amazon.com/codepipeline/home?region=us-east-1#/dashboard



2015-04-29

Performance of reading a registry key?

Performance of reading a registry key?

using (RegistryKey registryKey = Registry.CurrentUser.OpenSubKey(@"Software/Copium")) { return (string)registryKey.GetValue("BinDir"); }

The registry is a convenient place to record persistent cross-process data in a uniform and multi-thread-safe manner. It roams with the user if you store it in HKEY_CURRENT_USER, and individual keys can be secured (even on systems that use FAT, which doesn't otherwise support security).
But that doesn't mean that it's free.
The cost of opening a key, reading a value, and closing it is around 60,000 to 100,000 cycles (I'm told). And that's assuming the key you're looking for is in the cache. If you open the key and hold it open, then the act of reading a value costs around 15,000 to 20,000 cycles. (These numbers are estimates for Windows XP; actual mileage may vary.)
Consequently, you shouldn't be reading a registry key in your inner loop. Not only does it cost you CPU time at query time, but the constant hammering of the registry means that the data structures used by the registry to locate and store your key (including the entry in the registry cache) are kept in the system working set. Don't read a registry key on every mouse move; read the value once and cache the result. If you need to worry about somebody changing the value while your program is running, you can establish a protocol for people to follow when they want to change a setting. Windows, for example, uses functions such as SystemParametersInfo to manipulate settings that are normally cached rather than read from the registry each time they are needed. Calling the update function both updates the registry and the in-memory cache. If you can't establish a mechanism for coordinating changes to the setting, you can set a change notification via the RegNotifyChangeKeyValue function so that you are notified when the value changes.
Whenever possible, optimize for the common case, not the rare case. The common case is that the registry value hasn't changed. By using a notification mechanism, you move the cost of "But what if the value changed?" out of your inner loop and into code that doesn't execute most of the time. (Remember, the fastest code is code that never runs.)
Of course, you don't want to burn a thread waiting on the notification event. I use the thread pool. The RegisterWaitForSingleObject function lets you tell the thread pool, "Hey, could you call me when this object is signalled? Thanks." The thread pool then does the work of combining this with all the other handles it has been asked to wait for into a giant WaitForMultipleObjects call. That way, one thread can handle multiple waits.
One caveat to heed with the RegNotifyChangeKeyValue function is that the notification has thread affinity! If the thread that calls the RegNotifyChangeKeyValue function exits, the notification is raised. This means that you shouldn't call the function from a thread pool thread, since the system will destroy threads in the thread pool when the work list goes idle and their presence is no longer needed. If you mess up and call it from a thread pool thread, you'll find that the event keeps firing spuriously as the thread pool cleanup code runs, making the cure as bad as the disease! Instead, you should create the wait from a persistent thread (say, the thread that actually cares about the value!) and register the wait there. When the event fires on the thread pool, handle the change, then ask your persistent thread to start a new cycle of RegNotifyChangeKeyValue. That way, the event is always associated with your persistent thread instead of with a transient thread pool thread.


Create/Edit Windows Registry Keys for TCP/IP Performance Tuning

This topic describes how to tune Windows 2000, Windows XP, and Windows 2003 operating systems for TCP/IP performance. To add a key to the registry, you can either edit it directly as described below or create and execute a .reg file. When you have finished adding or editing these registry keys, you will need to restart the Server. Configure the following settings or variables below according to your specific tuning needs. If necessary, refer to the GlobalSCAPE Knowledge Base article Q10411 - HOWTO: Windows Registry Settings, for the procedure for creating/editing keys and creating a .reg file.

TcpTimedWaitDelay

This key determines the time that must elapse before TCP/IP can release a closed connection and reuse its resources. This interval between closure and release is known as the TIME_WAIT state or twice the maximum segment lifetime (2MSL) state. During this time, reopening the connection to the client and server costs less than establishing a new connection. By reducing the value of this entry, TCP/IP can release closed connections faster and provide more resources for new connections. Adjust this parameter if the running application requires rapid release, the creation of new connections, or an adjustment because of a low throughput caused by multiple connections in the TIME_WAIT state.
To activate this feature, create the following key:
Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters
Value name:
TcpTimedWaitDelay
Value data:
0x0000001e (Hex 0x0000001e = decimal 30. This value sets the wait time to 30 seconds.)

MaxUserPort

This key determines the highest port number that TCP/IP can assign when an application requests an available user port from the system.
To activate this feature, create the following key:
Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TCPIP\Parameters
Value name:
MaxUserPort
Value data:
(minimum) 32768

MaxConnect Backlog

These keys, if many connection attempts are received simultaneously, increase the default number of pending connections that are supported by the operating system.
To activate this feature, create the following 4 keys:
Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AFD\Parameters
Value name:
EnableDynamicBacklog
Value data:
00000001
Value name:
MinimumDynamicBacklog
Value data:
00000020
Value name:
MaximumDynamicBacklog
Value data:
00001000
Value name:
DynamicBacklogGrowthDelta
Value data:
00000010
These values request a minimum of 20 and a maximum of 1000 available connections. The number of available connections is increased by 10 each time that there are fewer than the minimum number of available connections.

KeepAliveInterval

This key determines how often TCP repeats keep-alive transmissions when no response is received.
To activate this feature, create the following key:
Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\AFD\Parameters
Value name:
KeepAliveInterval
Value data:
1 (second)

TcpMaxDataRetranmission

This key determines how many times TCP retransmits an unacknowledged data segment on an existing connection.
To activate this feature, create the following key:
Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Value name:
TcpMaxDataRetransmissions
Value data:
5 (seconds)

TPC/IP Acknowledgements

TCP/IP can be the source of some significant remote method delays. You can increase TCP performance by immediately acknowledging incoming TCP segments, in all situations.
To activate this feature, create the following key:

On Microsoft Windows 2000:

Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{Interface GUID}\
Value name:
TcpDelAckTicks
Value data:
0

On Microsoft Windows XP or Windows Server 2003:

Subkey:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces\{Interface GUID}
Value name:
TcpAckFrequency
Value data:
0

Links:
http://blogs.msdn.com/b/oldnewthing/archive/2006/02/22/536920.aspx

http://www.computerperformance.co.uk/windows7/windows7_delete_roaming_profile.htm
http://en.kioskea.net/faq/7106-windows-7-increase-the-performance-of-disk-cache

2014-11-03

freedom & democracy!

Wenn man sieht, wer im syrischen Bürgerkrieg kämpft (Islamischer Staat, al-Nusra-Front,  Islamische Befreiungsfront, Hissbolah, Dschabhat al-Kurdiya, Taliban Ableger Al-shaddad, Diktator Assad, ...) und alle teils gegeneinander sponsered by USA, Türkei, Iran, Russland,  Saudi Arabien, dann klingt das nach dem Gipfeltreffen der weltweit schlimmsten Terroristen. Kein Wunder, dass es so viele Flüchtlinge und kaum noch moderate Kräfte gibt! Es ist bewundernswert, wie es die Kurden schafften zwischen all diesen wahnsinnigen Meuchelmördern nicht zu radikalisieren.


Wenn man die schlimmsten Terrororganisationen sponsert, 
erhält man nie,
freedom & democracy!

Syrien: 200.000 Tote und zirka 4 Millionen Flüchtlinge

2014-07-19

a simple twitter login tester in C#

using System.Collections.Generic;
using System.Collections.Specialized;
using System.Net;
using System.IO;
using System.Web;
using System.Windows.Forms;
// [...]

namespace TweetBotTestForm
{
    public partial class Form1 : Form
    {
        const string AUTHURL = "https://twitter.com/sessions";

        public Form1()
        {
            InitializeComponent();
            this.textUsername.Text = "AAA@BBB";
            this.textPassword.Text = "XXXXXXX";
        }
    

        private void buttonLogin_Click(object sender, EventArgs e)
        {
            this.textOutput.Clear();
            this.textOutput.Text = string.Format(
                "Posting Username \'{0}\' Password \'{1}\' in {2}\r\n\n",
                this.textUsername.Text, this.textPassword.Text, AUTHURL);

            Dictionary<string, string> postParams =
                new Dictionary<string, string>();

            postParams.Add("session[username_or_email]", textUsername.Text);
            postParams.Add("session[password]", textPassword.Text);
            postParams.Add("remember_me", "0");
            postParams.Add("redirect_after_login", "/");

            string responseText = this.HttpPostLogin(AUTHURL, postParams);
            this.textOutput.Text += "AuthToken: " + responseText + "\r\n\n";

            string webResultText = this.LoginTweet(AUTHURL,
                this.textUsername.Text, this.textPassword.Text);
            this.textOutput.Text += "WebClient: " + webResultText + "\r\n\n";

        }       

        /// <summary>
        /// twitter login test
        /// by using System.Net.WebClient class
        /// </summary>
        /// <param name="authUrl">twitter session url</param>
        /// <param name="username">username</param>
        /// <param name="password">password</param>
        /// <returns>AuthToken</returns>
        protected string LoginTweet(
            string authUrl,
            string username,
            string password
        )
        {
            WebClient webClient = new WebClient();

            NameValueCollection formData = new NameValueCollection();
            // formData["authenticity_token"] = "3f962756ee8ab2afb0e0cb35ae1c97117844a6c7";
            formData["remember_me"] = "0";
            formData["redirect_after_login"] = "/";
            formData["return_to_ssl"] = "false";
            formData["scribe_log"] = string.Empty;
            formData["session[username_or_email]"] = username;
            formData["session[password]"] = password;

           
            byte[] responseBytes =
                webClient.UploadValues(authUrl, "POST", formData);
            string result = Encoding.UTF8.GetString(responseBytes);

            webClient.Dispose();

            string authResponse = ParseTwitterSession(ref result);

            return authResponse; // result;
        }

        /// <summary>
        /// twitter login test
        /// by using System.Net.HttpWebRequest/HttpWebResponse class
        /// </summary>
        /// <param name="authUrl"></param>
        /// <param name="postParameters"></param>
        /// <returns></returns>
        protected string HttpPostLogin(
            string authUrl,
            Dictionary<string, string> postParameters
        )
        {
            string postData = "";

            foreach (string key in postParameters.Keys)
            {
                postData += HttpUtility.UrlEncode(key) + "="
                      + HttpUtility.UrlEncode(postParameters[key]) + "&";
            }

            HttpWebRequest myHttpWebRequest =
                (HttpWebRequest)HttpWebRequest.Create(authUrl);
            myHttpWebRequest.Method = "POST";

            byte[] data = Encoding.ASCII.GetBytes(postData);

            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            myHttpWebRequest.ContentLength = data.Length;

            Stream requestStream = myHttpWebRequest.GetRequestStream();
            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            HttpWebResponse myHttpWebResponse =
                (HttpWebResponse)myHttpWebRequest.GetResponse();

            this.textOutput.Text += "\r\n Cookie Count = " +
                myHttpWebResponse.Cookies.Count.ToString();
            this.textOutput.Text += "\r\n Header = " +
                myHttpWebResponse.Headers.ToString();
            this.textOutput.Text += "\r\n";

            Stream responseStream = myHttpWebResponse.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(
                responseStream,
                Encoding.Default
            );
            string pageContent = myStreamReader.ReadToEnd();

            myStreamReader.Close();
            responseStream.Close();
            myHttpWebResponse.Close();

            string authResponse = ParseTwitterSession(ref pageContent);

            return authResponse; // pageContent;
        }


        /// <summary>
        /// Dummy html code in response parsing
        /// very quick & dirty implemented
        /// </summary>
        /// <param name="pageContent">html response from webclient</param>
        /// <returns>authentication_token</returns>
        protected static string ParseTwitterSession(ref string pageContent)
        {
            string authResponse = string.Empty;
            if (pageContent.IndexOf("authenticity_token") < 0)
            {
                return authResponse;
            }
            pageContent = pageContent.Substring(

                pageContent.IndexOf("authenticity_token") + 18);

            while (pageContent.IndexOf("value=\"") > -1)
            {
                pageContent = pageContent.Substring(
                    pageContent.IndexOf("value=") + 8
                );
                if (pageContent.IndexOf('\"') > -1)
                {
                    string valueString =
                        pageContent.Substring(
                            0,
                            pageContent.IndexOf("\"")
                        );

                    if (valueString.Length > 37)
                    {
                        authResponse = valueString;
                        break;
                    }
                }
                else
                {
                    authResponse = string.Empty;
                    break;
                }
            }
            return authResponse;
        }

    }
}



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Collections.Specialized;
using System.Net;
using System.IO;
using System.Web;

namespace TwitterTestLogon
{
    public partial class TweetLogin : Form
    {
        const string AUTHURL = "https://twitter.com/sessions";

        public TweetLogin()
        {
            InitializeComponent();
            this.textUsername.Text = "myemail@mydomain.org";
            this.textPassword.Text = "mypassword";
        }
  

        /// <summary>
        /// event that is fired, when buttonLogin clicked
        /// </summary>
        /// <param name="sender">sender, that fires event</param>
        /// <param name="e">EventArgs e</param>
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            this.textOutput.Clear();
            this.textOutput.Text = string.Format(
                "Posting Username \'{0}\' Password \'{1}\' in {2}\r\n\n",
                this.textUsername.Text, this.textPassword.Text, AUTHURL);

            // create Dictionary<string, string> postParams with default parameters to post for twitter login
            Dictionary<string, string> postParams = new Dictionary<string, string>();
            postParams.Add("session[username_or_email]", textUsername.Text);
            postParams.Add("session[password]", textPassword.Text);
            postParams.Add("remember_me", "0");
            postParams.Add("redirect_after_login", "/");
            postParams.Add("return_to_ssl", "false");
            // postParams.Add("scribe_log", string.Empty);


            // get authentication Parameters from twitter Login via HttpPostLogin(AUTHURL, postParams);
            Dictionary<string, string> authTwitterParams = this.HttpPostLogin(AUTHURL, postParams);
            // write authentication Parameters to TextBox textOutput
            this.textOutput.Text += "\r\nTwitter Login POSTING via HttpWebRequest: \r\n";
            foreach (string ikey in authTwitterParams.Keys)
            {
                string ivalue =  authTwitterParams[ikey];
                this.textOutput.Text += ikey + " \t= "
                    + authTwitterParams[ikey] + "\r\n";
                
                try
                {
                    // add 4 authentication twitter parameters to postParams
                    if (ikey.StartsWith("Set-Cookie"))
                    {
                        string guest_id = HttpUtility.UrlDecode(ParseTwitterSession(ivalue, "guest_id"));
                        postParams.Add("guest_id", guest_id);
                        this.textOutput.Text += "guest_id" + " \t= " + guest_id + "\r\n";

                        string _twitter_sess = ParseTwitterSession(ivalue, "_twitter_sess");
                        postParams.Add("_twitter_sess", _twitter_sess);
                        this.textOutput.Text += "_twitter_sess" + " \t= " + _twitter_sess + "\r\n";

                        string ct0 = ParseTwitterSession(ivalue, "ct0");
                        postParams.Add("ct0", ct0);
                        this.textOutput.Text += "ct0" + " \t= " + ct0 + "\r\n";

                        string tdomain  = ParseTwitterSession(ivalue, "Domain");
                        postParams.Add("Domain", tdomain);
                        this.textOutput.Text += "Domain" + " \t= " + tdomain + "\r\n";
                    }   
                }
                catch (Exception ex)
                {
                    this.textOutput.Text += "\r\nException: " + ex.ToString() + "\r\n";
                }
            }

            // pass postParams from Dictionary<string, string> to NameValueCollection formData 
            NameValueCollection formData = new NameValueCollection();
            foreach (string pkey in postParams.Keys) { formData[pkey] = postParams[pkey]; }

            // get authentication Parameters from twitter Login via WebClientLoginTwitter(AUTHURL, formData);
            Dictionary<string, string> gotAuthParams = this.WebClientLoginTwitter(AUTHURL, formData);
            // write authentication Parameters to TextBox textOutput
            this.textOutput.Text += "\r\nTwitter Login POSTING via WebClient: \r\n";
            foreach (string ikey in gotAuthParams.Keys)
            {
                this.textOutput.Text += ikey + " \t= "
                        + gotAuthParams[ikey] + "\r\n";
            }            

        }
  

        /// <summary>
        /// twitter login test
        /// by using System.Net.HttpWebRequest/HttpWebResponse class
        /// </summary>
        /// <param name="authUrl">twitter session url</param>
        /// <param name="postParameters">parameter collection, that will be POSTed urlencoded to requested authUrl</param>
        /// <returns>Dictionary<string, string> authParams from response Headers and authenticity_token from response body</returns>
        protected Dictionary<string, string> HttpPostLogin(
   string authUrl, 
   Dictionary<string, string> postParameters
  )
        {
            string postData = "";
            // add all postParameters as an UrlEncoded string
            foreach (string key in postParameters.Keys)
            {
                postData += HttpUtility.UrlEncode(key) + "="
                      + HttpUtility.UrlEncode(postParameters[key]) + "&";
            }
            // get postData as byte[]
            byte[] data = Encoding.ASCII.GetBytes(postData);

            // create HttpWebRequest via authUrl // set POST Method, ContentType, ContentLength
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)HttpWebRequest.Create(authUrl); 
            myHttpWebRequest.Method = "POST";
            myHttpWebRequest.ContentType = "application/x-www-form-urlencoded";
            myHttpWebRequest.ContentLength = data.Length;

            // Write postParameters as byte[] to RequestStream of created HttpWebRequest
            Stream requestStream = myHttpWebRequest.GetRequestStream();
            requestStream.Write(data, 0, data.Length);
            requestStream.Close();

            // get HttpWebResponse now from HttpWebRequest
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();

            // create twitterResponseHeaders Dictionary<string, string> 
            Dictionary<string, string> twitterResponseHeaders = new Dictionary<string, string>();

            // add key values from HttpWebResponse.Headers to twitterResponseHeaders Dictionary<string, string> 
            foreach (string hkey in myHttpWebResponse.Headers.AllKeys)
            {
                string hvalue = myHttpWebResponse.Headers[hkey];
                twitterResponseHeaders.Add(hkey, hvalue);
            }

            // get ResponseStream from HttpWebResponsem, read Content of ResponseStream and store it in string pageContent
            Stream responseStream = myHttpWebResponse.GetResponseStream();
            StreamReader myStreamReader = new StreamReader(responseStream, Encoding.Default);
            string pageContent = myStreamReader.ReadToEnd();
            myStreamReader.Close();
            responseStream.Close();

            // close HttpWebResponse received from HttpWebRequest
            myHttpWebResponse.Close();

            // parse authenticity_token hidden form value from received pageContent
            string authenticity_token = ParseTwitterAuthValue(ref pageContent, "authenticity_token");
            // and add it to twitterResponseHeaders Dictionary<string, string> 
            twitterResponseHeaders.Add("authenticity_token", authenticity_token);

            return twitterResponseHeaders; // pageContent;
        }
  

        /// <summary>
        /// twitter login test
        /// using System.Net.WebClient class
        /// </summary>
        /// <param name="authUrl">twitter session url</param>
        /// <param name="authParams">parameter collection, that will be POSTed as NameValueCollection formData to requested authUrl</param>
        /// <returns>Dictionary<string, string> authParams from response Headers and authenticity_token from response body</returns>
        protected Dictionary<string, string> WebClientLoginTwitter(
   string authUrl, 
   NameValueCollection formData
  )
        {
            WebClient webClient = new WebClient();

            // add authParams to NameValueCollection formData
           

            // POST to authUrl pairs in NameValueCollection formData via WebClient.UploadValues
            byte[] responseBytes = webClient.UploadValues(authUrl, "POST", formData);
            string result = Encoding.UTF8.GetString(responseBytes);

            Dictionary<string, string> responseHeaders = new Dictionary<string, string>();
            for (int rh = 0; rh < webClient.ResponseHeaders.Keys.Count; rh++)
            {
                string rhkey = webClient.ResponseHeaders.Keys[rh];
                string rhvalue = webClient.ResponseHeaders[rhkey];
                responseHeaders.Add(rhkey, rhvalue);
            }

            webClient.Dispose();
            
            string authResponse = ParseTwitterAuthValue(ref result, "authenticity_token");
            responseHeaders.Add("authenticity_token", authResponse);

            return responseHeaders; // result;
        }

  
        /// <summary>
        /// Dummy html code in response parsing
        /// very quick & dirty implemented
        /// </summary>
        /// <param name="pageContent">html response from webclient or httpwebresponse</param>
        /// <returns>authentication_token</returns>
        protected static string ParseTwitterAuthValue(ref string pageContent, string parseString)
        {
            int parseStringLength = parseString.Length; 
            if (string.IsNullOrEmpty(parseString) || (parseStringLength < 2)) {
                throw new ArgumentException("ParseTwitterSession(ref string pageContent, string parseString)\r\n, parseString is null, empty or to short for parse...");
            }
            
            string authResponse = string.Empty;
            if (pageContent.IndexOf(parseString) < 0)
            {
                return authResponse;
            }
            pageContent = pageContent.Substring(
                pageContent.IndexOf(parseString) + parseStringLength);

            while (pageContent.IndexOf("value=\"") > -1)
            {
                pageContent = pageContent.Substring(
                    pageContent.IndexOf("value=") + 8
                );
                if (pageContent.IndexOf('\"') > -1)
                {
                    string valueString =
                        pageContent.Substring(
                            0,
                            pageContent.IndexOf("\"")
                        );

                    if (valueString.Length > 37)
                    {
                        authResponse = valueString;
                        break;
                    }
                }
                else
                {
                    authResponse = string.Empty;
                    break;
                }
            }
            return authResponse;
        }

  
        /// <summary>
        /// Dummy html code in response parsing
        /// very quick & dirty implemented
        /// </summary>
        /// <param name="pageContent">html response from webclient or httpwebresponse</param>
        /// <returns>authentication_token</returns>
        protected static string ParseTwitterSession(string contentForSearch, string parseString)
        {
            int parseStringLength = parseString.Length;
            if (string.IsNullOrEmpty(parseString) || (parseStringLength < 2))
            {
                throw new ArgumentException("ParseTwitterSession(ref string pageContent, string parseString)\r\n, parseString is null, empty or to short for parse...");
            }
            string content2Parse = contentForSearch;
            string parsedValue = string.Empty;

            if (content2Parse.IndexOf(parseString) < 0)
            {
                return parsedValue;
            }
            content2Parse = content2Parse.Substring(
                content2Parse.IndexOf(parseString) + parseStringLength);

            while (content2Parse.IndexOf("=") > -1)
            {
                content2Parse = content2Parse.Substring(
                    content2Parse.IndexOf("=") + 1
                );
                if (content2Parse.IndexOf(';') > -1)
                {
                    string valueString =
                        content2Parse.Substring(
                            0,
                            content2Parse.IndexOf(";")
                        );

                    if (valueString.Length > 1)
                    {
                        parsedValue = valueString;
                        break;
                    }
                }
                else
                {
                    parsedValue = content2Parse;
                    break;
                }
            }
            return parsedValue;
        }

    }
}