Hello.
It’s been more than 1 an year and a half since this blog was started.
Now, I, Mihai Valentin launched my online portfolio, and part of this blog will be moved and continued to www.mihaivalentin.com/blog
Please update your links!
Hello.
It’s been more than 1 an year and a half since this blog was started.
Now, I, Mihai Valentin launched my online portfolio, and part of this blog will be moved and continued to www.mihaivalentin.com/blog
Please update your links!
aptitude install virtualbox-ose-guest-x11
#/bin/shLAST_BACKUP=`cat /backup/_last_backup`tar --after-date="`echo $LAST_BACKUP`" -X/backup/exclude.lst -zvcf /backup/web-`date +"%Y-%m-%d_%H-%M-%S"`.tgz /srv/www/date +"%Y-%m-%d %H:%M:%S %Z" > /backup/_last_backup
The ideea is simple: _last_backup file will contain the data of the last backup, so that in the next one will be included only files that have been changed or added. Useful when you cannot install rdiff-backup.
Put the codes below in .bashrc in your user directory
function findt() { find . -name "$2" -print | xargs grep "$1" --color=ALWAYS ;}
To run:
findt "function" "*.php" findt "System.exit" "*.java"
I wrote an Apache module that provides the momentary load average through the environment variables LOADAVG1 (1 minute load average) and LOADAVG5 (5 minutes load average)
If you want to log the load average at the time of your requests, you can simply activate mod_loadaverage and then, in apache2.conf, use:
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" %{LOADAVG1}e %{LOADAVG5}e" default_and_loadaverage
CustomLog /var/log/acceslog.loadaverage.log default_and_loadaverage
This way, the load average will be appended to each request logged.
If you want to access these variables from PHP, you can do:
$loadavg1 = $_SERVER['LOADAVG1']; // outputs the load 1 minute load average (ex: 0.5)
#include "httpd.h"
#include "http_config.h"
static int append_loadavg(request_rec *r) {
char *buf1 = (char *)malloc(15);
char *buf2 = (char *)malloc(15);
float la1,la5;
FILE *f = fopen("/proc/loadavg","r");
if (f != NULL) {
fscanf(f,"%f %f",&la1,&la5);
fclose(f);
sprintf(buf1, "%3.2f",la1);
sprintf(buf2, "%3.2f",la5);
apr_table_setn(r->subprocess_env,"LOADAVG1",buf1);
apr_table_setn(r->subprocess_env,"LOADAVG5",buf2);
}
return OK;
}
static void loadavg_module_register_hooks(apr_pool_t *p) {
ap_hook_fixups(append_loadavg,NULL,NULL,APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA loadavg_module = {
STANDARD20_MODULE_STUFF,
NULL,
NULL,
NULL,
NULL,
NULL,
loadavg_module_register_hooks
};
You need apxs2 (aptitude install apache2-dev – the developement version of apache)
apxs2 -i -c mod_loadavg.c
where mod_loadavg.c is the sourcecode above.
What apxs2 should do is:
- compile your module
- copy it to /usr/lib/apache2/modules (or whereever your apache modules dir folder is)
- add in httpd.conf the following: “LoadModule loadavg_module “/usr/lib/apache2/modules/mod_loadavg.so”"
After installation, make sure you restart apache.
As I told you before, a usage of it may be log the loadaverage during all of your reqeuests or to find out the loadaverage value from PHP.
This module is not tested thouroughly, but if you find it has any problems, tell me.
Change these lines in /etc/opt/ssh/sshd_config
SyslogFacility AUTH
LogLevel INFO
Then restart sshd.
Then add this line to /etc/syslog.conf
auth.info;mail.none /var/adm/syslog/sshd.log
Then restart syslogd and youre done!
Source: http://forums13.itrc.hp.com/service/forums/questionanswer.do?admit=109447627+1275035196242+28353475&threadId=267234
find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'
Source:http://snippets.dzone.com/posts/show/1491
ffmpeg -i source.mp4 -s qcif -vcodec h263 -acodec aac -ac 1 -ar 8000 -r 25 -ab 32 -y output.3gp
@media handheld, screen and (max-width: 500px) {
body {background: #c00 !important;}
}
http://www.whoopis.com/howtos/web-bandwidth-limit.html
Instead of putting the conf inside the httpd2.conf, put it in the virtual hosts configuration. Otherwise it won’t work.
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
BandwidthModule On
ForceBandWidthModule On
Bandwidth all 0
LargeFileLimit .flv 1000 256000
MinBandwidth all -1
</Directory>
…
http://tperspective.blogspot.com/2009/02/apache-flv-streaming-done-right.html
sed -re ‘s/search/replace/g’ -i *
1. Download a stable PHP
2. ./configure && make (you must also enable the cgi)
3. In the vhost you need, just write
fastcgi.server = ( “.php” =>
((
“socket” => “/www/myvhost/tmp/php-fastcgi.socket”,
“bin-path” => “/usr/local/php-5.3.1/sapi/cgi/php-cgi -c /www/myvhost/php.ini”
))
)
4. Make sure that /usr/local/php-5.3.1 can be accessed by Lighttpd (it has enough permissions)
5. Restart lighttpd and enjoy!
screen -S myscreen
you login, and issue a command
to recover from another console,
screen -r myscreen
On Linux, create mytransfer.c with:
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
int main(int argc, char *argv[]) {
char buf[1024];
// Socket stuff
int sockfd, portno, n;
struct hostent *he;
struct sockaddr_in their_addr;
he=gethostbyname("THE.WINDOWS.IP.HERE");
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0) printf("ERROR opening socket");
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(39412); // port number
their_addr.sin_addr = *((struct in_addr *)he->h_addr);
memset(&(their_addr.sin_zero), '', 8);
if(connect(sockfd, (struct sockaddr *)&their_addr, sizeof(struct sockaddr)) == -1) {
printf("connect()\n");
exit(1);
} else {
printf("s-a conectat!\n");
}
// Socket stuff end
while (1) {
fgets(buf, 1024, stdin);
if (strlen(buf)>0) {
write(sockfd, buf,strlen(buf));
sleep(1);
}
memset(buf,0,sizeof(buf));
}
return 0;
}
On Windows, download and install netcat, and run it with the following command line:
nc -L -l -p 39412 > c:\php.log
Then, on Linux:
killall -9 mytransfer.o; gcc -o mytransfer.o mytransfer.c && tail -f /tmp/php.log | ./mytransfer.o
You will now notice that the c:\php.log will contain the data which is being written in realtime on /tmp/php.log on the linux machine.
First: Install LUA:
http://bluescripts.net/tag/lighttpd/
Second: Instal Lighttpd
Third: http://h264.code-shop.com/trac/wiki/Mod-H264-Streaming-Lighttpd-Version2
4th: Make sure autoconf, automake, libtool are the latest versions.
If you encounter problems, http://h264.code-shop.com/trac/discussion/1/85
If you are having problems with wordpress search form in Lighttpd, it’s because it does not directly support the QSA parameter from mod_rewrite.
To overcome this problem, instead of:
“.” => “index.php”
use
“.(?:\?(.*))?” => “index.php?$1″
This simulates QSA and makes your search work
In order to make a simple function, you must first create a new language, called plpgsql. After that, create the function using plpgsql language, not the sql function.
To be able to set the serial pseudo-data-type, you must first set that field as primary key and then that type will appear for usage in Navicat PostgreSQL.
Add this to your css
.x-grid3-header {position: relative;}
Options -Indexes
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^m/(.*) /index.php?u=$1&m=1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*) /index.php?u=$1 [L]
mysqldump –user=dbuser –password=dbpass dbname | gzip -9 > backup-`date +”%Y-%m-%d_%H-%M-%S”`.sql.gz
tar zcfv backup-`date +”%Y-%m-%d_%H-%M-%S”`.tgz /root/code
http://forums.crm.saeven.net/showthread.php?t=128
The folder containing the files should be 0755, and the files inside 0644 (in order not to yield “is writable by the group” error)
To do this, just call the following functions
find . -type f -print0 | xargs -0 chmod 644;find . -type d -print0 | xargs -0 chmod 755
function contains($haystack, $needle) { return strpos($haystack,$needle)!==FALSE; } function beginsWith($str, $prefix) { return strpos($str, $prefix)===0; }
Problem: see the title, a very frustrating problem.
Solution: This problem appears usually when using maps like Google Maps, Virtual Earth, Yahoo on your page. Move the script just before the closing of the body tag.
Problem: You may have made a CSS only design, and the results look like this: (two divs, one floated on the left and the other one floating on the right)
Solution: do not use ANY padding at all on those 2 elements. Why?
Because Internet Explorer 6 has a different approach on the W3C box model
Problem: When setting a margin in Internet Explorer 6, instead of respecting it, it doubles it. For example, if we set margin:10px, IE6 will make the margin 20px.
Solution: just set the element’s display style to inline. (style=”margin-left: 10px; display: inline”)
WordPress is great, but what do you do if you want to deploy a blog developed on your localhost on a remote host, let’s name it myblog.com. The problem is that WordPress keeps the absolute links in the database, on various fields in various tables. Searching and replacing those fields and tables can be frustrating, so I propose an alternative solution
Here are the steps to do:
Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!