<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: hacks code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Thu, 24 Jul 2008 08:57:47 GMT</pubDate>
    <description>DZone Snippets: hacks code</description>
    <item>
      <title>CSS Hacks for opacity</title>
      <link>http://snippets.dzone.com/posts/show/3957</link>
      <description>in Internet Explorer 4, Gecko-based browsers, and Safari.&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#transparent {&lt;br /&gt;    filter: alpha(opacity=50);&lt;br /&gt;    -moz-opacity: 0.5;&lt;br /&gt;    opacity: 0.5;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 05 May 2007 05:58:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3957</guid>
      <author>Adios (Adios , T.)</author>
    </item>
    <item>
      <title>Float to_s hack for easy sprintf'ing</title>
      <link>http://snippets.dzone.com/posts/show/3810</link>
      <description> Float Hacks:&lt;br /&gt; 1. to_s override.&lt;br /&gt;I really hate using sprintf, mainly because i always have to go online&lt;br /&gt;and look up the syntax.  I figured i could make that a little easier.&lt;br /&gt;Now you can print floats with different precision as easily as:&lt;br /&gt;		&lt;br /&gt;4.123456.to_s(1)	# =&gt; "4.1"&lt;br /&gt;4.123456.to_s(3)	# =&gt; "4.12"&lt;br /&gt;4.123456.to_s(3)	# =&gt; "4.123"&lt;br /&gt;4.123456.to_s(4)	# =&gt; "4.1235" (Note the auto rounding from 4.123456)&lt;br /&gt;4.123456.to_s		# =&gt; "4.123456"&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Float&lt;br /&gt;  alias_method :orig_to_s, :to_s&lt;br /&gt;  def to_s(arg = nil)&lt;br /&gt;    if arg.nil?&lt;br /&gt;      orig_to_s&lt;br /&gt;    else&lt;br /&gt;      sprintf("%.#{arg}f", self)&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;I have packaged this and other useful hacks into a plugin at http://blog.djdossiers.com/articles/2007/03/31/new-rails-plugin-jakes-toolbox&lt;br /&gt;&lt;br /&gt;Peace&lt;br /&gt;&lt;br /&gt;--jake</description>
      <pubDate>Thu, 12 Apr 2007 20:50:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3810</guid>
      <author>jake3030 (Jake Varghese)</author>
    </item>
    <item>
      <title>Hash Referencing Hack for Ruby</title>
      <link>http://snippets.dzone.com/posts/show/3809</link>
      <description> Hash Hacks:&lt;br /&gt; 1.  Method Missing hack to allow easy referencing.&lt;br /&gt; I can never remember whether the Hash i am playing with has symbols for keys or &lt;br /&gt; strings. I also dont like typing the brackets (not all text editors have the &lt;br /&gt; cool "close brace" feature).  That's why i came up with this method missing hack.  &lt;br /&gt; Instead of explaining what it does, I'll just show you.&lt;br /&gt; 		&lt;br /&gt; Example:&lt;br /&gt; hsh =  {"project"=&gt;&lt;br /&gt; 		{ "prototype_url"=&gt;nil, &lt;br /&gt; 		"designer_id"=&gt;2, &lt;br /&gt; 		"finished_at"=&gt;nil,  									"phone_number"=&gt;"512225555", &lt;br /&gt;		 "website"=&gt;"http://www.ggg.com", &lt;br /&gt;		 "first_name"=&gt;"test", &lt;br /&gt; 		}&lt;br /&gt; 					}&lt;br /&gt; hsh.project&lt;br /&gt;#=&gt;  {"prototype_url"=&gt;nil, "designer_id"=&gt;2, "finished_at"=&gt;nil, "phone_number"=&gt;"512225555", "website"=&gt;"http://www.ggg.com", "first_name"=&gt;"test"}&lt;br /&gt; 	&lt;br /&gt;hsh.project.prototype_url #=&gt; nil&lt;br /&gt;hsh.project.designer_id 	#=&gt; 2&lt;br /&gt;hsh.project.first_name 		#=&gt; test&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;class Hash    		&lt;br /&gt;  def method_missing(method_id, *args, &amp;block)&lt;br /&gt;    method_name = method_id.to_s&lt;br /&gt;    check = self.stringify_keys&lt;br /&gt;    if check.keys.include?(method_name)&lt;br /&gt;      check[method_name]&lt;br /&gt;    else&lt;br /&gt;      super&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I have packaged this and other useful hacks into a plugin at http://blog.djdossiers.com/articles/2007/03/31/new-rails-plugin-jakes-toolbox&lt;br /&gt;&lt;br /&gt;Peace&lt;br /&gt;&lt;br /&gt;--jake&lt;br /&gt;</description>
      <pubDate>Thu, 12 Apr 2007 20:49:16 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3809</guid>
      <author>jake3030 (Jake Varghese)</author>
    </item>
    <item>
      <title>CSS filtering</title>
      <link>http://snippets.dzone.com/posts/show/1981</link>
      <description>I'm a big fan of keeping all css hacks out of the main stylsheet.&lt;br /&gt;&lt;br /&gt;To target IE6, you must use a conditional comment&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;!--[if IE 6]&gt;&lt;link rel="stylesheet" href="ie6.css" media="screen" type="text/css" /&gt;&lt;![endif]--&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;To target IE5, you can use a conditional comment or the following filters:&lt;br /&gt;&lt;br /&gt;Just IE5&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@media tty {&lt;br /&gt;  i{content:"\";/*" "*/}}; @import 'ie5.css'; {;}/*";}&lt;br /&gt;}/* */ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Just IE5.5&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@media tty {&lt;br /&gt;  i{content:"\";/*" "*/}}@m; @import 'ie5-5.css'; /*";}&lt;br /&gt;}/* */ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Both IE5 and IE5.5 (this is my preferred method)&lt;br /&gt;&lt;code&gt;&lt;br /&gt;@media tty {&lt;br /&gt;  i{content:"\";/*" "*/}} @import 'midpassbefore.css'; /*";}&lt;br /&gt;}/* */ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;IE5 for the Mac does not have a conditional comment, so a css filter can be used&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/*\*//*/&lt;br /&gt;  @import "ie5mac.css";&lt;br /&gt;/**/&lt;br /&gt;&lt;/code&gt; &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;A solution:&lt;br /&gt;HTML&lt;br /&gt;&lt;code&gt;&lt;br /&gt;&lt;head&gt;&lt;br /&gt;  ...&lt;br /&gt;  &lt;link rel="stylesheet" href="media.css" media="screen,projection" type="text/css" /&gt;&lt;br /&gt;  &lt;link rel="stylesheet" href="iehacks.css" media="screen" type="text/css" /&gt;&lt;br /&gt;  &lt;!--[if IE 6]&gt;&lt;link rel="stylesheet" href="ie6.css" media="screen" type="text/css" /&gt;&lt;![endif]--&gt;&lt;br /&gt;  &lt;link rel="stylesheet" href="/assets/css/print.css" media="print" type="text/css" /&gt;&lt;br /&gt;&lt;/head&gt; &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;iehacks.css&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/******* IE5/mac stylesheet ************/&lt;br /&gt;/*\*//*/&lt;br /&gt;  @import "ie5mac.css";&lt;br /&gt;/**/&lt;br /&gt;/******* IE5 Windows *******************/&lt;br /&gt;@media tty {&lt;br /&gt;  i{content:"\";/*" "*/}} @import 'midpassbefore.css'; /*";}&lt;br /&gt;}/* */ &lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;sources:&lt;br /&gt;http://tantek.com/CSS/Examples/ie50winbandpass.html&lt;br /&gt;http://tantek.com/CSS/Examples/ie55winbandpass.html&lt;br /&gt;http://www.stopdesign.com/examples/ie5mac-bpf/&lt;br /&gt;http://tantek.com/CSS/Examples/midpass.html&lt;br /&gt;http://www.dithered.com/css_filters/index.html</description>
      <pubDate>Fri, 05 May 2006 02:14:20 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1981</guid>
      <author>jbjaaz ()</author>
    </item>
    <item>
      <title>Clear Fix</title>
      <link>http://snippets.dzone.com/posts/show/1728</link>
      <description>// Clears floats that do not automatically force the container's bottom edge down as the float is made taller. &lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;/* Hacks/Misc */&lt;br /&gt;.cf:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }&lt;br /&gt;* html .cf {height: 1%;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 23 Mar 2006 01:26:55 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1728</guid>
      <author>chicken ()</author>
    </item>
    <item>
      <title>MSN Messenger Password Decrypter for Windows XP &amp; 2003</title>
      <link>http://snippets.dzone.com/posts/show/1007</link>
      <description>// MSN Messenger Password Decrypter for Windows XP &amp; 2003&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt; /*&lt;br /&gt; *  MSN Messenger Password Decrypter for Windows XP &amp; 2003&lt;br /&gt; *  (Compiled-VC++ 7.0, tested on WinXP SP2, MSN Messenger 7.0)&lt;br /&gt; *      - Gregory R. Panakkal&lt;br /&gt; *        http://www.crapware.tk/&lt;br /&gt; *        http://www.infogreg.com/&lt;br /&gt; */&lt;br /&gt;&lt;br /&gt;#include &lt;windows.h&gt;&lt;br /&gt;#include &lt;wincrypt.h&gt;&lt;br /&gt;#include &lt;stdio.h&gt;&lt;br /&gt;&lt;br /&gt;#pragma comment(lib, "Crypt32.lib")&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;//Following definitions taken from wincred.h&lt;br /&gt;//[available only in Oct 2002 MS Platform SDK / LCC-Win32 Includes]&lt;br /&gt;&lt;br /&gt;typedef struct _CREDENTIAL_ATTRIBUTEA {&lt;br /&gt;    LPSTR Keyword;&lt;br /&gt;    DWORD Flags;&lt;br /&gt;    DWORD ValueSize;&lt;br /&gt;    LPBYTE Value;&lt;br /&gt;}&lt;br /&gt;CREDENTIAL_ATTRIBUTEA,*PCREDENTIAL_ATTRIBUTEA;&lt;br /&gt;&lt;br /&gt;typedef struct _CREDENTIALA {&lt;br /&gt;    DWORD Flags;&lt;br /&gt;    DWORD Type;&lt;br /&gt;    LPSTR TargetName;&lt;br /&gt;    LPSTR Comment;&lt;br /&gt;    FILETIME LastWritten;&lt;br /&gt;    DWORD CredentialBlobSize;&lt;br /&gt;    LPBYTE CredentialBlob;&lt;br /&gt;    DWORD Persist;&lt;br /&gt;    DWORD AttributeCount;&lt;br /&gt;    PCREDENTIAL_ATTRIBUTEA Attributes;&lt;br /&gt;    LPSTR TargetAlias;&lt;br /&gt;    LPSTR UserName;&lt;br /&gt;} CREDENTIALA,*PCREDENTIALA;&lt;br /&gt;&lt;br /&gt;typedef CREDENTIALA CREDENTIAL;&lt;br /&gt;typedef PCREDENTIALA PCREDENTIAL;&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;typedef BOOL (WINAPI *typeCredEnumerateA)(LPCTSTR, DWORD, DWORD *, PCREDENTIALA **);&lt;br /&gt;typedef BOOL (WINAPI *typeCredReadA)(LPCTSTR, DWORD, DWORD, PCREDENTIALA *);&lt;br /&gt;typedef VOID (WINAPI *typeCredFree)(PVOID);&lt;br /&gt;&lt;br /&gt;typeCredEnumerateA pfCredEnumerateA;&lt;br /&gt;typeCredReadA pfCredReadA;&lt;br /&gt;typeCredFree pfCredFree;&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////////////////////////////&lt;br /&gt;&lt;br /&gt;void showBanner()&lt;br /&gt;{&lt;br /&gt;    printf("MSN Messenger Password Decrypter for Windows XP/2003\n");&lt;br /&gt;    printf("   - Gregory R. Panakkal, http://www.infogreg.com \n\n");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;////////////////////////////////////////////////////////////////////&lt;br /&gt;int main()&lt;br /&gt;{&lt;br /&gt;    PCREDENTIAL *CredentialCollection = NULL;&lt;br /&gt;    DATA_BLOB blobCrypt, blobPlainText, blobEntropy;&lt;br /&gt;&lt;br /&gt;    //used for filling up blobEntropy&lt;br /&gt;    char szEntropyStringSeed[37] = "82BD0E67-9FEA-4748-8672-D5EFE5B779B0"; //credui.dll&lt;br /&gt;    short int EntropyData[37];&lt;br /&gt;    short int tmp;&lt;br /&gt;&lt;br /&gt;    HMODULE hDLL;&lt;br /&gt;    DWORD Count, i;&lt;br /&gt;&lt;br /&gt;    showBanner();&lt;br /&gt;&lt;br /&gt;    //Locate CredEnumerate, CredRead, CredFree from advapi32.dll&lt;br /&gt;    if( hDLL = LoadLibrary("advapi32.dll") )&lt;br /&gt;    {&lt;br /&gt;        pfCredEnumerateA = (typeCredEnumerateA)GetProcAddress(hDLL, "CredEnumerateA");&lt;br /&gt;        pfCredReadA = (typeCredReadA)GetProcAddress(hDLL, "CredReadA");&lt;br /&gt;        pfCredFree = (typeCredFree)GetProcAddress(hDLL, "CredFree");&lt;br /&gt;&lt;br /&gt;        if( pfCredEnumerateA == NULL||&lt;br /&gt;            pfCredReadA == NULL ||&lt;br /&gt;            pfCredFree == NULL )&lt;br /&gt;        {&lt;br /&gt;            printf("error!\n");&lt;br /&gt;            return -1;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;&lt;br /&gt;    //Get an array of 'credential', satisfying the filter&lt;br /&gt;    pfCredEnumerateA("Passport.Net\\*", 0, &amp;Count, &amp;CredentialCollection);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    if( Count ) //usually this value is only 1&lt;br /&gt;    {&lt;br /&gt;&lt;br /&gt;        //Calculate Entropy Data&lt;br /&gt;        for(i=0; i&lt;37; i++) // strlen(szEntropyStringSeed) = 37&lt;br /&gt;        {&lt;br /&gt;            tmp = (short int)szEntropyStringSeed[i];&lt;br /&gt;            tmp &lt;&lt;= 2;&lt;br /&gt;            EntropyData[i] = tmp;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        for(i=0; i&lt;Count; i++)&lt;br /&gt;        {&lt;br /&gt;            blobEntropy.pbData = (BYTE *)&amp;EntropyData;&lt;br /&gt;            blobEntropy.cbData = 74; //sizeof(EntropyData)&lt;br /&gt;&lt;br /&gt;            blobCrypt.pbData = CredentialCollection[i]-&gt;CredentialBlob;&lt;br /&gt;            blobCrypt.cbData = CredentialCollection[i]-&gt;CredentialBlobSize;&lt;br /&gt;&lt;br /&gt;            CryptUnprotectData(&amp;blobCrypt, NULL, &amp;blobEntropy, NULL, NULL, 1, &amp;blobPlainText);&lt;br /&gt;            &lt;br /&gt;            printf("Username : %s\n", CredentialCollection[i]-&gt;UserName);&lt;br /&gt;            printf("Password : %ls\n\n", blobPlainText.pbData);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    pfCredFree(CredentialCollection);&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 22 Dec 2005 18:05:10 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1007</guid>
      <author>mornlee (mornlee)</author>
    </item>
  </channel>
</rss>
