Easy Host Fake Win32
Sometimes we want to redirect some host to another ip address, the quick option is edit the hosts file.
Well i made this tool to do that.
Java Desktop Application, needs Java RunTime:

Easy Host Fake Java Setup
Is my first Java desktop application on NetBeans
PHP5 script, needs Console Getopt Pear Package (getopt function don’t work on Windows, in the next php 5.3.0 could be)
need pear? run go-pear.bat on your php5 directory
c:\>pear install Console_Getopt
Windows Batch file:
:save this ehf.cmd on your %windir%
:set php-cli to your php.exe path
@set php-cli=c:\php5\php.exe
:set ehf script path
@set ehf=c:\develop\php\scripts\ehf.php
@%php-cli% %ehf% %1 %2 %3 %4
Script ehf.php:
/* Script: Easy Host Fake
* Author: Albertux (Alberto Isaac Ayala Esquivias)
* WebSite: http://Albertux.AyalaSoft.com
* FeedBack: <albertoi7@gmail.com>
* License: GPLv3 (http://www.gnu.org/licenses/gpl.txt)
* Note: you need Pear Package Console Getopt
*/
$ip_default = '127.0.0.1'; // default ip
$hosts_file = 'c:/windows/system32/drivers/etc/hosts'; // default hosts file
require_once 'Console/Getopt.php';
$options = Console_Getopt::getopt($_SERVER["argv"],"a:e:r:");
function about() {
echo "
Easy Host Fake (version 1.0.1) [2008-12-27]
Usage: ehf [OPTIONS]
Mandatory: \"-r\" or \"-e\" [host]
Options:
-r [host] [redirect host to 127.0.0.1 (or other ip address)]
-e [host] [erase host on hosts file]
-a [ip address]
Examples:
ewf -r google.com -a 192.168.1.1
ewf -e google.com
More info [http://Albertux.AyalaSoft.com/2008/12/28/easy-host-fake-win32/]
";
}
function AddHost($host,$ip) {
global $hosts_file;
$handle = fopen($hosts_file,"a");
fwrite($handle,"\r\n$ip\t$host\t# Easy Host Fake");
fclose($handle);
}
function removeHost($host) {
global $hosts_file;
$handle = fopen($hosts_file, "r");
$contents = fread($handle, filesize($hosts_file));
fclose($handle);
$pattern = '/\\r\\n(\d+)\.(\d+)\.(\d+)\.(\d+)\t'.$host.'\t# Easy Host Fake/';
$replacement = "";
$newcontents = preg_replace($pattern, $replacement, $contents);
$handle = fopen($hosts_file,"w");
fwrite($handle,$newcontents);
fclose($handle);
}
function getValue($data,$var) {
for ($i=0; $i<count($data[0]); $i++) {
if ($var == $data[0][$i][0]) {
break;
}
}
return $data[0][$i][1];
}
if ($options->message) { about(); die(); }
$host = getValue($options,"r");
$ip = getValue($options,"a");
if (!$host) {
$host = getValue($options,"e");
if ($ip) { about(); die(); }
if (!$host) { about(); die(); }
removeHost($host); die();
}
if (!$host) { about(); die(); }
if (!$ip) { $ip = $ip_default; }
addHost($host,$ip);
Download php script + batch cmd
Note: on Windows Vista you need some permissions on hosts file, and remember all Web browsers use cache.
network, projects, security, web, windows
java, pear, php, tool
qTranslate Tag Fix WordPress 2.7
qTranslate is a plugin to makes creation of multilingual content as easy as working with a single language.
But … qTranslate 2.0 crash my WordPress :’(
It’s 1:15 A.M. I dont have much time to check now what’s the problem, next days I’m going to Nuevo Leon with my family so i decide to downgrade to qTranslate 1.1.6
Again “str_replace()” fix the tag cloud (wp-includes/category-template.php) WordPress 2.7:
foreach ( $tags as $key => $tag ) {
$count = $counts[ $key ];
$tag_link = '#' != $tag->link ? clean_url( $tag->link ) : '#';
$tag_id = isset($tags[ $key ]->id) ? $tags[ $key ]->id : $key;
$tag_name = $tags[ $key ]->name;
$a[] = "<a class="tag-link-$tag_id" style="font-size: " title="" . attribute_escape( $topic_count_text_callback( $count ) ) . "" href="$tag_link">$tag_name</a>";
}
develop, web
web, wordpress
Google Native Client
Native Client is an open-source research technology for running x86 native code in web applications
WebSite: http://code.google.com/p/nativeclient/
More information on Google Code Blog
Download native client
develop, hardware, web
google, x86
Fixing the Time
function total(year) {
var seconds = 365 * 24 * 60 * 60; //Normal Year;
var plus = 24 * 60 * 60; // Leap year have one more day
var leap = false;
if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) leap = true;
if (leap) seconds += plus;
if (year == 1972) seconds += 2;
if (year > 1972 && year < 1980) seconds += 1;
if (year > 1980 && year < 1984) seconds += 1;
if (year > 1988 && year < 1991) seconds += 1;
if (year > 1991 && year < 1996) seconds += 1;
if (year > 1996 && year < 1999) seconds += 1;
if (year == 1985 || year == 1987 || year == 2005 || year == 2008) seconds += 1;
document.write('Year: '+year+', Total of secods: '+seconds+'
');
}
total(1972);
total(1975);
total(1980);
total(1981);
total(2004);
total(2005);
total(2006);
total(2007);
total(2008);
total(2009);
Result:
Year: 1972, Total of secods: 31622402
Year: 1975, Total of secods: 31536001
Year: 1980, Total of secods: 31622400
Year: 1981, Total of secods: 31536001
Year: 2004, Total of secods: 31622400
Year: 2005, Total of secods: 31536001
Year: 2006, Total of secods: 31536000
Year: 2007, Total of secods: 31536000
Year: 2008, Total of secods: 31622401
Year: 2009, Total of secods: 31536000
Leap Second (http://en.wikipedia.org/wiki/Leap_second)
Leap Years (http://en.wikipedia.org/wiki/Leap_year)
develop, security, web
javascript, leap, time, year
JavaFX 1.0 Release
JavaFX is a rich client platform for building cross-device applications and content. Designed to enable easy creation and deployment of rich internet applications (RIAs) with immersive media and content, the JavaFX platform ensures that RIAs look and behave consistently across diverse form factors and devices.
See the Tutorial, Samples, and FAQ.
Download JavaFX SDK.
develop, web
java
TODO LIST 2009
Read/Learn/Practice:
Python 2.6 (What’s New)
Perl 5 (Modules, Packages)
PHP (Changes, and news)
COBOL
.NET (C#, LINQ, (ok VB but not much))
Java (Im interested on Mobil Applications)
Haskell
Ruby (Im interested on Rails)
Parrot and Pugs
Gnu/Linux (Services and Bash)
BSD and OpenSolaris
Personal Projects 2009:
BSE (Blog’s Search Engine) (http://BSE.AyalaSoft.com)
Invoices PHP (Now is part of a Intranet) (http://valuacion.com.mx)
Forming one’s own business
And others ….
Lambda Functions on PHP 5.3.0:
$lambda = function () { echo "Hello World!\n"; };
Parrot “Hello World” example:
.sub main
print "Hello World!\n";
.end
COBOL “Hello World” example:
* Hello World Program
* GPL Copyleft Jonathan Riddell 2001
IDENTIFICATION DIVISION.
PROGRAM-ID. hello.
ENVIRONMENT DIVISION.
DATA DIVISION.
PROCEDURE DIVISION.
DISPLAY "Hello ," WITH NO ADVANCING
DISPLAY "World!"
STOP RUN.
Haskell “Hello World” example:
develop, unix/linux, web, windows
cobol, dotnet, haskell, java, perl, python, ruby
C Compile on Demand
If you want to use C/C++ as CGI you need compile the code you can compile on demand check C Cod WebSite
See the Documentation some aspects similars to ASP(VBScript).
you now:
#!/usr/bin/php
#!/usr/bin/perl
#!/usr/bin/python
#!/bin/bash
...
Add this #!/usr/bin/ccod to use C/C++, one simple example:
Download C Cod.
develop, network, projects, unix/linux, web, windows
c/c++, cgi
Recent Comments