March 29, 2013

tip: embed raw text in html


 it's become somewhat au courant to use the "type" attribute to mark <script> blocks that you don't want to be evaluated:
<script type='text/html-template'>
  <div> this is a template </div>
</script>
By giving a weird non-JavaScript type, you get a way to stuff raw text into the page for use by other JavaScript code (which is presumably in script block that can be evaluated).

This technique is great for using the block inside the <script> for html template, to be used by JQuery. Without the <script> block, IE will mess with the source code and remove thing it does not know.

Source: http://stackoverflow.com/questions/5265202/do-you-need-text-javascript-specified-in-your-script-tags

March 20, 2013

California LLC taxs and fees

For California LLC not treated as corporation:



  1. Annual tax of $800 is paid in the tax year by 04/15 with form 3522 . 
  2. LLC fee estimate for current year is paid by 6/15 current year
  3. LLC fee final is filed by next year 4/15 with From 568, the payment form is 3536
  4. The Fee is tax deductible
Source:

1. https://www.ftb.ca.gov/businesses/bus_structures/LLCompany.shtml
2. http://www.taxes.ca.gov/Income_Tax/limliacobus.shtml
3. https://www.upcounsel.com/california-llc-fee

March 15, 2013

php one line udp client

socket_sendto(socket_create(AF_INET, SOCK_DGRAM, SOL_UDP), $raw_post_data, strlen($raw_post_data), 0, '127.0.0.1', 57000);

The above will send the post data  (suppose it is in $raw_post_data) to a local udp server listening on port 57000.

March 6, 2013

Excel 2003 useful shortcuts

Ctrl-1:          Open Cell Format Dialog
shift +space: select row
ctrl + -:        delete row.
ctrl + +:        Insert a row (above the currently selected row)     

March 1, 2013

clean up diff file

The following program take a diff file and removes chunks that are simply different by a white spaces or carriages returns, such as

int func(a,b){

vs. 

int func(a,b)
{

Save this to file "diffclean.awk" and run it as "./diffclean.awk my.diff".



#!/usr/bin/gawk -f
function process_block(str,strp,strm){
        regex="[ \t\f\r\n]+";
        gsub(regex," ",strp);
        gsub(regex," ",strm);
        if (strp!=strm){
                print str;
        }
}

{
        if (!block_started) {
                if (/^@@/) {
                        block_started=1;
                        str=$0;
                        strp="";
                        strm="";
                }else{
                        print;
                }
                next;
        }

        if (/^diff/) {
                process_block(str,strp,strm);
                block_started=0;
                print;
                next;
        }
        if (/^@@/) {
                process_block(str,strp,strm);
                str=$0;
                strp="";
                strm="";
                next;
        }

        str=str "\n" $0;
        if (/^-/) strm=strm substr($0,2);
        if (/^+/) strp=strp substr($0,2);
}

END{
        if (block_started){
                process_block(str,strp,strm);
        }
}