Twitter library update 0.32

February 28th, 2011 No comments

[download#7#format=2]
[download#7#format=1]

Categories: Delphi stuff, Software Tags:

another twitter library update v0.31

February 27th, 2011 1 comment

v0.3:

– Added a method: RetrievePIN(user,pass), with this you can avoid the user having to login and return with an access PIN, the app will retrieve it on its own by simulating a login etc. Use with care, since this method is prone to errors whenever Twitter changes something in their login and auth process. Check usage.pas for details on when to use this.
Note: reposted with a small modification to fix an error in the preauth process, redownload if you got 0.3 before.

[download#7#format=2]
[download#7#format=1]

Here’s the magic:

procedure TwitterCli.RetrievePIN(user,pass: ansistring);
Var h: THttpCli;
    pvars,token,oatoken: ansistring;
    ts: TStringList;
    s,x: ansistring;
    a: Integer;
begin

  LastReq := trRequestRawAccess;

  FCookie := '';
  ts := TStringList.Create;
  h := THttpCli.Create(nil);
  with h do
  begin
    url := 'http://twitter.com/oauth/authorize?oauth_token='+OAuthToken;
    RcvdStream := TMemoryStream.Create;
    OnDocEnd           := HTTPClientDocEnd;
    OnHeaderEnd        := HTTPClientHeaderEnd;
    OnBeforeHeaderSend := HTTPClientBeforeHeaderSend;
    OnCookie           := GrabCookie;
    try
      Get;
    except
      on e:exception do
      begin
        if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add(e.Message);
        ResultStrings.Text := 'Error: '+e.Message;
      end;
    end;

     try
      h.RcvdStream.WriteBuffer(#0' ', 1);
      h.RcvdStream.Position := 0;
      ts.LoadFromStream(h.RcvdStream);
    finally
    end;
  end;

  if h.StatusCode <> 200 then
  begin
    LastHttpStatus := h.StatusCode;
    ResultStrings.Text := 'Error in raw authentication on 1st step';
    h.RcvdStream.Free; h.RcvdStream := nil;
    FreeAndNil(h);
    FreeAndNil(ts);
    TriggerReqDone;
    Exit;
  end;


  if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
   TMemo(DebugMemo).Lines.Add(h.Cookie);

    h.RcvdStream.Free; h.RcvdStream := nil;

  if FCookie[length(FCookie)] = ';' then Delete(FCookie,length(FCookie),1);

  if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
  begin
    TMemo(DebugMemo).Lines.Add('----------------------------------------');
    TMemo(DebugMemo).Lines.Add('----------------------------------------');
  end;

  s := ts.text;
  if Pos('twttr.form_authenticity_token', s) > 0 then
  begin
    Delete(s,1,Pos('twttr.form_authenticity_token',s)+32);
    s := Copy(s,1,Pos('''',s)-1);
  end
  else
  begin
    LastHttpStatus := 0;
    ResultStrings.Text := 'Error in raw authentication prelogin';
    h.RcvdStream.Free; h.RcvdStream := nil;
    FreeAndNil(h);
    FreeAndNil(ts);
    TriggerReqDone;
    Exit;
  end;

  ts.Clear;
  with h do
  begin
    url := 'http://twitter.com/oauth/authorize';
    RcvdStream := TMemoryStream.Create;
    SendStream := TMemoryStream.Create;
    pvars := ('authenticity_token=' + s +
             '&oauth_token=' + OAuthToken +
             '&session%5Busername_or_email%5D=' + user +
             '&session%5Bpassword%5D=' + pass);
    SendStream.Write(pvars[1], Length(pvars));
    SendStream.Seek(0, soFromBeginning);
    OnDocEnd           := HTTPClientDocEnd;
    OnHeaderEnd        := HTTPClientHeaderEnd;
    OnBeforeHeaderSend := HTTPClientBeforeHeaderSend;
    Cookie := FCookie;
    if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
     TMemo(DebugMemo).Lines.Add('Cookie before post='+FCookie);
    ExtraHeader := 'Origin:https://twitter.com' + #13#10 +
                   'Referer:http://twitter.com/oauth/authorize?oauth_token=' + OAuthToken;
    try
      Post;
    except
      on e:exception do
      begin
        if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add(e.Message);
        ResultStrings.Text := 'Error: '+e.Message;
      end;
    end;

     try
      h.RcvdStream.WriteBuffer(#0' ', 1);
      h.RcvdStream.Position := 0;
      ts.LoadFromStream(h.RcvdStream);
    finally
    end;

    x := '';
    s := ts.Text;
    if Pos('<div id="oauth_pin">',s) > 0 then
    begin
      Delete(s,1,Pos('<div id="oauth_pin">',s)+19);
      s := Copy(s,1,Pos('<',s));
      for a := 1 to length(s) do
       if (Ord(s&#91;a&#93;) > 47) and (Ord(s[a]) < 58) then
        x := x + s&#91;a&#93;;
    end;

    LastHttpStatus := h.StatusCode;

    if x = '' then LastHttpStatus := 0
    else AccessPIN := x;

    if DebugMode then if Assigned(DebugMemo) then TMemo(DebugMemo).Lines.Add('PIN='+x);

    if DebugMode then if Assigned(DebugMemo) then with TMemo(DebugMemo) do
    begin
      TMemo(DebugMemo).Lines.Add(ts.Text);
      TMemo(DebugMemo).Lines.Add(h.Cookie);
    end;

    if h.StatusCode <> 200 then ResultStrings.Text := 'Error in raw authentication on 2nd step';

    FreeAndNil(ts);
    h.RcvdStream.Free; h.RcvdStream := nil;
    h.SendStream.Free; h.SendStream := nil;
    FreeAndNil(h);
  end;

  TriggerReqDone;

end;

procedure TwitterCli.GrabCookie(Sender: TObject; const Data: string; var Accept: Boolean);
begin
  FCookie := FCookie + Data + ';';
end;
Categories: Delphi stuff, Software Tags:

twitter library update

February 27th, 2011 No comments

Slightly modified my delphi twitter library to work with the latest ICS distribution and to remove the dependency of an altered OverbyteIcsHttpProt file.

[download#7#format=2]
[download#7#format=1]

Categories: Delphi stuff, Software Tags:

Twitter library for Delphi

February 27th, 2011 45 comments

2013 fix/update: http://code.google.com/p/delphi-twitter-library/

Edit: As of December 2012 Twitter api is using GZip in every callback, so you’ll have to enable content encoding before every Get/Post call, and then load the result from a gzipped stream in the RequestDone procs.

Edit June 2012: This twitter library is now deprecated and will no longer be updated. I’ve rewritten it as a generic OAuth lib to use with both Twitter and Imgur (and any other OAuth 1.0 services) for a closed source project.

This is my take on Open Auth and Twitter for Delphi. I recently had to look into it to update a twitter plugin for my Mal Upater application, so I made this small library along with a test application TwitMee. There is barely nothing at all for Delphi, and the little
I found was overcomplicated and didn’t work with Unicode (f.e. japanese symbols etc) (my library does).

I’ve been asked by a few people to make it open source, so here’s the code, use it freely as long you comply with the GPL v3 license.

Requirements: one of the latest versions of Delphi which includes Unicode. (probably easy to adapt using Jedi’s jcl implementation
for unicode strings as well).

Read more…

Categories: Delphi stuff, Software Tags:

UPS, hard drive mirroring

February 27th, 2011 No comments

I finally did it, bought a decent UPS.

This is something I was holding up for years, for some reason, and finally decided to get one. The area I live at is quite prone to having micro power cuts whenever it rains, and it’s so extremelly annoying when the PC keeps rebooting from those, you have 930493 things open and bam, all gone; rarely any data loss since I usually save any open docs very often, but having to re-open and prepare all the apps I use etc etc, specially while programming, is really frustrating.

A couple years ago I actually bought a cheap, really cheap, UPS, and omg did it suck. It was around 35 euro; whenever there was a power cut it would last a few seconds.. 4..5 then bam, off, followed by a really loud beeeeeeeeeeeep that never turned itself off even after power came back until you pressed a switch. It’s been buried under my bed since then.

This week I bought this:

it was around 65 euro, not a fortune either, and seems to be working nicely. I tried to manually cut the power and waited a few minutes, seemed to hold up just fine. I had plugged the case, 1 of my 2 24″ lcd screens, and the DSL router to the battery-backed plugs.

The software to manage it seems a bit messy to setup and you need to figure out yourself, the documentation is severely lacking, but after playing around a bit I got it. The display for the remaining time while on battery didn’t seem to work, it never showed anything even when I cut the power; maybe it needs a few minutes to “learn”.. dunno.

A view of the status:

Along with the UPS I ordered also a 2TB disk as I was planning to get one soon, so I fit it along as there no extra shipping charge for another small item. Shipping sucks here btw, was around 20 euro for the box; usually at least ~15 is the minimum for anything from the mainland.

So, I replaced an old 500GB disk with it. I had a 50 GB partition on it that was “using” for OSX (installed, played around with for 10 minutes then never booted back); I wanted to keep it since I’d like to take a look at programming for Cocoa and the iCrap sometime, and if you ever tried to install an OSX backup you’ll know it can be a real PITA to get it working.

So I was looking for a simple app to mirror the drive or at least the osx partition; last time I used anything like that was many years ago, old norton ghost through a bootup cd with a dos-like interface etc.

I looked into a few apps, first Paragon’s Backup & Recovery, but that didn’t work. It has a few options to make backups and restore images etc, but nothing to mirror a drive. You need to first make an image into a file then it has some options to restore it, none of which let me specify my new raw disk. Then tried a few others till I found one that actually worked with no hassles: R-Drive Image

was pretty simple and straightforward. So I did the cloning, booted back into the new drive, OSX ran up just fine.

Categories: Misc Tags:

TwitMee 0.21

February 17th, 2011 No comments

New version up, fixes a couple minor bugs.

Categories: Software Tags:

TwitMee update

February 15th, 2011 No comments

version 0.2 fixes a problem with unicode messages

http://eden.fm/twitmee-0-1/

Categories: Software Tags:

TwitMee 0.1

February 14th, 2011 1 comment

Extremelly simplistic and lightweight Twitter Client. No fancy graphics and complicated settings, only send status updates. Just type and click.

– Install: no install required, just run the exe from anywhere, it will store access details and be ready to send right away next time you start it. Doesn’t need any frameworks like .net, air etc , pure win32 app.
– Supports UNICODE, you can send status updates in Japanese etc.

[download#6#format=2]

[download#6#format=1]
Categories: Software Tags:

Tiny Uploader 2.51

January 19th, 2011 No comments
Categories: Software Tags:

Tiny Uploader 2.5

January 18th, 2011 No comments
Categories: Software Tags:

New website

March 21st, 2010 No comments

Techsuki v.2

Galleries and software are being moved to this domain.

Categories: Misc Tags:

Researchers Use MRIs to Read Subject's Thoughts

January 13th, 2010 4 comments

http://www.dailytech.com/article.aspx?newsid=16358

.. A previous study had looked at using fMRI scans of parts of the brain linked to shape identification to correctly guess the a viewed image from a series of stock images.  Jack Gallant, a University of California, Berkeley neuroscientist who led the current effort, describes this previous work as similar to “the magician’s card trick where you pick a card from a deck, and he guesses which card you picked. The magician knows all the cards you could have seen.”

The new study expands this approach greatly by also scanning parts of the brain used for general classifications like “person”, “car”, or “building”.  Utilizing Bayesian probabilistic math, researchers armed with a database of over 6 million possible results and the new scans were able to go beyond identification into the realm of reconstruction, coming up with an image corresponding to what the person was thinking of, after an initial calibration to adjust for mental differences.

Categories: tehsuki import Tags:

Guide to the Large Hadron Collider

January 13th, 2010 No comments
Categories: tehsuki import Tags:

Researchers Use Excitons to Develop Superfast Circuits

January 13th, 2010 No comments

http://www.dailytech.com/article.aspx?newsid=16353

New breakthrough uses commercially achievable cold temperatures

Researchers at UC San Diego have made a breakthrough in integrated circuits using a particle type called excitons that can operate at commercially available cold temperatures. The breakthrough could one day lead to computers that are capable of running much faster than the machines we use today.

The same team made a similar discovery last summer with the development of an integrated circuit that was capable of working at 1.5 degrees Kelvin. The researchers point out that that temperature is warmer than the average temperature in space.

The new discovery is of a similar integrated circuit that can operate using excitons at 125 degrees Kelvin, equivalent to minus 234 degrees Fahrenheit. That is still a very cold temperature, but it can be achieved with commercially available liquid nitrogen. Liquid nitrogen costs about as much as gasoline. The previous discovery requiring temperatures of minus 457 degrees Fahrenheit was only achievable in specially outfitted labs.

Categories: tehsuki import Tags:

Science Lab Creates 3D Glass Printing Process

January 13th, 2010 No comments

http://www.dailytech.com/article.aspx?newsid=16340

3D printing is an interesting technology which allows engineers and designers to get a 3D object from a digital design that can be viewed in the real world. Artists also use 3D printing to make art that is designed digitally.

A team of engineers and artists working at the University of Washington’s Solheim Rapid Manufacturing Laboratory has developed a new method of using conventional 3D printers to create glass objects. A 3D printer typically uses a layer of powder that is activated by an ink jet printer that sprays a binding material at the exact location it is needed. The reaction binder adheres to the powdered and creates the object.

Categories: tehsuki import Tags: