December 25th, 2011 by GadElKareem
Server load is open source widgets for android that retrieve your current server average load and display it on a widget on your android home screen, you can add more widgets for each server. The widget will update every 30 min to display your server’s current average load. Check the php example for extracting your servers’ current load.
Program test on Galaxy s2
Download
Source Code
Get from Android Market
php file ex:
-
-
<?php
-
$load = getServerLoad();
-
-
if( $load !== NULL ){
-
$load = explode(‘ ‘, $load[‘load’]);
-
-
}
-
-
function getServerLoad(){
-
-
if(strpos($os, ‘win’) === false){
-
-
-
-
$load = $load[0];
-
-
-
$load = $load[count($load)-1];
-
}else{
-
return NULL;
-
}
-
-
-
$cpu_count = shell_exec(‘cat /proc/cpuinfo | grep processor | wc -l’);
-
-
return array(‘load’=>$load, ‘procs’=>$cpu_count);
-
}else{
-
-
$wmi=new COM(‘WinMgmts:\\\\.’);
-
$cpus=$wmi->InstancesOf(‘Win32_Processor’);
-
$load=0;
-
$cpu_count=0;
-
-
while($cpu = $cpus->Next()){
-
$load += $cpu->LoadPercentage;
-
$cpu_count++;
-
}
-
}else{
-
foreach($cpus as $cpu){
-
$load += $cpu->LoadPercentage;
-
$cpu_count++;
-
}
-
}
-
return array(‘load’=>$load, ‘procs’=>$cpu_count);
-
}
-
return NULL;
-
}
-
return NULL;
-
}
-
-
?>
-
-
-
ScreenShots :
Read More
October 23rd, 2011 by GadElKareem
tested on Firefox 7.0.1
-
-
const Ci = Components.interfaces;
-
const Cc = Components.classes;
-
-
function ReadWrite( data ){
-
-
try{
-
Components.utils.import("resource://gre/modules/NetUtil.jsm");
-
Components.utils.import("resource://gre/modules/FileUtils.jsm");
-
-
var file = FileUtils.getFile("ProfD", ["FileName.txt"]);
-
var ostream = FileUtils.openSafeFileOutputStream(file );
-
var converter = Cc
["@mozilla.org/intl/scriptableunicodeconverter"].
-
createInstance(Ci.nsIScriptableUnicodeConverter);
-
-
if( data ){
-
-
if ( !file.exists() ){
-
file.create( Ci.nsIFile.NORMAL_FILE_TYPE, 420);
-
}
-
converter.charset = "UTF-8";
-
var istream = converter.convertToInputStream(data);
-
NetUtil.asyncCopy(istream , ostream, function(status) {
-
if (!Components.isSuccessCode(status)) {
-
alert( "Error! :" + status );
-
return false;
-
}
-
});
-
-
}else{
-
var data = ”;
-
var fstream = Cc
["@mozilla.org/network/file-input-stream;1"].
-
createInstance(Ci.nsIFileInputStream);
-
var cstream = Cc
["@mozilla.org/intl/converter-input-stream;1"].
-
createInstance(Ci.nsIConverterInputStream);
-
fstream.init(file, -1, 0, 0);
-
cstream.init(fstream, "UTF-8", 0, 0); // you can use another encoding here if you wish
-
-
let (str = {}) {
-
let read = 0;
-
do {
-
read = cstream.readString(0xffffffff, str); // read as much as we can and put it in str.value
-
data += str.value;
-
} while (read != 0);
-
}
-
cstream.close(); // this closes fstream
-
return data;
-
-
}
-
-
}catch(e){
-
// alert( e);
-
return false;
-
}
-
}
-
Read More
August 5th, 2011 by GadElKareem
-
-
-
if( login_limit() )
-
die( ‘Your IP has been banned from logging in for the next 5 minutes’ );
-
-
-
-
/*
-
* Counts login times by same IP
-
* returns true if limit reached or false if not
-
*/
-
function login_limit(){
-
//get real IP if user behind proxy noted by Sebastian Enger
-
$ip = isset($_SERVER[‘HTTP_X_FORWARDED_FOR’]) ?
$_SERVER[‘HTTP_X_FORWARDED_FOR’] : $_SERVER[‘REMOTE_ADDR’];
-
-
//user still banned from login
-
if( _cache( $ip . ‘banned’ ) )
-
return true;
-
-
//number of seconds
-
$sec = 30;
-
//find ip info array in cache saved less than $sec ago
-
if( ($ip_info=_cache
( $ip )) && $ip_info[0] > time()-$sec ){
-
-
//user login 10 times during last $sec
-
if( $ip_info[1] > 10 ){
-
//ban user ip for the next 5 minutes
-
_cache( $ip . ‘banned’, 1, 0, 60*5 );
-
_cache( $ip, -1 );
-
return true;
-
}
-
//increase login retries +1
-
_cache
( $ip, array( $ip_info[0], ++$ip_info[1] ), 0, $sec );
-
return false;
-
-
}
-
-
//add ip info to cache
-
-
return false;
-
}
-
-
function _cache( $name, $val=NULL, $ttl=false ){
-
//memcached
-
-
-
$mcdb = memcache_connect(‘unix:///etc/sockets/memcached.sock’, 0);
-
-
if($val === -1){
-
return memcache_delete($mcdb,$name);
-
}elseif( $val !== NULL ){
-
return memcache_set($mcdb,$name,$val, false, $ttl);
-
}else{
-
$retval = memcache_get($mcdb,$name);
-
return $retval ? $retval : NULL;
-
}
-
-
}
-
-
Read More
February 7th, 2011 by GadElKareem
Show your support for the Egyptian revolution by adding this code to your website and blog
-
-
display: block;
-
width: 222px;
-
height: 111px;
-
position: fixed;
-
top: -16px;
-
right: -70px;
-
-webkit-transform: rotate(45deg);
-
-moz-transform: rotate(45deg);
-
-o-transform: rotate(45deg);
-
}
-
-
top: -80px\9;
-
right: -70px\9;
-
*right: -70px;
-
filter: progid:DXImageTransform.Microsoft.Matrix(sizingMethod=’auto expand’, M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476);
-
-ms-filter: "progid:DXImageTransform.Microsoft.Matrix(SizingMethod=’auto expand’, M11=0.7071067811865476, M12=-0.7071067811865475, M21=0.7071067811865475, M22=0.7071067811865476)";
-
zoom: 1;
-
}
-
</style>
-
A Demo of this code can be seen on the top right of this page
Read More
June 19th, 2010 by GadElKareem
great help @ http://mansurovs.com/tech/converting-vbulletin-to-utf-8
these are the exact commands that worked for me
#more-58" class="more-link"> more.. »
Read More
February 25th, 2010 by GadElKareem
This the simplest tooltip jQuery plugin you can find around.
features:
- takes advantage of live(), mouseenter and mouseleave methods
- tracks mouse movement
- right and bottom viewport border tracking
- can be applied on any element
Demo – download – Google code
#more-57" class="more-link"> more.. »
Read More
December 5th, 2009 by GadElKareem
you need Jquery:
-
-
<label for="myinput"></label><input name="myinput" type="text" value="text here" />
-
$(‘label’).live(‘click’, function(e){
-
if( $(e.target).is(‘:input’) ) return;
-
var i = $(‘:input[name="' + $(this).attr('for') + '"]‘)
-
i.is(‘:checkbox’) ? i.attr(‘checked’, !i.attr(‘checked’) ) : i.focus().select();
-
})
-
Read More
November 29th, 2009 by GadElKareem
using vbulletin files :
-
-
-
define(‘THIS_SCRIPT’, ‘login’);
-
require_once( ‘./global.php’);
-
require_once( DIR . ‘/includes/functions_wysiwyg.php’ );
-
-
echo convert_wysiwyg_html_to_bbcode
(‘<i>hello world</i>’);
-
using external function :
#more-55" class="more-link"> more.. »
Read More
May 15th, 2008 by GadElKareem
Sitemap Creator crawls/spiders your website creating XML sitemaps compatible with the standard sitemaps.org protocol supported by Google, Yahoo!, MSN and MoreOver. The script pings Google, Yahoo!, MSN and MoreOver bots to download the sitemap file, then tracks the bot and sends you an email on every scan to your Sitemap and gives you a full report of the Search Engine respond.
Sitemaps are created from a CSV file which could easily be edited using any text editor before creating the sitemap. #more-53" class="more-link"> more.. »
Read More
April 22nd, 2008 by GadElKareem
you can exclude an email address or even a host that is spamming you using the access file located in your etc directory, the bad news is that it does not support regex or even wildcards. #more-52" class="more-link"> more.. »
Read More
March 31st, 2008 by GadElKareem
It is very easy to start programs remotely on your windows desktop from another computer but running X11 application on Linux from another ssh session would start a new X11 session on your remote machine, that was a problem for me and here is how I solved that….. #more-51" class="more-link"> more.. »
Read More
March 7th, 2008 by GadElKareem
just a snippet, –sort is not good for me..try
ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | more
#more-50" class="more-link"> more.. »
Read More
December 10th, 2007 by GadElKareem
New Sitemap Creator Beta available
Sitemap Creator 0.2a is different from version 0.1, The script now is able to crawl/spider your website, create your sitemaps, ping Google, Yahoo, MSN, Ask.com, moreover.com with the location of your sitemaps and send you alerts by email when sitemaps are created or crawled by the search bot. The crawler saves sitemaps data into an easy to edit CSV file.
Download (build 20070109) :
sitemap_creator.tar.gz – sitemap_creator.zip
#more-49" class="more-link"> more.. »
Read More
November 22nd, 2007 by GadElKareem
As I mentioned on my previous post yesterday about Fixing FAlbum Plugin that I’m trying to add support for Google XML Sitemaps Plugin to FAlbum so that all URLs including albums, photos and tags would be added to Blog’s Sitemap which would be crawled by Google, Yahoo and MSN . #more-48" class="more-link"> more.. »
Read More
November 20th, 2007 by GadElKareem
This is not working anymore
FAlbum is a WordPress Plug-in that adds your Flickr photo albums to your blog without redirecting the viewer to Flickr or leaving your blog. It is very useful and unique, I have always needed that plugin on my blog, however, some features needed a lot of digging into the code to fix or to get it working. So, I am going to describe a step by step installation of this plugin then will show how to fix. #more-47" class="more-link"> more.. »
Read More
October 29th, 2007 by hkareem
Process Modeling
Abstract
In this article, we will walk through modeling a sample process using the Business Process Execution Language for Web Services. This article uses Sybase PowerDesigner as the modeling tool and J2EE 1.4 as the programming and deployment platform. The article assumes basic knowledge of BPEL4WS, UML, WSDL and J2EE technologies.
#more-46" class="more-link"> more.. »
Read More
October 19th, 2007 by GadElKareem
Since IE6 was released it has been a pain for every designer, the browser has its own world leaving behind web standards, forcing designers to add hacks, extra code and scripts just to fix its stupid bugs, bugs and more Bugs. #more-44" class="more-link"> more.. »
Read More
September 17th, 2007 by GadElKareem
*Updated 11 Jan 2007 to include luazlib, fix lighty config file and add zlib decoding to cache.lua for older browsers
Since I read the documentations for mod_cml, I was very excited to use this module since caching using PHP running as FastCGI is not helping much during server peak load. However, mod_cml was replaced by mod_magnet which is more flexible and gives more control over request handling in Lighttpd. This Article will focus on caching your PHP scripts using Lua and mod_magnet under Lighttpd, #more-42" class="more-link"> more.. »
Read More
June 23rd, 2007 by GadElKareem
Although Compression is a very important method of making your pages lighter and easier for users to download, it’s definitely going to cost you more CPU and on high load servers it’s not recommended unless you already know how to cache your HTML pages. #more-41" class="more-link"> more.. »
Read More
June 12th, 2007 by GadElKareem
is it a googlebot failure? or Google is not into SEO ?
check : http://www.google.com/search?q=search #more-40" class="more-link"> more.. »
Read More