Autarchy of the Private Cave

Tiny bits of bioinformatics, [web-]programming etc

    • Archives

    • Recent comments

    Archive for the 'Notepad' Category

    Short miscellaneous notes

    Decisions in 10 minutes or less

    21st January 2007

    Brian Valentine is said to be the author of the motto: “Decisions in 10 minutes or less, or the next one is free“.

    I came across this motto accidentally while surfing the web, and think it’s worth writing down.

    For more details you can see the story behind the Brian Valentine managing Windows 2000 release.

    There is also the “quotes” page at WarpedVisions, which has the one about decisions in 10 minutes, as well as many other quotes.

    Share

    Posted in Notepad | No Comments »

    Gliwice stay is getting pleasant

    27th October 2006

    Since the 16th of October I am on bioinformatics training in Gliwice, Poland, at the Comprehensive Cancer Centre Maria Sklodowska-Curie Memorial Institute, Gliwice branch. I am training in microarrays data analysis, with focus on R + BioConductor usage for analysis.

    I am already more-or-less comfortable with Polish – though understanding is still a much easier task than expressing own thoughts, thus most commonly I address colleagues in English, and perceive responses in Polish :)

    Here there is an excellent lunch location – Bar U Piotra (“At the Peter’s”). For 6.5 PLN (roughly 2.2 USD or 10.4 UAH) you get soup, meat with some garnish, and – not always – some salad. However, 6.5 PLN is a special price, available only if you buy at least 7 (or 10?) meals ahead. Food is simple but tastes like home-cooked, and helpings size is well sufficient for me – which means “more than sufficient” for an average person.

    I still cannot get used to other people coming to work at 8 a.m., but the idea of leaving at 4 p.m. adds a kernel of good sense to the early-rising idea.

    Generally, Gliwice is not a bad place to stay, at least for up to 2-3 months. Autumn here is beautiful – see my gallery for some samples of what is looks like here at the end of October.

    Share

    Posted in Notepad | No Comments »

    XName.org down: largest DDoS they ever had

    27th October 2006

    Yesterday (October, 26, 2006) I found that the nameservers for my blog (ns0.xname.org, ns1.xname.org) are not responding.
    Today the following message appeared on xname.org:

    XName currently DOWN

    XName is temporarily closed since 08:00PM CEST yesterday evening. We were experiencing the largest DDoS we ever had on both ns0 and ns1 IP addresses, forcing our upstream providers to cut off XName servers in order to preserve their other customers.

    We’re working hard in order to have at least one DNS server answering ASAP, and we already negotiated with a premium transit provider to host one of our DNS servers shortly.

    Currently my blog is back online, available by its name, and not by IP.

    But I am looking for other free NS-record hosting servers (xname-like). I would appreciate if people comment with their experience on managing this problem. I temporarily allowed comments for anyone without registering (but with moderation).

    Meanwhile there are two places for Russian speaking folks to register secondary DNS: ns2.trifle.net, secondary.net.ua. Soon I’ll register secondaries there, leaving primary on xname, which was a stable service up until yesterday’s DDoS attack they had.

    update:

    Update: Sat. 28. 12:00 – ns0 is up and running, serving all zones correctly

    update 2:

    Update: Mon. 30. 18:00 CEST – ns1 is up and running, reachable from Association Kazar’s network peers (ns1 IP is still blacklisted on upstream transits backbones)

    update 3:
    xame.org is back online, fully functional.

    update 4:
    See the List of free DNS services.
    I’m staying with xname, though did add a couple of secondaries for better fault protection.

    update 5:
    See the comments to this post for new technical information about the DDoS attack, including IP addresses of the attackers and some packet statistics. Thanks Boris for the new information.

    new attack. On the 14th of January, 2007, I got the following letter from XName team:

    DDoS attack on both DNS servers
    Our both DNS servers IPs – ns0.xname.org and ns1.xname.org – are under heavy DDoS since 5PM CEST today.
    Consequently, both of them are unreachable – except very intermittently.
    We’re working with our transit providers to solve this ASAP.

    Next day (2007-01-15), XName was up and running:

    Resuming normal operations
    Since 2AM CEST both ns0 and ns1 were answering correctly – many thanx to
    our transit providers for their help on this issue.

    the total outage of our service was 7 hours…

    one more attack on the 1st of October 2007 (started on the 30th of September):

    both ns0 and ns1 DNS servers are under DDoS attack since 10PM (gmt+2) yesterday (September, 30th), ns0 is unreachable since 6AM this morning (October, 1st: total saturation of our uplink).
    ns1 is fine but was off 3 hours today (October, 1st), between 2PM and 5PM.

    I wonder what kind of a mentally sick person would attack the free service…

    For any further X-Name attack updates and history, please refer to the comments below.

    Share

    Posted in Notepad, Web | 11 Comments »

    Perfecting foreign language skills

    17th October 2006

    While at school, I was perfecting my English skills – improving pronunciation, learning grammar and spelling. When I had to go abroad, I felt good about talking with almost no accent; when some people happened to talk unclearly, I considered this to be their problem, not mine – because I was talking good.

    Yesterday, travelling by train from Medyka to Gliwice (in Poland), I needed to ask at what time does the train stop in Gliwice (it’s not the final destination of the train). Thankfully, there was a man from Ukraine travelling to Wroclaw (which is further in the train’s route), and he gave me a Ukrainian-Polish phrase book. I managed to construct the phrase which actually asks what I need. Then I went to the guard’s accommodation, and asked the question.
    Read the rest of this entry »

    Share

    Posted in Notepad, Society | No Comments »

    search-hilite.php file

    2nd October 2006

    1. <?php
    2. /*
    3. Plugin Name: Search_Hilite
    4. Plugin URI: http://www.blog.mediaprojekte.de/cms-systeme/wordpress/wordpress-plugin-search-hilite/
    5. Description: When someone is referred from a search engine like Google, Yahoo, or WordPress' own, the searchterms are highlighted. You can set the markup-style in Options pages or in your own css.  /original Version 1.5 by <a href="http://dev.wp-plugins.org/file/google-highlight/>Ryan Boren </a>. Support for Chinese Language Added by Xuefeng Li
    6. Version: 1.9
    7. Author: Georg Leciejewski
    8. Author URI: http://www.blog.mediaprojekte.de
    9. */
    10. define("SEARCHHILITE", "190");
    11.  
    12. /**
    13. * @desc get search terms as array
    14. * @author Georg Leciejewski
    15. */
    16. function get_search_query_terms($engine = 'google') {
    17.         $referer = urldecode($_SERVER['HTTP_REFERER']);
    18.         $query_array = array();
    19.         switch ($engine) {
    20.         case 'google':
    21.                 // Google query parsing code adapted from Dean Allen's
    22.                 // Google Hilite 0.3. http://textism.com
    23.                 $query_terms = preg_replace('/^.*q=([^&]+)&?.*$/i','$1', $referer);
    24.                 $query_terms = preg_replace('/\'|"/', '', $query_terms);
    25.                 $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    26.                 break;
    27.         //added by  Xuefeng Li        
    28.         case 'baidu':
    29.         // My server don't support iconv function, so i had to use another function gb2utf8 to replace it.
    30.             //$referer = iconv('gb2312', 'utf-8', $referer);
    31.                 $referer =  gb2utf8($referer);
    32.                 $query_terms = preg_replace('/^.*(wd=|word=)([^&]+)&?.*$/i','$2', $referer);
    33.                 $query_terms = preg_replace('/\'|"/', '', $query_terms);
    34.                 $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    35.                 break;
    36.  
    37.         case 'lycos':
    38.                 $query_terms = preg_replace('/^.*query=([^&]+)&?.*$/i','$1', $referer);
    39.                 $query_terms = preg_replace('/\'|"/', '', $query_terms);
    40.                 $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    41.                 break;
    42.  
    43.         case 'yahoo':
    44.                 $query_terms = preg_replace('/^.*p=([^&]+)&?.*$/i','$1', $referer);
    45.                 $query_terms = preg_replace('/\'|"/', '', $query_terms);
    46.                 $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    47.                 break;
    48.                
    49.         case 'wordpress':
    50.                 $search = get_query_var('s');
    51.                 $search_terms = get_query_var('search_terms');
    52.  
    53.                 if (!empty($search_terms)) {
    54.                         $query_array = $search_terms;
    55.                 } else if (!empty($search)) {
    56.                         $query_array = array($search);
    57.                 } else if (empty($search)) {
    58.                     //do nothing man
    59.                 } else {
    60.                         $query_terms = preg_replace('/^.*s=([^&]+)&?.*$/i','$1', $referer);
    61.                         $query_terms = preg_replace('/\'|"/', '', $query_terms);
    62.                         $query_array = preg_split ("/[\s,\+\.]+/", $query_terms);
    63.                 }
    64.         }
    65.        
    66.         return $query_array;
    67. }
    68. /**
    69. * @desc get textfile to make chinese character conversion
    70. * @author Xuefeng Li
    71. */
    72. function gb2utf8($text) {
    73.    $charset[0]=0;
    74.    $filename = dirname(__FILE__).'/'."gb2utf8.txt";
    75.    $fp = fopen($filename,"r");
    76.    while(! feof($fp)) {
    77.       list($gb,$utf8) = fgetcsv($fp,10);
    78.       $charset[$gb] = $utf8;
    79.    }
    80.    fclose($fp);
    81.  
    82.    preg_match_all("/(?:[\x80-\xff].)|[\x01-\x7f]+/",$text,$tmp);
    83.    $tmp = $tmp[0];
    84.    $ar = array_intersect($tmp, array_keys($charset));
    85.    foreach($ar as $k=>$v)
    86.     $tmp[$k] = $charset[$v];
    87.    return join('',$tmp);
    88. }
    89. /**
    90. * @desc check from which searchengine
    91. * @author Georg Leciejewski
    92. */
    93. function is_referer_search_engine($engine = 'google') {
    94.         if( empty($_SERVER['HTTP_REFERER']) && 'wordpress' != $engine ) {
    95.                 return false;
    96.         }
    97.  
    98.         $referer = urldecode($_SERVER['HTTP_REFERER']);
    99.  
    100.         if ( ! $engine ) {
    101.                 return false;
    102.         }
    103.  
    104.         switch ($engine) {
    105.         case 'google':
    106.                 if (preg_match('|^http://(www)?\.?google.*|i', $referer)) {
    107.                         return true;
    108.                 }
    109.                 break;
    110.  
    111.         case 'lycos':
    112.                 if (preg_match('|^http://search\.lycos.*|i', $referer)) {
    113.                         return true;
    114.                 }
    115.                 break;
    116.  
    117.         case 'yahoo':
    118.                 if (preg_match('|^http://search\.yahoo.*|i', $referer)) {
    119.                         return true;
    120.                 }
    121.                 break;
    122.         //added by  Xuefeng Li
    123.         case 'baidu':
    124.                 if (preg_match('|^http://(www)?\.?baidu.com|i', $referer)) {
    125.                         return true;
    126.                 }
    127.                 break;
    128.         case 'wordpress':
    129.                 if ( is_search() )
    130.                         return true;
    131.  
    132.                 $siteurl = get_option('home');
    133.                 if (preg_match("#^$siteurl#i", $referer))
    134.                         return true;
    135.  
    136.                 break;
    137.         }
    138.  
    139.         return false;
    140. }
    141.  
    142. /**
    143. * @desc Hiliting Conversion
    144. * @author Georg Leciejewski
    145. */
    146. function hilite($text)
    147. {
    148.     $search_engines = array('wordpress', 'google', 'lycos', 'yahoo', 'baidu');
    149.     $loopcounter=0;
    150.    foreach ($search_engines as $engine)
    151.     {
    152.          if ( is_referer_search_engine($engine))
    153.             {
    154.                $query_terms = get_search_query_terms($engine);
    155.                foreach ($query_terms as $term)
    156.                     {
    157.                         if ( !empty($term) && $term != ' ' && strlen($term) >= 3 )
    158.                         {
    159.                             $loopcounter++;
    160.                             if ( $loopcounter == 1) $hilite_class='hilite';
    161.                             elseif($loopcounter == 2) $hilite_class='hilite1';
    162.                             elseif($loopcounter == 3) $hilite_class='hilite2';
    163.                             elseif($loopcounter == 4) $hilite_class='hilite3';
    164.  
    165.                             $qterm = preg_quote($term, '/');
    166.                             if ( preg_match("/<&#91;^>]*?>/s",$text) != 0 )
    167.                                 $text = preg_replace('/('.$qterm.')/i','<span class="'.$hilite_class.'">$1</span>',$text);
    168.                             else
    169.                             {
    170.                                 $regex = '/(>[^<>]*?)('.$qterm.')([^>]*?<)/i';
    171. error_log( htmlspecialchars($text) );
    172. error_log( "regex='$regex',qterm='$qterm'" );
    173.                                 $text = preg_replace($regex,'$1<span class="'.$hilite_class.'">$2</span>$3',$text);
    174.                                 /* (?![^<&#93;*?>) */
    175. //                              $text = preg_replace('/(?<=>)([^<&#93;+)?('.$term.')/i','$1<span class="'.$hilite_class.'">$2</span>',$text);  //taken out the \b option to also mark substrings
    176.                             }
    177.                         }
    178.                }
    179.                break;
    180.          }
    181.    }
    182.    return $text;
    183. }
    184.  
    185. /**
    186. * @desc insert hilite css into head
    187. * @author Georg Leciejewski
    188. */
    189. function hilite_head() {
    190.  
    191.     $css = search_hilite_getCss();
    192.  
    193.      if(get_option('search_hilite_use_own_css')=='1')
    194.      {
    195.      }   
    196.      elseif (!empty ($css) )
    197.      {
    198.       echo $css ;
    199.  
    200.      }else{
    201.        echo "
    202.       <style type='text/css'>
    203.      .hilite {
    204.             color: #000;
    205.             background-color: #99ccff;
    206.             }
    207.    .hilite1 {
    208.             color: #000;
    209.             background-color: #ffcc66;
    210.             }
    211.    .hilite2 {
    212.             color: #000;
    213.             background-color: #99ff66;
    214.             }
    215.    .hilite3 {
    216.             color: #000;
    217.             background-color: #ff9999;
    218.             }
    219.     </style>";
    220.      }
    221. }
    222.  
    223. /**
    224. * @desc Admin menu Page
    225. * @author Georg Leciejewski
    226. */
    227. function search_hilite_options() {
    228.  
    229.     if($_POST['search_hilite_options_save']){
    230.      update_option('search_hilite_css',$_POST['search_hilite_css']);
    231.      update_option('search_hilite_use_own_css',$_POST['search_hilite_use_own_css']);
    232.         echo '<div class="updated"><p>'. __('Search Hilite Options successfully saved.','searchHilite') .'</p></div>';
    233.     }
    234.     ?>
    235.     <div class="wrap">
    236.     <h2><?php _e('Search Hilite CSS Options','searchHilite') ?> </h2>
    237.     <form method="post" id="search_hilite_options" action="">
    238.         <fieldset class="options">
    239.         <legend><?php _e('Insert your own Hilite CSS Style','searchHilite') ?></legend>
    240.         <table width="100%" cellspacing="2" cellpadding="5" class="editform">
    241.         <tr valign="top">
    242.                 <th width="33%" scope="row"><?php _e('take CSS Style from my Stylesheet:','searchHilite') ?></th>
    243.                 <td>
    244.                <input type="checkbox" name="search_hilite_use_own_css" value='1' <?php if(get_option('search_hilite_use_own_css')=='1') { echo "checked='checked'";  } ?> >
    245. <br /><?php _e('Should be set if you inserted the hilite style in your existing css. If not set and Style Field below is empty. The default style (example) will be used.
    246. ','searchHilite') ?>
    247.               </td>
    248.             </tr>
    249.             <tr valign="top">
    250.                 <th width="33%" scope="row"><?php _e('CSS Style:','searchHilite') ?></th>
    251.                 <td>
    252.                 <textarea rows="10" cols="30" name="search_hilite_css" tabindex="4" id="search_hilite_css"><?php echo stripslashes(get_option('search_hilite_css')) ;  ?>
    253.                 </textarea>
    254.                <br /><br /><strong><?php _e('Example:','searchHilite') ?></strong> <br />
    255.  
    256.                <?php _e('CSS Style:','searchHilite') ?>
    257.                <?php
    258.                echo "<br />
    259.                 &lt;style type='text/css'&gt;<br />
    260.                 .hilite {<br />
    261.                 color: #000;<br />
    262.                 background-color: #;<br />
    263.                 }<br />
    264.                 .hilite1 {<br />
    265.                 color: #000;<br />
    266.                 background-color: #99FF99;<br />
    267.                 }<br />
    268.                 .hilite2 {<br />
    269.                 color: #000;<br />
    270.                 background-color: #FFFF66;<br />
    271.                 }<br />
    272.                 .hilite3 {<br />
    273.                 color: #000;<br />
    274.                 background-color: #FF66FF;<br />
    275.                 }<br />
    276.                 &lt;/style&gt;
    277.                 ";
    278.                 ?>
    279.                 </td>
    280.             </tr>
    281.         </table>
    282.         <p class="submit"><input type="submit" name="search_hilite_options_save" value="Save" /></p>
    283.         </fieldset>
    284.     </form>
    285.     </div>
    286. <?php
    287. }
    288.  
    289. /**
    290. * @desc get search_hilite_css
    291. * @author Georg Leciejewski
    292. */
    293. function search_hilite_getCss(){
    294.     if($css = get_option('search_hilite_css')){
    295.        $css = stripslashes($css) ;
    296.         return $css;
    297.     }
    298. }
    299.  
    300. /**
    301. * @desc look for old google_hilite_css option and removes them just for security if someone uses the old plugin
    302. * @author Georg Leciejewski
    303. */
    304. function search_hilite_install(){
    305.     if(get_option('google_hilite_css')){
    306.       delete_option ('google_hilite_css');
    307.     }
    308.  
    309.     add_option('search_hilite_css', " <style type='text/css'>
    310.     .hilite {
    311.             color: #000;
    312.             background-color: #99ccff;
    313.             }
    314.    .hilite1 {
    315.             color: #000;
    316.             background-color: #ffcc66;
    317.             }
    318.    .hilite2 {
    319.             color: #000;
    320.             background-color: #99ff66;
    321.             }
    322.    .hilite3 {
    323.             color: #000;
    324.             background-color: #ff9999;
    325.             }
    326.     </style>");
    327.     add_option('search_hilite_use_own_css', "0");
    328. }
    329.  
    330. /**
    331. * @desc Admin Menu hook
    332. * @author Georg Leciejewski
    333. */
    334. function search_hilite_adminmenu(){
    335.     add_options_page('Search Hilite Options', 'Search Hilite', 9, 'search-hilite.php', 'search_hilite_options');
    336. }
    337.  
    338. /**
    339. * @desc Remote Version checking
    340. * @author georg leciejewski /  Per Soderlind
    341. * @param string $widgetname full Widgetname ie: King_Text_Widget
    342. * @param int $localversion widget Version Number
    343. */
    344. function search_hilite_remote_version_check($widgetname,$localversion) {
    345.     require_once(ABSPATH . WPINC . '/class-snoopy.php');
    346.     if (class_exists(snoopy)) {
    347.         $client = new Snoopy();
    348.         $client->_fp_timeout = 10;
    349.         if (@$client->fetch('http://website-king.com/versiontrack/'.$widgetname.'.txt') === false) {
    350.             return -1;
    351.         }
    352.         $remote = $client->results;
    353.         if (!$remote || strlen($remote) > 8 ) {
    354.             return -1;
    355.         }
    356.         if (intval($remote) > intval($localversion)) {
    357.             return 1;
    358.         } else {
    359.             return 0;
    360.         }
    361.     }
    362. }
    363.  
    364. /**
    365. * @desc Admin Header for Version Check on Pluginpage
    366. * @author georg leciejewski /  Per Soderlind
    367. * @param string $widgetname full Widgetname ie: King_Text_Widget
    368. * @param int $localversion widget Version Number
    369. */
    370. function search_hilite_admin_head($widgetname,$localversion) {
    371.     load_plugin_textdomain('searchHilite');
    372.     if ((strpos($_SERVER['REQUEST_URI'], 'plugins.php') !== false) && (search_hilite_remote_version_check($widgetname,$localversion) == 1)) {
    373.         echo "<script type='text/javascript' src='" . get_settings('siteurl') . "/wp-content/plugins/king-includes/js/prototype-1.4.0.js'></script>\n";
    374.  
    375.         $alert = "\n";
    376.         $alert .= "\n<script type='text/javascript'>";
    377.         $alert .= "\n//<!&#91;CDATA&#91;";
    378.         $alert .= "\nfunction alertNewVersion" . $widgetname . "() {";
    379.         $alert .= "\n   pluginname = '" . $widgetname . "';";
    380.         $alert .= "\n   allNodes = document.getElementsByClassName('name');";
    381.         $alert .= "\n   for(i = 0; i < allNodes.length; i++) {";
    382.         $alert .= "\n           var regExp=/<\S&#91;^>&#93;*>/g;";
    383.         $alert .= "\n       temp = allNodes&#91;i&#93;.innerHTML;";
    384.         $alert .= "\n       if (temp.replace(regExp,'') == pluginname) {";
    385.         $alert .= "\n           Element.setStyle(allNodes&#91;i&#93;.getElementsByTagName('a')&#91;0&#93;, {color: '#f00'});";
    386.         $alert .= "\n           new Insertion.After(allNodes&#91;i&#93;.getElementsByTagName('strong')&#91;0&#93;,'<br/><small>" .  __("new version available","widgetKing") . "</small>');";
    387.         $alert .= "\n       }";
    388.         $alert .= "\n   }";
    389.         $alert .= "\n}";
    390.         $alert .= "\naddLoadEvent(alertNewVersion" . $widgetname . ");";
    391.         $alert .= "\n//&#93;&#93;>";
    392.         $alert .= "\n</script>";
    393.         $alert .= "\n";
    394.         echo $alert;
    395.     }
    396. }
    397. /**
    398. * @desc Version Check Heading
    399. * @author Georg Leciejewski
    400. */
    401. function search_hilite_version() {
    402.  
    403.     search_hilite_admin_head('Search_Hilite',SEARCHHILITE);
    404. }
    405.  
    406. if (isset($_GET['activate']) && $_GET['activate'] == 'true') {
    407.     add_action('init', 'search_hilite_install');
    408.     }
    409.  
    410. add_action('admin_head','search_hilite_version');
    411. add_action('admin_menu','search_hilite_adminmenu',1);
    412.  
    413. // Highlight text and comments:
    414. add_filter('the_content', 'hilite');
    415. add_filter('the_excerpt', 'hilite');
    416. add_filter('comment_text', 'hilite');
    417. add_action('wp_head', 'hilite_head');
    418. add_filter('the_title', 'hilite');
    419.  
    420. ?>
    Share

    Posted in Notepad | No Comments »

    Optimal Title WordPress plugin

    1st October 2006

    This might be the simplest thing to do in your blog – put the post title in front of the blog name. And the plugin to do so is simple – but still appreciated for the effort. Get it and enjoy.

    P.S. If you read the WP Codex, especially the paragraph on reversing page title display – please see the comments at “optimal title” home for explanations why the plugin is better.

    Share

    Posted in Notepad, Web, WP PlugIns | No Comments »

    Google Browser Sync

    1st October 2006

    Today I came across Google Browser Sync once again. It allows you to synchronize the current state of two or more Firefox installations on different computers. Here, “state” means bookmarks, history, open tabs, persistent cookies and saved passwords.

    I didn’t try it yet, as I do not feel like syncing my work PC with home PC :)
    However, I’m a long-time user of Foxmarks, which allows to sync only bookmarks, and works perfect for me – especially after the recent update to version 0.8.

    Share

    Posted in Notepad | No Comments »